Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ZEN-3994] GenFlow: Add support for Swagger-Codegen v3.0 with OpenAPI v3 Support (DO NOT MERGE) #53

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/genflow-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<parent>
<groupId>com.reprezen.genflow</groupId>
<artifactId>genflow</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.1-ZEN-3994-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public static PropertyBuilder swaggerCodegenProvider() {
.withUiSymbol("S").withUiColor("109,154,0");
}

public static PropertyBuilder swaggerCodegenV3Provider() {
return new PropertyBuilder().named(PROVIDER) //
.withValue("Swagger Codegen v3") //
.withUiSymbol("S").withUiColor("109,154,0");
}

public static PropertyBuilder openApiGeneratorProvider() {
return new PropertyBuilder().named(PROVIDER) //
.withValue("OpenAPI Generator") //
Expand Down
2 changes: 1 addition & 1 deletion modules/genflow-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.reprezen.genflow</groupId>
<artifactId>genflow</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.1-ZEN-3994-SNAPSHOT</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>genflow-tests</artifactId>
Expand Down
10 changes: 1 addition & 9 deletions modules/gentemplates/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>com.reprezen.genflow</groupId>
<artifactId>genflow</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.1-ZEN-3994-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<name>genflow-common</name>
Expand Down Expand Up @@ -76,14 +76,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen</artifactId>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.reprezen.genflow.common.codegen.GenModulesInfo.Parameter;

import io.swagger.codegen.CodegenConfig;

public abstract class GenModuleWrapper<Config> {

protected Config config;
Expand Down Expand Up @@ -99,7 +95,7 @@ public String getDerivedName() {
return name;
}

enum GenericType {
public enum GenericType {
CLIENT, SERVER, DOCUMENTATION, CONFIG, OTHER
};

Expand Down Expand Up @@ -128,126 +124,6 @@ public List<Parameter> getParameters() {

public abstract Logger getLogger();

public static class ScgModuleWrapper extends GenModuleWrapper<io.swagger.codegen.CodegenConfig> {

private Logger logger = LoggerFactory.getLogger(ScgModuleWrapper.class);

public ScgModuleWrapper(io.swagger.codegen.CodegenConfig config) {
super(config);
}

public ScgModuleWrapper(Class<CodegenConfig> configClass) {
super(configClass);
}

public static GenModuleWrapper<io.swagger.codegen.CodegenConfig> getDummyInstance() {
return new ScgModuleWrapper(io.swagger.codegen.CodegenConfig.class);
}

@Override
public Enum<?> getType() {
return config.getTag();
}

@Override
public GenericType getGenericType() {
switch (config.getTag()) {
case CLIENT:
return GenericType.CLIENT;
case SERVER:
return GenericType.SERVER;
case DOCUMENTATION:
return GenericType.DOCUMENTATION;
case CONFIG:
return GenericType.CONFIG;
case OTHER:
default:
return GenericType.OTHER;
}
}

@Override
public String getName() {
return config.getName();
}

@Override
public List<CliOptWrapper<?>> getClientOptions() {
return config.cliOptions().stream().map(cliOpt -> new ScgCliOptWrapper(cliOpt))
.collect(Collectors.toList());
}

@Override
public Logger getLogger() {
return logger;
}

@Override
public Enum<?> typeNamed(String name) {
return io.swagger.codegen.CodegenType.valueOf(name);
}

}

public static class OagModuleWrapper extends GenModuleWrapper<org.openapitools.codegen.CodegenConfig> {
private Logger logger = LoggerFactory.getLogger(ScgModuleWrapper.class);

public OagModuleWrapper(org.openapitools.codegen.CodegenConfig config) {
super(config);
}

public OagModuleWrapper(Class<org.openapitools.codegen.CodegenConfig> configClass) {
super(configClass);
}

public static GenModuleWrapper<org.openapitools.codegen.CodegenConfig> getDummyInstance() {
return new OagModuleWrapper(org.openapitools.codegen.CodegenConfig.class);
}

@Override
public Enum<?> getType() {
return config.getTag();
}

@Override
public GenericType getGenericType() {
switch (config.getTag()) {
case CLIENT:
return GenericType.CLIENT;
case SERVER:
return GenericType.SERVER;
case DOCUMENTATION:
return GenericType.DOCUMENTATION;
case CONFIG:
return GenericType.CONFIG;
case OTHER:
default:
return GenericType.OTHER;
}
}

@Override
public String getName() {
return config.getName();
}

@Override
public List<CliOptWrapper<?>> getClientOptions() {
return config.cliOptions().stream().map(cliOpt -> new OagCliOptWrapper(cliOpt))
.collect(Collectors.toList());
}

@Override
public Enum<?> typeNamed(String name) {
return org.openapitools.codegen.CodegenType.valueOf(name);
}

@Override
public Logger getLogger() {
return logger;
}
}

public static abstract class CliOptWrapper<CliOpt> {

protected CliOpt cliOpt;
Expand All @@ -262,42 +138,6 @@ public CliOptWrapper(CliOpt cliOpt) {

}

public static class ScgCliOptWrapper extends CliOptWrapper<io.swagger.codegen.CliOption> {

public ScgCliOptWrapper(io.swagger.codegen.CliOption cliOpt) {
super(cliOpt);
}

@Override
public String getName() {
return cliOpt.getOpt();
}

@Override
public String getDescription() {
return cliOpt.getDescription();
}

}

public static class OagCliOptWrapper extends CliOptWrapper<org.openapitools.codegen.CliOption> {

public OagCliOptWrapper(org.openapitools.codegen.CliOption cliOpt) {
super(cliOpt);
}

@Override
public String getName() {
return cliOpt.getOpt();
}

@Override
public String getDescription() {
return cliOpt.getDescription();
}

}

static class Util {
private static String trimFromEnd(String s, String... suffixes) {
for (String suffix : suffixes) {
Expand Down
2 changes: 1 addition & 1 deletion modules/gentemplates/openapi-diagram/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.reprezen.genflow</groupId>
<artifactId>genflow</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.1-ZEN-3994-SNAPSHOT</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>openapi-diagram</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/gentemplates/openapi-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.reprezen.genflow</groupId>
<artifactId>genflow</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.1-ZEN-3994-SNAPSHOT</version>
<relativePath>../../..</relativePath>
</parent>
<artifactId>openapi-generator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.reprezen.genflow.openapi.generator;

import com.reprezen.genflow.common.codegen.GenModuleWrapper.CliOptWrapper;

public class OagCliOptWrapper extends CliOptWrapper<org.openapitools.codegen.CliOption> {

public OagCliOptWrapper(org.openapitools.codegen.CliOption cliOpt) {
super(cliOpt);
}

@Override
public String getName() {
return cliOpt.getOpt();
}

@Override
public String getDescription() {
return cliOpt.getDescription();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.reprezen.genflow.api.template.IGenTemplate;
import com.reprezen.genflow.common.codegen.CodegenGenTemplateGroup;
import com.reprezen.genflow.common.codegen.GenModuleWrapper;
import com.reprezen.genflow.common.codegen.GenModuleWrapper.OagModuleWrapper;
import com.reprezen.genflow.common.codegen.GenModulesInfo.Info;

public class OagCodegenGenTemplateGroup extends CodegenGenTemplateGroup<CodegenConfig> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.reprezen.genflow.common.codegen.GenModuleDiscovery;
import com.reprezen.genflow.common.codegen.GenModuleWrapper;
import com.reprezen.genflow.common.codegen.GenModuleWrapper.OagModuleWrapper;

public class OagCodegenModuleDiscovery extends GenModuleDiscovery<CodegenConfig> {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.reprezen.genflow.openapi.generator;

import java.util.List;
import java.util.stream.Collectors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.reprezen.genflow.common.codegen.GenModuleWrapper;

public class OagModuleWrapper extends GenModuleWrapper<org.openapitools.codegen.CodegenConfig> {

private Logger logger = LoggerFactory.getLogger(OagModuleWrapper.class);

public OagModuleWrapper(org.openapitools.codegen.CodegenConfig config) {
super(config);
}

public OagModuleWrapper(Class<org.openapitools.codegen.CodegenConfig> configClass) {
super(configClass);
}

public static GenModuleWrapper<org.openapitools.codegen.CodegenConfig> getDummyInstance() {
return new OagModuleWrapper(org.openapitools.codegen.CodegenConfig.class);
}

@Override
public Enum<?> getType() {
return config.getTag();
}

@Override
public GenericType getGenericType() {
switch (config.getTag()) {
case CLIENT:
return GenericType.CLIENT;
case SERVER:
return GenericType.SERVER;
case DOCUMENTATION:
return GenericType.DOCUMENTATION;
case CONFIG:
return GenericType.CONFIG;
case OTHER:
default:
return GenericType.OTHER;
}
}

@Override
public String getName() {
return config.getName();
}

@Override
public List<CliOptWrapper<?>> getClientOptions() {
return config.cliOptions().stream().map(cliOpt -> new OagCliOptWrapper(cliOpt)).collect(Collectors.toList());
}

@Override
public Enum<?> typeNamed(String name) {
return org.openapitools.codegen.CodegenType.valueOf(name);
}

@Override
public Logger getLogger() {
return logger;
}
}
2 changes: 1 addition & 1 deletion modules/gentemplates/openapi-normalizer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.reprezen.genflow</groupId>
<artifactId>genflow</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.1-ZEN-3994-SNAPSHOT</version>
<relativePath>../../..</relativePath>
</parent>
<artifactId>openapi-normalizer</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion modules/gentemplates/openapi3-doc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<parent>
<groupId>com.reprezen.genflow</groupId>
<artifactId>genflow</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.1-ZEN-3994-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<dependencies>
Expand Down
Loading