Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !11554
Something went wrong while fetching comments. Please try again.

[Java/Microprofile] Add support for Jackson serialization & async

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/pravussum/java-microprofile-improvements into master 3 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 16

Created by: pravussum

Add support for Jackson serialization & async interfaces using Mutiny in Java Microprofile library

This PR

  • adds support for a new library option "microprofileMutiny" to generate async signatures in the API interfaces using SmallRye Mutiny which is the reactive library used by Quarkus - this will wrap the return types in Uni<>
  • adds support for the Jackson JSON serialization in the Microprofile library - currently only JSONB is supported

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

/cc @bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608

Compare
  • master (base)

and
  • latest version
    46623099
    1 commit, 2 years ago

16 files
+ 101
- 51

    Preferences

    File browser
    Compare changes
docs/ge‎nerators‎
jav‎a.md‎ +2 -1
modules/openapi-g‎enerator/src/main‎
java/org/openapitoo‎ls/codegen/languages‎
JavaClientC‎odegen.java‎ +19 -3
resources/Java/lib‎raries/microprofile‎
api.mu‎stache‎ +4 -1
api_test‎.mustache‎ +1 -1
enumClass‎.mustache‎ +18 -0
pom.mu‎stache‎ +10 -0
returnType‎s.mustache‎ +0 -4
sam‎ples‎
client/pet‎store/java‎
microprofile-rest-c‎lient/…/…/…/…/…/…/…‎
PetAp‎i.java‎ +8 -8
StoreA‎pi.java‎ +4 -4
UserAp‎i.java‎ +8 -8
resttempla‎te-jakarta‎
a‎pi‎
openap‎i.yaml‎ +3 -0
src/main/java/…/ope‎napitools/client/api‎
PetAp‎i.java‎ +4 -0
…/…/…/…‎/…/…/…/…‎
PetAp‎i.java‎ +8 -8
StoreA‎pi.java‎ +4 -4
UserAp‎i.java‎ +8 -8
server/petstore/‎…/…/…/…/…/…/model‎
ModelLi‎st.java‎ +0 -1
docs/generators/java.md
+ 2
- 1
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -56,10 +56,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<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) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.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: JSON-B</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 4.x</dd></dl>|okhttp-gson|
|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 gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.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: JSON-B or Jackson 2.9.x</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 4.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|
|microprofileMutiny|Whether to use async types for microprofile (currently only Smallrye Mutiny is supported).| |null|
|microprofileRestClientVersion|Version of MicroProfile Rest Client API.| |null|
|modelPackage|package for generated models| |org.openapitools.client.model|
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
docs/generators/java.md
+ 2
- 1
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -56,10 +56,11 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|implicitHeadersRegex|Skip header parameters that matches given regex in the generated API methods using @ApiImplicitParams annotation. Note: this parameter is ignored when implicitHeaders=true| |null|
|invokerPackage|root package for generated code| |org.openapitools.client|
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<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) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.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: JSON-B</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 4.x</dd></dl>|okhttp-gson|
|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 gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey3' or other HTTP libraries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**jersey3**</dt><dd>HTTP client: Jersey client 3.x. JSON processing: Jackson 2.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 10.x. JSON processing: Jackson 2.9.x. or Gson 2.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: JSON-B or Jackson 2.9.x</dd><dt>**apache-httpclient**</dt><dd>HTTP client: Apache httpclient 4.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|
|microprofileMutiny|Whether to use async types for microprofile (currently only Smallrye Mutiny is supported).| |null|
|microprofileRestClientVersion|Version of MicroProfile Rest Client API.| |null|
|modelPackage|package for generated models| |org.openapitools.client.model|
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
+ 19
- 3
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -65,6 +65,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
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 MICROPROFILE_MUTINY = "microprofileMutiny";
public static final String USE_ABSTRACTION_FOR_FILES = "useAbstractionForFiles";
public static final String DYNAMIC_OPERATIONS = "dynamicOperations";
public static final String SUPPORT_STREAMING = "supportStreaming";
@@ -106,6 +107,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
protected boolean doNotUseRx = true;
protected boolean usePlayWS = false;
protected String microprofileFramework = MICROPROFILE_DEFAULT;
protected boolean microprofileMutiny = false;
protected String configKey = null;
protected boolean asyncNative = false;
@@ -197,6 +199,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
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.newString(MICROPROFILE_MUTINY, "Whether to use async types for microprofile (currently only Smallrye Mutiny is supported)."));
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, webclient, libraries"));
cliOptions.add(CliOption.newBoolean(DYNAMIC_OPERATIONS, "Generate operations dynamically at runtime from an OAS", this.dynamicOperations));
cliOptions.add(CliOption.newBoolean(SUPPORT_STREAMING, "Support streaming endpoint (beta)", this.supportStreaming));
@@ -221,7 +224,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x");
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8");
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: JSON-B");
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client 1.x. JSON processing: JSON-B or Jackson 2.9.x");
supportedLibraries.put(APACHE, "HTTP client: Apache httpclient 4.x");
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
@@ -333,6 +336,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);
if (additionalProperties.containsKey(MICROPROFILE_MUTINY)) {
this.setMicroprofileMutiny(convertPropertyToBooleanAndWriteBack(MICROPROFILE_MUTINY));
}
if (!additionalProperties.containsKey(MICROPROFILE_REST_CLIENT_VERSION)) {
additionalProperties.put(MICROPROFILE_REST_CLIENT_VERSION, MICROPROFILE_REST_CLIENT_DEFAULT_VERSION);
} else {
@@ -625,7 +632,12 @@ public class JavaClientCodegen extends AbstractJavaCodegen
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("api_exception.mustache", apiExceptionFolder, "ApiException.java"));
supportingFiles.add(new SupportingFile("api_exception_mapper.mustache", apiExceptionFolder, "ApiExceptionMapper.java"));
serializationLibrary = "none";
if (getSerializationLibrary() == null) {
LOGGER.info("No serializationLibrary configured, using '{}' as fallback", SERIALIZATION_LIBRARY_JSONB);
setSerializationLibrary(SERIALIZATION_LIBRARY_JSONB);
} else if (getSerializationLibrary().equals(SERIALIZATION_LIBRARY_GSON)) {
forceSerializationLibrary(SERIALIZATION_LIBRARY_JSONB);
}
if (microprofileFramework.equals(MICROPROFILE_KUMULUZEE)) {
supportingFiles.add(new SupportingFile("kumuluzee.pom.mustache", "", "pom.xml"));
@@ -1102,7 +1114,11 @@ public class JavaClientCodegen extends AbstractJavaCodegen
this.microprofileFramework = microprofileFramework;
}
public void setConfigKey(String configKey) {
public void setMicroprofileMutiny(boolean microprofileMutiny) {
this.microprofileMutiny = microprofileMutiny;
}
public void setConfigKey(String configKey) {
this.configKey = configKey;
}
modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api.mustache
+ 4
- 1
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -15,6 +15,9 @@ import {{rootJavaEEPackage}}.ws.rs.core.MediaType;
{{^disableMultipart}}
import org.apache.cxf.jaxrs.ext.multipart.*;
{{/disableMultipart}}
{{#microprofileMutiny}}
import io.smallrye.mutiny.Uni;
{{/microprofileMutiny}}
{{#useBeanValidation}}
import {{javaxPackage}}.validation.constraints.*;
@@ -66,7 +69,7 @@ public interface {{classname}} {
{{#hasProduces}}
@Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} })
{{/hasProduces}}
public {{{returnType}}}{{^returnType}}void{{/returnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException, ProcessingException;
{{^vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<{{{returnType}}}>{{/microprofileMutiny}}{{^microprofileMutiny}}{{{returnType}}}{{/microprofileMutiny}}{{/vendorExtensions.x-java-is-response-void}}{{#vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<Void>{{/microprofileMutiny}}{{^microprofileMutiny}}void{{/microprofileMutiny}}{{/vendorExtensions.x-java-is-response-void}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException, ProcessingException;
{{/operation}}
}
{{/operations}}
modules/openapi-generator/src/main/resources/Java/libraries/microprofile/api_test.mustache
+ 1
- 1
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -72,7 +72,7 @@ public class {{classname}}Test {
{{#allParams}}
{{^isFile}}{{{dataType}}} {{paramName}} = null;{{/isFile}}{{#isFile}}org.apache.cxf.jaxrs.ext.multipart.Attachment {{paramName}} = null;{{/isFile}}
{{/allParams}}
//{{#returnType}}{{{.}}} response = {{/returnType}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
//{{^vendorExtensions.x-java-is-response-void}}{{#microprofileMutiny}}Uni<{{{returnType}}}>{{/microprofileMutiny}}{{^microprofileMutiny}}{{{returnType}}}{{/microprofileMutiny}} response = {{/vendorExtensions.x-java-is-response-void}}api.{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
//{{#returnType}}assertNotNull(response);{{/returnType}}
modules/openapi-generator/src/main/resources/Java/libraries/microprofile/enumClass.mustache
+ 18
- 0
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -3,8 +3,10 @@
@XmlEnum({{dataType}}.class)
{{/withXml}}
{{^withXml}}
{{#jsonb}}
@JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class)
@JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class)
{{/jsonb}}
{{/withXml}}
{{>additionalEnumTypeAnnotations}}public enum {{datatypeWithEnum}} {
@@ -24,6 +26,9 @@
value = v;
}
{{#jackson}}
@JsonValue
{{/jackson}}
public {{dataType}} value() {
return value;
}
@@ -44,6 +49,7 @@
}
{{/withXml}}
{{^withXml}}
{{#jsonb}}
public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> {
@Override
public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
@@ -62,5 +68,17 @@
generator.write(obj.value);
}
}
{{/jsonb}}
{{#jackson}}
@JsonCreator
public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (b.value.equals(value)) {
return b;
}
}
{{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}}
}
{{/jackson}}
{{/withXml}}
}
modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom.mustache
+ 10
- 0
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -156,6 +156,13 @@
<version>${jakarta.annotation.version}</version>
<scope>provided</scope>
</dependency>
{{#microprofileMutiny}}
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny</artifactId>
<version>${mutiny.version}</version>
</dependency>
{{/microprofileMutiny}}
</dependencies>
<repositories>
<repository>
@@ -196,5 +203,8 @@
<maven.failsafe.plugin.version>2.6</maven.failsafe.plugin.version>
<build.helper.maven.plugin.version>1.9.1</build.helper.maven.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
{{#microprofileMutiny}}
<mutiny.version>1.2.0</mutiny.version>
{{/microprofileMutiny}}
</properties>
</project>
modules/openapi-generator/src/main/resources/Java/libraries/microprofile/returnTypes.mustache deleted 100644 → 0
+ 0
- 4
  • View file @ cce3c963

{{#useGenericResponse}}Response{{/useGenericResponse}}{{! non-generic response:
}}{{^useGenericResponse}}{{!
}}{{{returnType}}}{{!
}}{{/useGenericResponse}}
\ No newline at end of file
samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/api/PetApi.java
+ 8
- 8
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -49,7 +49,7 @@ public interface PetApi {
@POST
@Consumes({ "application/json", "application/xml" })
public void addPet(Pet body) throws ApiException, ProcessingException;
void addPet(Pet body) throws ApiException, ProcessingException;
/**
* Deletes a pet
@@ -57,7 +57,7 @@ public interface PetApi {
*/
@DELETE
@Path("/{petId}")
public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey) throws ApiException, ProcessingException;
void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey) throws ApiException, ProcessingException;
/**
* Finds Pets by status
@@ -68,7 +68,7 @@ public interface PetApi {
@GET
@Path("/findByStatus")
@Produces({ "application/xml", "application/json" })
public List<Pet> findPetsByStatus(@QueryParam("status") List<String> status) throws ApiException, ProcessingException;
List<Pet> findPetsByStatus(@QueryParam("status") List<String> status) throws ApiException, ProcessingException;
/**
* Finds Pets by tags
@@ -81,7 +81,7 @@ public interface PetApi {
@GET
@Path("/findByTags")
@Produces({ "application/xml", "application/json" })
public List<Pet> findPetsByTags(@QueryParam("tags") List<String> tags) throws ApiException, ProcessingException;
List<Pet> findPetsByTags(@QueryParam("tags") List<String> tags) throws ApiException, ProcessingException;
/**
* Find pet by ID
@@ -92,7 +92,7 @@ public interface PetApi {
@GET
@Path("/{petId}")
@Produces({ "application/xml", "application/json" })
public Pet getPetById(@PathParam("petId") Long petId) throws ApiException, ProcessingException;
Pet getPetById(@PathParam("petId") Long petId) throws ApiException, ProcessingException;
/**
* Update an existing pet
@@ -101,7 +101,7 @@ public interface PetApi {
@PUT
@Consumes({ "application/json", "application/xml" })
public void updatePet(Pet body) throws ApiException, ProcessingException;
void updatePet(Pet body) throws ApiException, ProcessingException;
/**
* Updates a pet in the store with form data
@@ -110,7 +110,7 @@ public interface PetApi {
@POST
@Path("/{petId}")
@Consumes({ "application/x-www-form-urlencoded" })
public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status) throws ApiException, ProcessingException;
void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status) throws ApiException, ProcessingException;
/**
* uploads an image
@@ -120,5 +120,5 @@ public interface PetApi {
@Path("/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment _fileDetail) throws ApiException, ProcessingException;
ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment _fileDetail) throws ApiException, ProcessingException;
}
samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/api/StoreApi.java
+ 4
- 4
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -48,7 +48,7 @@ public interface StoreApi {
*/
@DELETE
@Path("/order/{orderId}")
public void deleteOrder(@PathParam("orderId") String orderId) throws ApiException, ProcessingException;
void deleteOrder(@PathParam("orderId") String orderId) throws ApiException, ProcessingException;
/**
* Returns pet inventories by status
@@ -59,7 +59,7 @@ public interface StoreApi {
@GET
@Path("/inventory")
@Produces({ "application/json" })
public Map<String, Integer> getInventory() throws ApiException, ProcessingException;
Map<String, Integer> getInventory() throws ApiException, ProcessingException;
/**
* Find purchase order by ID
@@ -70,7 +70,7 @@ public interface StoreApi {
@GET
@Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" })
public Order getOrderById(@PathParam("orderId") Long orderId) throws ApiException, ProcessingException;
Order getOrderById(@PathParam("orderId") Long orderId) throws ApiException, ProcessingException;
/**
* Place an order for a pet
@@ -79,5 +79,5 @@ public interface StoreApi {
@POST
@Path("/order")
@Produces({ "application/xml", "application/json" })
public Order placeOrder(Order body) throws ApiException, ProcessingException;
Order placeOrder(Order body) throws ApiException, ProcessingException;
}
samples/client/petstore/java/microprofile-rest-client/src/main/java/org/openapitools/client/api/UserApi.java
+ 8
- 8
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -49,7 +49,7 @@ public interface UserApi {
*/
@POST
public void createUser(User body) throws ApiException, ProcessingException;
void createUser(User body) throws ApiException, ProcessingException;
/**
* Creates list of users with given input array
@@ -57,7 +57,7 @@ public interface UserApi {
*/
@POST
@Path("/createWithArray")
public void createUsersWithArrayInput(List<User> body) throws ApiException, ProcessingException;
void createUsersWithArrayInput(List<User> body) throws ApiException, ProcessingException;
/**
* Creates list of users with given input array
@@ -65,7 +65,7 @@ public interface UserApi {
*/
@POST
@Path("/createWithList")
public void createUsersWithListInput(List<User> body) throws ApiException, ProcessingException;
void createUsersWithListInput(List<User> body) throws ApiException, ProcessingException;
/**
* Delete user
@@ -75,7 +75,7 @@ public interface UserApi {
*/
@DELETE
@Path("/{username}")
public void deleteUser(@PathParam("username") String username) throws ApiException, ProcessingException;
void deleteUser(@PathParam("username") String username) throws ApiException, ProcessingException;
/**
* Get user by user name
@@ -84,7 +84,7 @@ public interface UserApi {
@GET
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
public User getUserByName(@PathParam("username") String username) throws ApiException, ProcessingException;
User getUserByName(@PathParam("username") String username) throws ApiException, ProcessingException;
/**
* Logs user into the system
@@ -93,7 +93,7 @@ public interface UserApi {
@GET
@Path("/login")
@Produces({ "application/xml", "application/json" })
public String loginUser(@QueryParam("username") String username, @QueryParam("password") String password) throws ApiException, ProcessingException;
String loginUser(@QueryParam("username") String username, @QueryParam("password") String password) throws ApiException, ProcessingException;
/**
* Logs out current logged in user session
@@ -101,7 +101,7 @@ public interface UserApi {
*/
@GET
@Path("/logout")
public void logoutUser() throws ApiException, ProcessingException;
void logoutUser() throws ApiException, ProcessingException;
/**
* Updated user
@@ -111,5 +111,5 @@ public interface UserApi {
*/
@PUT
@Path("/{username}")
public void updateUser(@PathParam("username") String username, User body) throws ApiException, ProcessingException;
void updateUser(@PathParam("username") String username, User body) throws ApiException, ProcessingException;
}
samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/api/PetApi.java
+ 8
- 8
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -52,7 +52,7 @@ public interface PetApi {
@Consumes({ "application/json", "application/xml" })
@Produces({ "application/xml", "application/json" })
public Pet addPet(Pet pet) throws ApiException, ProcessingException;
Pet addPet(Pet pet) throws ApiException, ProcessingException;
/**
* Deletes a pet
@@ -62,7 +62,7 @@ public interface PetApi {
*/
@DELETE
@Path("/{petId}")
public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey) throws ApiException, ProcessingException;
void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey) throws ApiException, ProcessingException;
/**
* Finds Pets by status
@@ -73,7 +73,7 @@ public interface PetApi {
@GET
@Path("/findByStatus")
@Produces({ "application/xml", "application/json" })
public List<Pet> findPetsByStatus(@QueryParam("status") List<String> status) throws ApiException, ProcessingException;
List<Pet> findPetsByStatus(@QueryParam("status") List<String> status) throws ApiException, ProcessingException;
/**
* Finds Pets by tags
@@ -86,7 +86,7 @@ public interface PetApi {
@GET
@Path("/findByTags")
@Produces({ "application/xml", "application/json" })
public List<Pet> findPetsByTags(@QueryParam("tags") List<String> tags) throws ApiException, ProcessingException;
List<Pet> findPetsByTags(@QueryParam("tags") List<String> tags) throws ApiException, ProcessingException;
/**
* Find pet by ID
@@ -97,7 +97,7 @@ public interface PetApi {
@GET
@Path("/{petId}")
@Produces({ "application/xml", "application/json" })
public Pet getPetById(@PathParam("petId") Long petId) throws ApiException, ProcessingException;
Pet getPetById(@PathParam("petId") Long petId) throws ApiException, ProcessingException;
/**
* Update an existing pet
@@ -109,7 +109,7 @@ public interface PetApi {
@Consumes({ "application/json", "application/xml" })
@Produces({ "application/xml", "application/json" })
public Pet updatePet(Pet pet) throws ApiException, ProcessingException;
Pet updatePet(Pet pet) throws ApiException, ProcessingException;
/**
* Updates a pet in the store with form data
@@ -120,7 +120,7 @@ public interface PetApi {
@POST
@Path("/{petId}")
@Consumes({ "application/x-www-form-urlencoded" })
public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status) throws ApiException, ProcessingException;
void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status) throws ApiException, ProcessingException;
/**
* uploads an image
@@ -132,5 +132,5 @@ public interface PetApi {
@Path("/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment _fileDetail) throws ApiException, ProcessingException;
ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment _fileDetail) throws ApiException, ProcessingException;
}
samples/client/petstore/java/microprofile-rest-client-3.0/src/main/java/org/openapitools/client/api/StoreApi.java
+ 4
- 4
  • View file @ 46623099

  • Edit in single-file editor

  • Open in Web IDE


@@ -48,7 +48,7 @@ public interface StoreApi {
*/
@DELETE
@Path("/order/{orderId}")
public void deleteOrder(@PathParam("orderId") String orderId) throws ApiException, ProcessingException;
void deleteOrder(@PathParam("orderId") String orderId) throws ApiException, ProcessingException;
/**
* Returns pet inventories by status
@@ -59,7 +59,7 @@ public interface StoreApi {
@GET
@Path("/inventory")
@Produces({ "application/json" })
public Map<String, Integer> getInventory() throws ApiException, ProcessingException;
Map<String, Integer> getInventory() throws ApiException, ProcessingException;
/**
* Find purchase order by ID
@@ -70,7 +70,7 @@ public interface StoreApi {
@GET
@Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" })
public Order getOrderById(@PathParam("orderId") Long orderId) throws ApiException, ProcessingException;
Order getOrderById(@PathParam("orderId") Long orderId) throws ApiException, ProcessingException;
/**
* Place an order for a pet
@@ -82,5 +82,5 @@ public interface StoreApi {
@Path("/order")
@Consumes({ "application/json" })
@Produces({ "application/xml", "application/json" })
public Order placeOrder(Order order) throws ApiException, ProcessingException;
Order placeOrder(Order order) throws ApiException, ProcessingException;
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
2
Client: Java Enhancement: Feature
2
Client: Java Enhancement: Feature
    Assign labels
  • Manage project labels

Milestone
6.4.0
6.4.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference: OpenAPITools/openapi-generator!11554
Source branch: github/fork/pravussum/java-microprofile-improvements

Menu

Explore Projects Groups Snippets