Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5ac14b8
Added library and edited generator to support server stub generation …
Feb 4, 2020
6dd9802
Trimmed and tweaked pom.xml template and removed unnecessary template…
Feb 5, 2020
49e8a0a
minor edits
jmezna Feb 6, 2020
580f666
Added new library to Java client codegen (microprofile-kumuluzee). A
chuckle-dog Feb 15, 2020
0e3233a
Merge branch 'master' of https://github.com/chuckle-dog/openapi-gener…
chuckle-dog Feb 15, 2020
42ada37
Edited README for microprofile-kumuluzee
chuckle-dog Feb 15, 2020
97b569c
Synced with remote master, resolved merge conflicts.
chuckle-dog Apr 10, 2020
dc1c3d4
Edited docs to include new KumuluzEE library options.
chuckle-dog Apr 10, 2020
f994ddd
Updated kee-rest-client client POM dependency version to latest
chuckle-dog Apr 10, 2020
741c256
fixed pom, edited REAMDE
jmezna Apr 15, 2020
6321cea
Trimmed redundant dependencies from KEE client pom
chuckle-dog Apr 15, 2020
56fef6d
Removed unnecessary DefaultGenerator edit, modified config template a…
chuckle-dog Apr 20, 2020
db0d79d
Merge branch 'master' into master
chuckle-dog Apr 22, 2020
30e3818
Made mp framework an additional property for microprofile instead of …
chuckle-dog Apr 30, 2020
ad63749
Merge branch 'master' of https://github.com/chuckle-dog/openapi-gener…
chuckle-dog Apr 30, 2020
b0ad1c6
Updated documentation with microprofile framework
chuckle-dog Apr 30, 2020
443f3f6
Merge branch 'master' into master
chuckle-dog May 7, 2020
176166b
Merge branch 'master' into master
chuckle-dog Aug 18, 2020
5b27252
Fixed errors caused by removed functions and variables
chuckle-dog Aug 19, 2020
203b62f
update doc
wing328 Aug 19, 2020
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
1 change: 1 addition & 0 deletions docs/generators/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sidebar_label: java
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x.</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2/3]=true'. (RxJava 1.x or 2.x or 3.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: Jackson 2.9.x</dd></dl>|okhttp-gson|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|microprofileFramework|Framework for microprofile. Possible values &quot;kumuluzee&quot;| |null|
|modelPackage|package for generated models| |org.openapitools.client.model|
|parcelableModel|Whether to generate models for Android that implement Parcelable with the okhttp-gson library.| |false|
|parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
Expand Down
2 changes: 1 addition & 1 deletion docs/generators/jaxrs-cxf-cdi.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sidebar_label: jaxrs-cxf-cdi
|invokerPackage|root package for generated code| |org.openapitools.api|
|java8|Use Java8 classes instead of third party equivalents. Starting in 5.x, JDK8 is the default and the support for JDK7, JDK6 has been dropped|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd></dl>|true|
|legacyDiscriminatorBehavior|This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. Note to developers supporting a language generator in OpenAPITools; to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd></dl>|&lt;default&gt;|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd><dt>**kumuluzee**</dt><dd>Server using KumuluzEE</dd></dl>|&lt;default&gt;|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
Expand Down
2 changes: 1 addition & 1 deletion docs/generators/jaxrs-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ sidebar_label: jaxrs-spec
|invokerPackage|root package for generated code| |org.openapitools.api|
|java8|Use Java8 classes instead of third party equivalents. Starting in 5.x, JDK8 is the default and the support for JDK7, JDK6 has been dropped|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd></dl>|true|
|legacyDiscriminatorBehavior|This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. Note to developers supporting a language generator in OpenAPITools; to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd></dl>|&lt;default&gt;|
|library|library template (sub-template)|<dl><dt>**&lt;default&gt;**</dt><dd>JAXRS spec only, to be deployed in an app server (TomEE, JBoss, WLS, ...)</dd><dt>**quarkus**</dt><dd>Server using Quarkus</dd><dt>**thorntail**</dt><dd>Server using Thorntail</dd><dt>**openliberty**</dt><dd>Server using Open Liberty</dd><dt>**helidon**</dt><dd>Server using Helidon</dd><dt>**kumuluzee**</dt><dd>Server using KumuluzEE</dd></dl>|&lt;default&gt;|
|licenseName|The name of the license| |Unlicense|
|licenseUrl|The URL of the license| |http://unlicense.org|
|modelPackage|package for generated models| |org.openapitools.model|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.GzipFeatures;
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
Expand Down Expand Up @@ -60,12 +61,16 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException";
public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode";
public static final String CASE_INSENSITIVE_RESPONSE_HEADERS = "caseInsensitiveResponseHeaders";
public static final String MICROPROFILE_FRAMEWORK = "microprofileFramework";
public static final String USE_ABSTRACTION_FOR_FILES = "useAbstractionForFiles";

