Allow specification of configkey for microprofile clients (#10693)

This commit is contained in:
Maximilian Zellhofer 2021-10-27 08:28:17 +02:00 committed by GitHub
parent ae39d782e0
commit 6bbafdfa30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 4 deletions

View File

@ -5,3 +5,4 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/Java
additionalProperties:
artifactId: microprofile-rest-client
configKey: petstore

View File

@ -56,6 +56,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
public static final String USE_PLAY_WS = "usePlayWS";
public static final String PLAY_VERSION = "playVersion";
public static final String ASYNC_NATIVE = "asyncNative";
public static final String CONFIGKEY = "configKey";
public static final String PARCELABLE_MODEL = "parcelableModel";
public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException";
public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode";
@ -102,6 +103,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
protected boolean usePlayWS = false;
protected String playVersion = PLAY_26;
protected String microprofileFramework = MICROPROFILE_DEFAULT;
protected String configKey = null;
protected boolean asyncNative = false;
protected boolean parcelableModel = false;
@ -281,6 +283,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
}
additionalProperties.put(MICROPROFILE_FRAMEWORK, microprofileFramework);
if (additionalProperties.containsKey(CONFIGKEY)) {
this.setConfigKey(additionalProperties.get(CONFIGKEY).toString());
}
if (additionalProperties.containsKey(ASYNC_NATIVE)) {
this.setAsyncNative(convertPropertyToBooleanAndWriteBack(ASYNC_NATIVE));
}
@ -964,6 +970,10 @@ public class JavaClientCodegen extends AbstractJavaCodegen
this.microprofileFramework = microprofileFramework;
}
public void setConfigKey(String configKey) {
this.configKey = configKey;
}
public void setParcelableModel(boolean parcelableModel) {
this.parcelableModel = parcelableModel;
}

View File

@ -30,7 +30,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
*/
{{/appName}}
@RegisterRestClient
@RegisterRestClient{{#configKey}}(configKey="{{configKey}}"){{/configKey}}
@RegisterProvider(ApiExceptionMapper.class)
@Path("{{#useAnnotatedBasePath}}{{contextPath}}{{/useAnnotatedBasePath}}{{commonPath}}")
public interface {{classname}} {

View File

@ -36,7 +36,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
*
*/
@RegisterRestClient
@RegisterRestClient(configKey="petstore")
@RegisterProvider(ApiExceptionMapper.class)
@Path("/pet")
public interface PetApi {

View File

@ -34,7 +34,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
*
*/
@RegisterRestClient
@RegisterRestClient(configKey="petstore")
@RegisterProvider(ApiExceptionMapper.class)
@Path("/store")
public interface StoreApi {

View File

@ -34,7 +34,7 @@ import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
*
*/
@RegisterRestClient
@RegisterRestClient(configKey="petstore")
@RegisterProvider(ApiExceptionMapper.class)
@Path("/user")
public interface UserApi {