mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
Allow selection of MP REST API version for MicroProfile REST client g… (#12043)
* Allow selection of MP REST API version for MicroProfile REST client generation * fix typo in pom.xml * fix typo in pom.xml, update samples * add exception when incorrect MP Rest Client version is chosen
This commit is contained in:
parent
67b659f47e
commit
783f810a05
@ -56,6 +56,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|licenseName|The name of the license| |Unlicense|
|
|licenseName|The name of the license| |Unlicense|
|
||||||
|licenseUrl|The URL of the license| |http://unlicense.org|
|
|licenseUrl|The URL of the license| |http://unlicense.org|
|
||||||
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
|
|microprofileFramework|Framework for microprofile. Possible values "kumuluzee"| |null|
|
||||||
|
|microprofileRestClientVersion|Version of MicroProfile Rest Client API.| |null|
|
||||||
|modelPackage|package for generated models| |org.openapitools.client.model|
|
|modelPackage|package for generated models| |org.openapitools.client.model|
|
||||||
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
|
|openApiNullable|Enable OpenAPI Jackson Nullable library| |true|
|
||||||
|parcelableModel|Whether to generate models for Android that implement Parcelable with the okhttp-gson library.| |false|
|
|parcelableModel|Whether to generate models for Android that implement Parcelable with the okhttp-gson library.| |false|
|
||||||
|
@ -89,6 +89,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
public static final String VERTX = "vertx";
|
public static final String VERTX = "vertx";
|
||||||
public static final String MICROPROFILE = "microprofile";
|
public static final String MICROPROFILE = "microprofile";
|
||||||
public static final String APACHE = "apache-httpclient";
|
public static final String APACHE = "apache-httpclient";
|
||||||
|
public static final String MICROPROFILE_REST_CLIENT_VERSION = "microprofileRestClientVersion";
|
||||||
|
public static final String MICROPROFILE_REST_CLIENT_DEFAULT_VERSION = "2.0";
|
||||||
|
public static final String MICROPROFILE_REST_CLIENT_DEFAULT_ROOT_PACKAGE = "javax";
|
||||||
|
|
||||||
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
public static final String SERIALIZATION_LIBRARY_GSON = "gson";
|
||||||
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
public static final String SERIALIZATION_LIBRARY_JACKSON = "jackson";
|
||||||
@ -122,6 +125,18 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
protected String authFolder;
|
protected String authFolder;
|
||||||
protected String serializationLibrary = null;
|
protected String serializationLibrary = null;
|
||||||
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
|
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
|
||||||
|
protected String rootJavaEEPackage;
|
||||||
|
protected Map<String, MpRestClientVersion> mpRestClientVersions = new HashMap<>();
|
||||||
|
|
||||||
|
private static class MpRestClientVersion {
|
||||||
|
public final String rootPackage;
|
||||||
|
public final String pomTemplate;
|
||||||
|
|
||||||
|
public MpRestClientVersion(String rootPackage, String pomTemplate) {
|
||||||
|
this.rootPackage = rootPackage;
|
||||||
|
this.pomTemplate = pomTemplate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public JavaClientCodegen() {
|
public JavaClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -138,6 +153,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
artifactId = "openapi-java-client";
|
artifactId = "openapi-java-client";
|
||||||
apiPackage = "org.openapitools.client.api";
|
apiPackage = "org.openapitools.client.api";
|
||||||
modelPackage = "org.openapitools.client.model";
|
modelPackage = "org.openapitools.client.model";
|
||||||
|
rootJavaEEPackage = MICROPROFILE_REST_CLIENT_DEFAULT_ROOT_PACKAGE;
|
||||||
|
|
||||||
// cliOptions default redefinition need to be updated
|
// cliOptions default redefinition need to be updated
|
||||||
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
|
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
|
||||||
@ -166,6 +182,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
cliOptions.add(CliOption.newString(ERROR_OBJECT_TYPE, "Error Object type. (This option is for okhttp-gson-next-gen only)"));
|
cliOptions.add(CliOption.newString(ERROR_OBJECT_TYPE, "Error Object type. (This option is for okhttp-gson-next-gen only)"));
|
||||||
cliOptions.add(CliOption.newString(CONFIG_KEY, "Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option."));
|
cliOptions.add(CliOption.newString(CONFIG_KEY, "Config key in @RegisterRestClient. Default to none. Only `microprofile` supports this option."));
|
||||||
cliOptions.add(CliOption.newBoolean(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC + " Only jersey2, jersey3, native, okhttp-gson support this option."));
|
cliOptions.add(CliOption.newBoolean(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC + " Only jersey2, jersey3, native, okhttp-gson support this option."));
|
||||||
|
cliOptions.add(CliOption.newString(MICROPROFILE_REST_CLIENT_VERSION, "Version of MicroProfile Rest Client API."));
|
||||||
|
|
||||||
supportedLibraries.put(JERSEY1, "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.");
|
supportedLibraries.put(JERSEY1, "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.");
|
||||||
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
|
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
|
||||||
@ -203,6 +220,13 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
// and the discriminator mapping schemas in the OAS document.
|
// and the discriminator mapping schemas in the OAS document.
|
||||||
this.setLegacyDiscriminatorBehavior(false);
|
this.setLegacyDiscriminatorBehavior(false);
|
||||||
|
|
||||||
|
initMpRestClientVersionToRootPackage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMpRestClientVersionToRootPackage() {
|
||||||
|
mpRestClientVersions.put("1.4.1", new MpRestClientVersion("javax", "pom.mustache"));
|
||||||
|
mpRestClientVersions.put("2.0", new MpRestClientVersion("javax", "pom.mustache"));
|
||||||
|
mpRestClientVersions.put("3.0", new MpRestClientVersion("jakarta", "pom_3.0.mustache"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -280,6 +304,28 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
}
|
}
|
||||||
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);
|
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);
|
||||||
|
|
||||||
|
if (!additionalProperties.containsKey(MICROPROFILE_REST_CLIENT_VERSION)) {
|
||||||
|
additionalProperties.put(MICROPROFILE_REST_CLIENT_VERSION, MICROPROFILE_REST_CLIENT_DEFAULT_VERSION);
|
||||||
|
} else {
|
||||||
|
String mpRestClientVersion = (String) additionalProperties.get(MICROPROFILE_REST_CLIENT_VERSION);
|
||||||
|
if (!mpRestClientVersions.containsKey(mpRestClientVersion)){
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format(Locale.ROOT,
|
||||||
|
"Version %s of MicroProfile Rest Client is not supported or incorrect. Supported versions are %s",
|
||||||
|
mpRestClientVersion,
|
||||||
|
String.join(", ", mpRestClientVersions.keySet())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!additionalProperties.containsKey("rootJavaEEPackage")) {
|
||||||
|
String mpRestClientVersion = (String) additionalProperties.get(MICROPROFILE_REST_CLIENT_VERSION);
|
||||||
|
if (mpRestClientVersions.containsKey(mpRestClientVersion)) {
|
||||||
|
rootJavaEEPackage = mpRestClientVersions.get(mpRestClientVersion).rootPackage;
|
||||||
|
}
|
||||||
|
additionalProperties.put("rootJavaEEPackage", rootJavaEEPackage);
|
||||||
|
}
|
||||||
|
|
||||||
if (additionalProperties.containsKey(CONFIG_KEY)) {
|
if (additionalProperties.containsKey(CONFIG_KEY)) {
|
||||||
this.setConfigKey(additionalProperties.get(CONFIG_KEY).toString());
|
this.setConfigKey(additionalProperties.get(CONFIG_KEY).toString());
|
||||||
}
|
}
|
||||||
@ -542,7 +588,9 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
|||||||
} else if (MICROPROFILE.equals(getLibrary())) {
|
} else if (MICROPROFILE.equals(getLibrary())) {
|
||||||
supportingFiles.clear(); // Don't need extra files provided by Java Codegen
|
supportingFiles.clear(); // Don't need extra files provided by Java Codegen
|
||||||
String apiExceptionFolder = (sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
|
String apiExceptionFolder = (sourceFolder + File.separator + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar);
|
||||||
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
|
String mpRestClientVersion = (String) additionalProperties.get(MICROPROFILE_REST_CLIENT_VERSION);
|
||||||
|
String pomTemplate = mpRestClientVersions.get(mpRestClientVersion).pomTemplate;
|
||||||
|
supportingFiles.add(new SupportingFile(pomTemplate, "", "pom.xml"));
|
||||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||||
supportingFiles.add(new SupportingFile("api_exception.mustache", apiExceptionFolder, "ApiException.java"));
|
supportingFiles.add(new SupportingFile("api_exception.mustache", apiExceptionFolder, "ApiException.java"));
|
||||||
supportingFiles.add(new SupportingFile("api_exception_mapper.mustache", apiExceptionFolder, "ApiExceptionMapper.java"));
|
supportingFiles.add(new SupportingFile("api_exception_mapper.mustache", apiExceptionFolder, "ApiExceptionMapper.java"));
|
||||||
|
@ -9,9 +9,9 @@ import java.io.OutputStream;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.ws.rs.*;
|
import {{rootJavaEEPackage}}.ws.rs.*;
|
||||||
import javax.ws.rs.core.Response;
|
import {{rootJavaEEPackage}}.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.MediaType;
|
import {{rootJavaEEPackage}}.ws.rs.core.MediaType;
|
||||||
{{^disableMultipart}}
|
{{^disableMultipart}}
|
||||||
import org.apache.cxf.jaxrs.ext.multipart.*;
|
import org.apache.cxf.jaxrs.ext.multipart.*;
|
||||||
{{/disableMultipart}}
|
{{/disableMultipart}}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import {{rootJavaEEPackage}}.ws.rs.core.Response;
|
||||||
|
|
||||||
public class ApiException extends Exception {
|
public class ApiException extends Exception {
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
package {{apiPackage}};
|
package {{apiPackage}};
|
||||||
|
|
||||||
import javax.ws.rs.core.MultivaluedMap;
|
import {{rootJavaEEPackage}}.ws.rs.core.MultivaluedMap;
|
||||||
import javax.ws.rs.core.Response;
|
import {{rootJavaEEPackage}}.ws.rs.core.Response;
|
||||||
import javax.ws.rs.ext.Provider;
|
import {{rootJavaEEPackage}}.ws.rs.ext.Provider;
|
||||||
import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
|
import org.eclipse.microprofile.rest.client.ext.ResponseExceptionMapper;
|
||||||
|
|
||||||
@Provider
|
@Provider
|
||||||
|
@ -1 +1 @@
|
|||||||
@javax.annotation.Generated(value = "{{generatorClass}}"{{^hideGenerationTimestamp}}, date = "{{generatedDate}}"{{/hideGenerationTimestamp}})
|
@{{rootJavaEEPackage}}.annotation.Generated(value = "{{generatorClass}}"{{^hideGenerationTimestamp}}, date = "{{generatedDate}}"{{/hideGenerationTimestamp}})
|
@ -7,8 +7,8 @@ package {{package}};
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
{{/serializableModel}}
|
{{/serializableModel}}
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
import javax.validation.constraints.*;
|
import {{rootJavaEEPackage}}.validation.constraints.*;
|
||||||
import javax.validation.Valid;
|
import {{rootJavaEEPackage}}.validation.Valid;
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
|
|
||||||
{{#models}}
|
{{#models}}
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
{{#withXml}}
|
{{#withXml}}
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import {{rootJavaEEPackage}}.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import {{rootJavaEEPackage}}.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import {{rootJavaEEPackage}}.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import {{rootJavaEEPackage}}.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import {{rootJavaEEPackage}}.xml.bind.annotation.XmlType;
|
||||||
import javax.xml.bind.annotation.XmlEnum;
|
import {{rootJavaEEPackage}}.xml.bind.annotation.XmlEnum;
|
||||||
import javax.xml.bind.annotation.XmlEnumValue;
|
import {{rootJavaEEPackage}}.xml.bind.annotation.XmlEnumValue;
|
||||||
{{/withXml}}
|
{{/withXml}}
|
||||||
{{^withXml}}
|
{{^withXml}}
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import javax.json.bind.annotation.JsonbTypeDeserializer;
|
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbTypeDeserializer;
|
||||||
import javax.json.bind.annotation.JsonbTypeSerializer;
|
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbTypeSerializer;
|
||||||
import javax.json.bind.serializer.DeserializationContext;
|
import {{rootJavaEEPackage}}.json.bind.serializer.DeserializationContext;
|
||||||
import javax.json.bind.serializer.JsonbDeserializer;
|
import {{rootJavaEEPackage}}.json.bind.serializer.JsonbDeserializer;
|
||||||
import javax.json.bind.serializer.JsonbSerializer;
|
import {{rootJavaEEPackage}}.json.bind.serializer.JsonbSerializer;
|
||||||
import javax.json.bind.serializer.SerializationContext;
|
import {{rootJavaEEPackage}}.json.bind.serializer.SerializationContext;
|
||||||
import javax.json.stream.JsonGenerator;
|
import {{rootJavaEEPackage}}.json.stream.JsonGenerator;
|
||||||
import javax.json.stream.JsonParser;
|
import {{rootJavaEEPackage}}.json.stream.JsonParser;
|
||||||
import javax.json.bind.annotation.JsonbProperty;
|
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbProperty;
|
||||||
{{#vendorExtensions.x-has-readonly-properties}}
|
{{#vendorExtensions.x-has-readonly-properties}}
|
||||||
import javax.json.bind.annotation.JsonbCreator;
|
import {{rootJavaEEPackage}}.json.bind.annotation.JsonbCreator;
|
||||||
{{/vendorExtensions.x-has-readonly-properties}}
|
{{/vendorExtensions.x-has-readonly-properties}}
|
||||||
{{/withXml}}
|
{{/withXml}}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jboss.jandex</groupId>
|
<groupId>org.jboss.jandex</groupId>
|
||||||
<artifactId>jandex-maven-plugin</artifactId>
|
<artifactId>jandex-maven-plugin</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>${jandex.maven.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>make-index</id>
|
<id>make-index</id>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<version>2.6</version>
|
<version>${maven.failsafe.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -39,7 +39,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
<version>1.9.1</version>
|
<version>${build.helper.maven.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>add-source</id>
|
<id>add-source</id>
|
||||||
@ -61,7 +61,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>${junit-version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
@ -69,7 +69,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.validation</groupId>
|
<groupId>jakarta.validation</groupId>
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
<version>${beanvalidation-version}</version>
|
<version>${beanvalidation.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
@ -77,83 +77,83 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.microprofile.rest.client</groupId>
|
<groupId>org.eclipse.microprofile.rest.client</groupId>
|
||||||
<artifactId>microprofile-rest-client-api</artifactId>
|
<artifactId>microprofile-rest-client-api</artifactId>
|
||||||
<version>1.4.1</version>
|
<version>${microprofile.rest.client.api.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JAX-RS -->
|
<!-- JAX-RS -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.ws.rs</groupId>
|
<groupId>jakarta.ws.rs</groupId>
|
||||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||||
<version>${jakarta.ws.rs-version}</version>
|
<version>${jakarta.ws.rs.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.smallrye</groupId>
|
<groupId>io.smallrye</groupId>
|
||||||
<artifactId>smallrye-rest-client</artifactId>
|
<artifactId>smallrye-rest-client</artifactId>
|
||||||
<version>1.2.1</version>
|
<version>${smallrye.rest.client.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.smallrye</groupId>
|
<groupId>io.smallrye</groupId>
|
||||||
<artifactId>smallrye-config</artifactId>
|
<artifactId>smallrye-config</artifactId>
|
||||||
<version>1.3.5</version>
|
<version>${smallrye.config.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{^disableMultipart}}
|
{{^disableMultipart}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cxf</groupId>
|
<groupId>org.apache.cxf</groupId>
|
||||||
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
||||||
<version>3.2.6</version>
|
<version>${cxf.rt.rs.extension.providers.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/disableMultipart}}
|
{{/disableMultipart}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.json.bind</groupId>
|
<groupId>jakarta.json.bind</groupId>
|
||||||
<artifactId>jakarta.json.bind-api</artifactId>
|
<artifactId>jakarta.json.bind-api</artifactId>
|
||||||
<version>${jakarta.json.bind-version}</version>
|
<version>${jakarta.json.bind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.json</groupId>
|
<groupId>jakarta.json</groupId>
|
||||||
<artifactId>jakarta.json-api</artifactId>
|
<artifactId>jakarta.json-api</artifactId>
|
||||||
<version>${jakarta.json-version}</version>
|
<version>${jakarta.json.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.xml.bind</groupId>
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
<version>${jakarta.xml.bind-version}</version>
|
<version>${jakarta.xml.bind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-core</artifactId>
|
<artifactId>jaxb-core</artifactId>
|
||||||
<version>2.2.11</version>
|
<version>${jaxb.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>2.2.11</version>
|
<version>${jaxb.impl.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.activation</groupId>
|
<groupId>jakarta.activation</groupId>
|
||||||
<artifactId>jakarta.activation-api</artifactId>
|
<artifactId>jakarta.activation-api</artifactId>
|
||||||
<version>${jakarta.activation-version}</version>
|
<version>${jakarta.activation.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>${jackson-jaxrs-version}</version>
|
<version>${jackson.jaxrs.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{#useBeanValidationFeature}}
|
{{#useBeanValidationFeature}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-validator</artifactId>
|
<artifactId>hibernate-validator</artifactId>
|
||||||
<version>5.2.2.Final</version>
|
<version>${hibernate.validator.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
{{/useBeanValidationFeature}}
|
{{/useBeanValidationFeature}}
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.annotation</groupId>
|
<groupId>jakarta.annotation</groupId>
|
||||||
<artifactId>jakarta.annotation-api</artifactId>
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
<version>${jakarta-annotation-version}</version>
|
<version>${jakarta.annotation.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -170,21 +170,31 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<swagger-core-version>1.5.18</swagger-core-version>
|
<swagger.core.version>1.5.18</swagger.core.version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty.version>9.2.9.v20150224</jetty.version>
|
||||||
<junit-version>4.13.2</junit-version>
|
<junit.version>4.13.2</junit.version>
|
||||||
<logback-version>1.2.10</logback-version>
|
<logback.version>1.2.10</logback.version>
|
||||||
{{#useBeanValidation}}
|
{{#useBeanValidation}}
|
||||||
<beanvalidation-version>2.0.2</beanvalidation-version>
|
<beanvalidation.version>2.0.2</beanvalidation.version>
|
||||||
{{/useBeanValidation}}
|
{{/useBeanValidation}}
|
||||||
<cxf-version>3.2.7</cxf-version>
|
<cxf.version>3.2.7</cxf.version>
|
||||||
<jackson-jaxrs-version>2.9.7</jackson-jaxrs-version>
|
<jackson.jaxrs.version>2.9.7</jackson.jaxrs.version>
|
||||||
<jakarta.activation-version>1.2.2</jakarta.activation-version>
|
<jakarta.activation.version>1.2.2</jakarta.activation.version>
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta.annotation.version>1.3.5</jakarta.annotation.version>
|
||||||
<jakarta.json.bind-version>1.0.2</jakarta.json.bind-version>
|
<jakarta.json.bind.version>1.0.2</jakarta.json.bind.version>
|
||||||
<jakarta.json-version>1.1.6</jakarta.json-version>
|
<jakarta.json.version>1.1.6</jakarta.json.version>
|
||||||
<jakarta.ws.rs-version>2.1.6</jakarta.ws.rs-version>
|
<jakarta.ws.rs.version>2.1.6</jakarta.ws.rs.version>
|
||||||
<jakarta.xml.bind-version>2.3.3</jakarta.xml.bind-version>
|
<jakarta.xml.bind.version>2.3.3</jakarta.xml.bind.version>
|
||||||
|
<microprofile.rest.client.api.version>{{microprofileRestClientVersion}}</microprofile.rest.client.api.version>
|
||||||
|
<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>
|
||||||
|
<smallrye.config.version>1.3.5</smallrye.config.version>
|
||||||
|
<cxf.rt.rs.extension.providers.version>3.2.6</cxf.rt.rs.extension.providers.version>
|
||||||
|
<jaxb.core.version>2.2.11</jaxb.core.version>
|
||||||
|
<jaxb.impl.version>2.2.11</jaxb.impl.version>
|
||||||
|
<hibernate.validator.version>5.2.2.Final</hibernate.validator.version>
|
||||||
|
<jandex.maven.plugin.version>1.1.0</jandex.maven.plugin.version>
|
||||||
|
<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>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
200
modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom_3.0.mustache
vendored
Normal file
200
modules/openapi-generator/src/main/resources/Java/libraries/microprofile/pom_3.0.mustache
vendored
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>{{groupId}}</groupId>
|
||||||
|
<artifactId>{{artifactId}}</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>{{artifactId}}</name>
|
||||||
|
{{#appDescription}}
|
||||||
|
<description>{{.}}</description>
|
||||||
|
{{/appDescription}}
|
||||||
|
<version>{{artifactVersion}}</version>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jboss.jandex</groupId>
|
||||||
|
<artifactId>jandex-maven-plugin</artifactId>
|
||||||
|
<version>${jandex.maven.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-index</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jandex</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>${maven.failsafe.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
|
<version>${build.helper.maven.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>add-source</id>
|
||||||
|
<phase>generate-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>add-source</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sources>
|
||||||
|
<source>src/gen/java</source>
|
||||||
|
</sources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
<!-- Bean Validation API support -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.validation</groupId>
|
||||||
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
|
<version>${beanvalidation.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
<!-- Eclipse MicroProfile Rest Client -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.microprofile.rest.client</groupId>
|
||||||
|
<artifactId>microprofile-rest-client-api</artifactId>
|
||||||
|
<version>${microprofile.rest.client.api.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JAX-RS -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.ws.rs</groupId>
|
||||||
|
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||||
|
<version>${jakarta.ws.rs.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.ext.microprofile</groupId>
|
||||||
|
<artifactId>jersey-mp-rest-client</artifactId>
|
||||||
|
<version>${jersey.mp.rest.client.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.geronimo.config</groupId>
|
||||||
|
<artifactId>geronimo-config-impl</artifactId>
|
||||||
|
<version>${geronimo.config.impl.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
{{^disableMultipart}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cxf</groupId>
|
||||||
|
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
||||||
|
<version>${cxf.rt.rs.extension.providers.version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/disableMultipart}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.json.bind</groupId>
|
||||||
|
<artifactId>jakarta.json.bind-api</artifactId>
|
||||||
|
<version>${jakarta.json.bind.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.json</groupId>
|
||||||
|
<artifactId>jakarta.json-api</artifactId>
|
||||||
|
<version>${jakarta.json.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
|
<version>${jakarta.xml.bind.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-core</artifactId>
|
||||||
|
<version>${jaxb.core.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-impl</artifactId>
|
||||||
|
<version>${jaxb.impl.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.activation</groupId>
|
||||||
|
<artifactId>jakarta.activation-api</artifactId>
|
||||||
|
<version>${jakarta.activation.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>${jackson.jaxrs.version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{#useBeanValidationFeature}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-validator</artifactId>
|
||||||
|
<version>${hibernate.validator.version}</version>
|
||||||
|
</dependency>
|
||||||
|
{{/useBeanValidationFeature}}
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.annotation</groupId>
|
||||||
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
|
<version>${jakarta.annotation.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>sonatype-snapshots</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<properties>
|
||||||
|
<java.version>11</java.version>
|
||||||
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
|
<swagger.core.version>1.5.18</swagger.core.version>
|
||||||
|
<jetty.version>9.2.9.v20150224</jetty.version>
|
||||||
|
<junit.version>4.13.2</junit.version>
|
||||||
|
<logback.version>1.2.10</logback.version>
|
||||||
|
{{#useBeanValidation}}
|
||||||
|
<beanvalidation.version>3.0.1</beanvalidation.version>
|
||||||
|
{{/useBeanValidation}}
|
||||||
|
<cxf.version>3.2.7</cxf.version>
|
||||||
|
<jackson.jaxrs.version>2.13.2</jackson.jaxrs.version>
|
||||||
|
<jakarta.activation.version>2.1.0</jakarta.activation.version>
|
||||||
|
<jakarta.annotation.version>2.0.0</jakarta.annotation.version>
|
||||||
|
<jakarta.json.bind.version>2.0.0</jakarta.json.bind.version>
|
||||||
|
<jakarta.json.version>2.0.1</jakarta.json.version>
|
||||||
|
<jakarta.ws.rs.version>3.0.0</jakarta.ws.rs.version>
|
||||||
|
<jakarta.xml.bind.version>3.0.1</jakarta.xml.bind.version>
|
||||||
|
<microprofile.rest.client.api.version>{{microprofileRestClientVersion}}</microprofile.rest.client.api.version>
|
||||||
|
<jersey.mp.rest.client.version>3.0.4</jersey.mp.rest.client.version>
|
||||||
|
<geronimo.config.impl.version>1.2.3</geronimo.config.impl.version>
|
||||||
|
<cxf.rt.rs.extension.providers.version>3.5.1</cxf.rt.rs.extension.providers.version>
|
||||||
|
<jaxb.core.version>3.0.2</jaxb.core.version>
|
||||||
|
<jaxb.impl.version>3.0.2</jaxb.impl.version>
|
||||||
|
<hibernate.validator.version>7.0.4.Final</hibernate.validator.version>
|
||||||
|
<jandex.maven.plugin.version>1.1.0</jandex.maven.plugin.version>
|
||||||
|
<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>
|
||||||
|
</properties>
|
||||||
|
</project>
|
@ -20,6 +20,7 @@ package org.openapitools.codegen.java;
|
|||||||
import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles;
|
import static org.openapitools.codegen.TestUtils.validateJavaSourceFiles;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -1389,6 +1390,125 @@ public class JavaClientCodegenTest {
|
|||||||
testExtraAnnotations(JavaClientCodegen.APACHE);
|
testExtraAnnotations(JavaClientCodegen.APACHE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDefaultMicroprofileRestClientVersion() throws Exception {
|
||||||
|
File output = Files.createTempDirectory("test").toFile();
|
||||||
|
|
||||||
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
|
.setGeneratorName("java")
|
||||||
|
.setLibrary(JavaClientCodegen.MICROPROFILE)
|
||||||
|
.setInputSpec("src/test/resources/3_0/petstore.yaml")
|
||||||
|
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||||
|
|
||||||
|
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
List<File> files = generator.opts(clientOptInput).generate();
|
||||||
|
|
||||||
|
TestUtils.ensureContainsFile(files, output, "pom.xml");
|
||||||
|
|
||||||
|
validateJavaSourceFiles(files);
|
||||||
|
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<microprofile.rest.client.api.version>2.0</microprofile.rest.client.api.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<java.version>1.8</java.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/src/main/java/org/openapitools/client/api/PetApi.java"),
|
||||||
|
"import javax.");
|
||||||
|
|
||||||
|
output.deleteOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMicroprofileRestClientVersion_1_4_1() throws Exception {
|
||||||
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
properties.put(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "1.4.1");
|
||||||
|
|
||||||
|
File output = Files.createTempDirectory("test").toFile();
|
||||||
|
|
||||||
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
|
.setAdditionalProperties(properties)
|
||||||
|
.setGeneratorName("java")
|
||||||
|
.setLibrary(JavaClientCodegen.MICROPROFILE)
|
||||||
|
.setInputSpec("src/test/resources/3_0/petstore.yaml")
|
||||||
|
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||||
|
|
||||||
|
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
List<File> files = generator.opts(clientOptInput).generate();
|
||||||
|
|
||||||
|
TestUtils.ensureContainsFile(files, output, "pom.xml");
|
||||||
|
|
||||||
|
validateJavaSourceFiles(files);
|
||||||
|
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<microprofile.rest.client.api.version>1.4.1</microprofile.rest.client.api.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<java.version>1.8</java.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/src/main/java/org/openapitools/client/api/PetApi.java"),
|
||||||
|
"import javax.");
|
||||||
|
|
||||||
|
output.deleteOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Version incorrectVersion of MicroProfile Rest Client is not supported or incorrect. Supported versions are 1.4.1, 2.0, 3.0")
|
||||||
|
public void testMicroprofileRestClientIncorrectVersion() throws Exception {
|
||||||
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
properties.put(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "incorrectVersion");
|
||||||
|
|
||||||
|
File output = Files.createTempDirectory("test").toFile();
|
||||||
|
output.deleteOnExit();
|
||||||
|
|
||||||
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
|
.setAdditionalProperties(properties)
|
||||||
|
.setGeneratorName("java")
|
||||||
|
.setLibrary(JavaClientCodegen.MICROPROFILE)
|
||||||
|
.setInputSpec("src/test/resources/3_0/petstore.yaml")
|
||||||
|
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||||
|
|
||||||
|
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
generator.opts(clientOptInput).generate();
|
||||||
|
fail("Expected an exception that did not occur");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMicroprofileRestClientVersion_3_0() throws Exception {
|
||||||
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
properties.put(JavaClientCodegen.MICROPROFILE_REST_CLIENT_VERSION, "3.0");
|
||||||
|
|
||||||
|
File output = Files.createTempDirectory("test").toFile();
|
||||||
|
|
||||||
|
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||||
|
.setAdditionalProperties(properties)
|
||||||
|
.setGeneratorName("java")
|
||||||
|
.setLibrary(JavaClientCodegen.MICROPROFILE)
|
||||||
|
.setInputSpec("src/test/resources/3_0/petstore.yaml")
|
||||||
|
.setOutputDir(output.getAbsolutePath().replace("\\", "/"));
|
||||||
|
|
||||||
|
final ClientOptInput clientOptInput = configurator.toClientOptInput();
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
List<File> files = generator.opts(clientOptInput).generate();
|
||||||
|
|
||||||
|
TestUtils.ensureContainsFile(files, output, "pom.xml");
|
||||||
|
|
||||||
|
validateJavaSourceFiles(files);
|
||||||
|
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<microprofile.rest.client.api.version>3.0</microprofile.rest.client.api.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<jersey.mp.rest.client.version>3.0.4</jersey.mp.rest.client.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/pom.xml"),
|
||||||
|
"<java.version>11</java.version>");
|
||||||
|
TestUtils.assertFileContains(Paths.get(output + "/src/main/java/org/openapitools/client/api/PetApi.java"),
|
||||||
|
"import jakarta.");
|
||||||
|
|
||||||
|
output.deleteOnExit();
|
||||||
|
}
|
||||||
|
|
||||||
public void testExtraAnnotations(String library) throws IOException {
|
public void testExtraAnnotations(String library) throws IOException {
|
||||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||||
output.deleteOnExit();
|
output.deleteOnExit();
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jboss.jandex</groupId>
|
<groupId>org.jboss.jandex</groupId>
|
||||||
<artifactId>jandex-maven-plugin</artifactId>
|
<artifactId>jandex-maven-plugin</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>${jandex.maven.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>make-index</id>
|
<id>make-index</id>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<version>2.6</version>
|
<version>${maven.failsafe.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
<version>1.9.1</version>
|
<version>${build.helper.maven.plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>add-source</id>
|
<id>add-source</id>
|
||||||
@ -59,81 +59,81 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>${junit-version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Eclipse MicroProfile Rest Client -->
|
<!-- Eclipse MicroProfile Rest Client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.microprofile.rest.client</groupId>
|
<groupId>org.eclipse.microprofile.rest.client</groupId>
|
||||||
<artifactId>microprofile-rest-client-api</artifactId>
|
<artifactId>microprofile-rest-client-api</artifactId>
|
||||||
<version>1.4.1</version>
|
<version>${microprofile.rest.client.api.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JAX-RS -->
|
<!-- JAX-RS -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.ws.rs</groupId>
|
<groupId>jakarta.ws.rs</groupId>
|
||||||
<artifactId>jakarta.ws.rs-api</artifactId>
|
<artifactId>jakarta.ws.rs-api</artifactId>
|
||||||
<version>${jakarta.ws.rs-version}</version>
|
<version>${jakarta.ws.rs.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.smallrye</groupId>
|
<groupId>io.smallrye</groupId>
|
||||||
<artifactId>smallrye-rest-client</artifactId>
|
<artifactId>smallrye-rest-client</artifactId>
|
||||||
<version>1.2.1</version>
|
<version>${smallrye.rest.client.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.smallrye</groupId>
|
<groupId>io.smallrye</groupId>
|
||||||
<artifactId>smallrye-config</artifactId>
|
<artifactId>smallrye-config</artifactId>
|
||||||
<version>1.3.5</version>
|
<version>${smallrye.config.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cxf</groupId>
|
<groupId>org.apache.cxf</groupId>
|
||||||
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
<artifactId>cxf-rt-rs-extension-providers</artifactId>
|
||||||
<version>3.2.6</version>
|
<version>${cxf.rt.rs.extension.providers.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.json.bind</groupId>
|
<groupId>jakarta.json.bind</groupId>
|
||||||
<artifactId>jakarta.json.bind-api</artifactId>
|
<artifactId>jakarta.json.bind-api</artifactId>
|
||||||
<version>${jakarta.json.bind-version}</version>
|
<version>${jakarta.json.bind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.json</groupId>
|
<groupId>jakarta.json</groupId>
|
||||||
<artifactId>jakarta.json-api</artifactId>
|
<artifactId>jakarta.json-api</artifactId>
|
||||||
<version>${jakarta.json-version}</version>
|
<version>${jakarta.json.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.xml.bind</groupId>
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||||
<version>${jakarta.xml.bind-version}</version>
|
<version>${jakarta.xml.bind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-core</artifactId>
|
<artifactId>jaxb-core</artifactId>
|
||||||
<version>2.2.11</version>
|
<version>${jaxb.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sun.xml.bind</groupId>
|
<groupId>com.sun.xml.bind</groupId>
|
||||||
<artifactId>jaxb-impl</artifactId>
|
<artifactId>jaxb-impl</artifactId>
|
||||||
<version>2.2.11</version>
|
<version>${jaxb.impl.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.activation</groupId>
|
<groupId>jakarta.activation</groupId>
|
||||||
<artifactId>jakarta.activation-api</artifactId>
|
<artifactId>jakarta.activation-api</artifactId>
|
||||||
<version>${jakarta.activation-version}</version>
|
<version>${jakarta.activation.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>${jackson-jaxrs-version}</version>
|
<version>${jackson.jaxrs.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.annotation</groupId>
|
<groupId>jakarta.annotation</groupId>
|
||||||
<artifactId>jakarta.annotation-api</artifactId>
|
<artifactId>jakarta.annotation-api</artifactId>
|
||||||
<version>${jakarta-annotation-version}</version>
|
<version>${jakarta.annotation.version}</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
@ -150,18 +150,28 @@
|
|||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<swagger-core-version>1.5.18</swagger-core-version>
|
<swagger.core.version>1.5.18</swagger.core.version>
|
||||||
<jetty-version>9.2.9.v20150224</jetty-version>
|
<jetty.version>9.2.9.v20150224</jetty.version>
|
||||||
<junit-version>4.13.2</junit-version>
|
<junit.version>4.13.2</junit.version>
|
||||||
<logback-version>1.2.10</logback-version>
|
<logback.version>1.2.10</logback.version>
|
||||||
<cxf-version>3.2.7</cxf-version>
|
<cxf.version>3.2.7</cxf.version>
|
||||||
<jackson-jaxrs-version>2.9.7</jackson-jaxrs-version>
|
<jackson.jaxrs.version>2.9.7</jackson.jaxrs.version>
|
||||||
<jakarta.activation-version>1.2.2</jakarta.activation-version>
|
<jakarta.activation.version>1.2.2</jakarta.activation.version>
|
||||||
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
|
<jakarta.annotation.version>1.3.5</jakarta.annotation.version>
|
||||||
<jakarta.json.bind-version>1.0.2</jakarta.json.bind-version>
|
<jakarta.json.bind.version>1.0.2</jakarta.json.bind.version>
|
||||||
<jakarta.json-version>1.1.6</jakarta.json-version>
|
<jakarta.json.version>1.1.6</jakarta.json.version>
|
||||||
<jakarta.ws.rs-version>2.1.6</jakarta.ws.rs-version>
|
<jakarta.ws.rs.version>2.1.6</jakarta.ws.rs.version>
|
||||||
<jakarta.xml.bind-version>2.3.3</jakarta.xml.bind-version>
|
<jakarta.xml.bind.version>2.3.3</jakarta.xml.bind.version>
|
||||||
|
<microprofile.rest.client.api.version>2.0</microprofile.rest.client.api.version>
|
||||||
|
<smallrye.rest.client.version>1.2.1</smallrye.rest.client.version>
|
||||||
|
<smallrye.config.version>1.3.5</smallrye.config.version>
|
||||||
|
<cxf.rt.rs.extension.providers.version>3.2.6</cxf.rt.rs.extension.providers.version>
|
||||||
|
<jaxb.core.version>2.2.11</jaxb.core.version>
|
||||||
|
<jaxb.impl.version>2.2.11</jaxb.impl.version>
|
||||||
|
<hibernate.validator.version>5.2.2.Final</hibernate.validator.version>
|
||||||
|
<jandex.maven.plugin.version>1.1.0</jandex.maven.plugin.version>
|
||||||
|
<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>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user