public static final String PLAY_24 = "play24";
public static final String PLAY_25 = "play25";
public static final String PLAY_26 = "play26";

public static final String MICROPROFILE_DEFAULT = "default";
public static final String MICROPROFILE_KUMULUZEE = "kumuluzee";

public static final String FEIGN = "feign";
public static final String GOOGLE_API_CLIENT = "google-api-client";
public static final String JERSEY1 = "jersey1";
Expand All @@ -91,7 +96,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
// (mustache does not allow for boolean operators so we need this extra field)
protected boolean doNotUseRx = true;
protected boolean usePlayWS = false;
protected String playVersion = PLAY_26;
protected String playVersion = PLAY_25;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change it back to PLAY_26 as the default play version in another PR.

protected String microprofileFramework = MICROPROFILE_DEFAULT;

protected boolean asyncNative = false;
protected boolean parcelableModel = false;
protected boolean useBeanValidation = false;
Expand Down Expand Up @@ -142,6 +149,7 @@ public JavaClientCodegen() {
cliOptions.add(CliOption.newBoolean(ASYNC_NATIVE, "If true, async handlers will be used, instead of the sync version"));
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
cliOptions.add(CliOption.newBoolean(CASE_INSENSITIVE_RESPONSE_HEADERS, "Make API response's headers case-insensitive. Available on " + OKHTTP_GSON + ", " + JERSEY2 + " libraries"));
cliOptions.add(CliOption.newString(MICROPROFILE_FRAMEWORK, "Framework for microprofile. Possible values \"kumuluzee\""));
cliOptions.add(CliOption.newBoolean(USE_ABSTRACTION_FOR_FILES, "Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on " + RESTTEMPLATE + " library"));

supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.");
Expand All @@ -158,6 +166,7 @@ public JavaClientCodegen() {
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client 1.x. JSON processing: Jackson 2.9.x");


CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
// set okhttp-gson as the default
Expand Down Expand Up @@ -209,7 +218,6 @@ public void processOpts() {
} else if (MICROPROFILE.equals(getLibrary()) && "threetenbp".equals(dateLibrary)) {
dateLibrary = "legacy";
}

super.processOpts();

// RxJava
Expand Down Expand Up @@ -254,6 +262,17 @@ public void processOpts() {
}
additionalProperties.put(PLAY_VERSION, playVersion);

// Microprofile framework
if (additionalProperties.containsKey(MICROPROFILE_FRAMEWORK)) {
this.setMicroprofileFramework(additionalProperties.get(MICROPROFILE_FRAMEWORK).toString());

if (!MICROPROFILE_KUMULUZEE.equals(microprofileFramework)) {
throw new RuntimeException("Ivalid microprofileFramework '{}'. Must be 'kumuluzee' or none.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix the typo (Ivalid => Invalid) and string interpolation '{}' in another PR.

}

}
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);

if (additionalProperties.containsKey(ASYNC_NATIVE)) {
this.setAsyncNative(convertPropertyToBooleanAndWriteBack(ASYNC_NATIVE));
}
Expand Down Expand Up @@ -448,6 +467,12 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("api_exception.mustache", apiExceptionFolder, "ApiException.java"));
supportingFiles.add(new SupportingFile("api_exception_mapper.mustache", apiExceptionFolder, "ApiExceptionMapper.java"));
serializationLibrary = "none";

if (microprofileFramework.equals(MICROPROFILE_KUMULUZEE)){
supportingFiles.add(new SupportingFile("kumuluzee.pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("kumuluzee.config.yaml.mustache", "src/main/resources", "config.yaml"));
supportingFiles.add(new SupportingFile("kumuluzee.beans.xml.mustache", "src/main/resources/META-INF", "beans.xml"));
}
} else {
LOGGER.error("Unknown library option (-l/--library): " + getLibrary());
}
Expand Down Expand Up @@ -843,6 +868,10 @@ public void setAsyncNative(boolean asyncNative) {
this.asyncNative = asyncNative;
}

public void setMicroprofileFramework(String microprofileFramework) {
this.microprofileFramework = microprofileFramework;
}

public void setParcelableModel(boolean parcelableModel) {
this.parcelableModel = parcelableModel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
public static final String THORNTAIL_LIBRARY = "thorntail";
public static final String OPEN_LIBERTY_LIBRARY = "openliberty";
public static final String HELIDON_LIBRARY = "helidon";
public static final String KUMULUZEE_LIBRARY = "kumuluzee";

private boolean interfaceOnly = false;
private boolean returnResponse = false;
Expand Down Expand Up @@ -99,6 +100,7 @@ public JavaJAXRSSpecServerCodegen() {
supportedLibraries.put(THORNTAIL_LIBRARY, "Server using Thorntail");
supportedLibraries.put(OPEN_LIBERTY_LIBRARY, "Server using Open Liberty");
supportedLibraries.put(HELIDON_LIBRARY, "Server using Helidon");
supportedLibraries.put(KUMULUZEE_LIBRARY, "Server using KumuluzEE");
library.setEnum(supportedLibraries);

cliOptions.add(library);
Expand Down Expand Up @@ -127,13 +129,16 @@ public void processOpts() {
additionalProperties.remove(RETURN_RESPONSE);
}
}
if (QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || OPEN_LIBERTY_LIBRARY.equals(library)) {
if (QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || OPEN_LIBERTY_LIBRARY.equals(library) || KUMULUZEE_LIBRARY.equals(library)) {
useSwaggerAnnotations = false;
} else {
if (additionalProperties.containsKey(USE_SWAGGER_ANNOTATIONS)) {
useSwaggerAnnotations = Boolean.valueOf(additionalProperties.get(USE_SWAGGER_ANNOTATIONS).toString());
}
}
if (KUMULUZEE_LIBRARY.equals(library)){
super.setSourceFolder("src/main/java");
}
writePropertyBack(USE_SWAGGER_ANNOTATIONS, useSwaggerAnnotations);

if (additionalProperties.containsKey(GENERATE_BUILDERS)) {
Expand All @@ -143,7 +148,7 @@ public void processOpts() {

if (additionalProperties.containsKey(OPEN_API_SPEC_FILE_LOCATION)) {
openApiSpecFileLocation = additionalProperties.get(OPEN_API_SPEC_FILE_LOCATION).toString();
} else if(QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library)) {
} else if(QUARKUS_LIBRARY.equals(library) || THORNTAIL_LIBRARY.equals(library) || HELIDON_LIBRARY.equals(library) || KUMULUZEE_LIBRARY.equals(library)) {
openApiSpecFileLocation = "src/main/resources/META-INF/openapi.yaml";
} else if(OPEN_LIBERTY_LIBRARY.equals(library)) {
openApiSpecFileLocation = "src/main/webapp/META-INF/openapi.yaml";
Expand Down Expand Up @@ -213,7 +218,9 @@ public void processOpts() {
.doNotOverwrite());
supportingFiles.add(new SupportingFile("beans.xml.mustache", "src/main/webapp/META-INF", "beans.xml")
.doNotOverwrite());
}
} else if(KUMULUZEE_LIBRARY.equals(library)) {
supportingFiles.add(new SupportingFile("config.yaml.mustache", "src/main/resources", "config.yaml"));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
bean-discovery-mode="annotated">
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
kumuluzee:
server:
http:
port: 8081

rest-client:
registrations:
{{#apiInfo}}{{#apis}}{{#operations}}- class: {{{invokerPackage}}}.{{{classname}}}
url: http://localhost:8080/v2
{{/operations}}{{/apis}}{{/apiInfo}}
Loading