forked from loafle/openapi-generator-original
Add lowercase lamda (#3501)
* Add lowercase lamda #3381 * Add lowercase prefix for spring #3381 * Add lamda prefix * Add lamda lower case to @Value * Add properties for braces #3381 * Add property for braces * Start CI * Revert
This commit is contained in:
parent
d45e306480
commit
ba63aa55a5
@ -69,6 +69,9 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
public static final String RETURN_SUCCESS_CODE = "returnSuccessCode";
|
public static final String RETURN_SUCCESS_CODE = "returnSuccessCode";
|
||||||
public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
|
public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
|
||||||
|
|
||||||
|
public static final String OPEN_BRACE = "{";
|
||||||
|
public static final String CLOSE_BRACE = "}";
|
||||||
|
|
||||||
protected String title = "OpenAPI Spring";
|
protected String title = "OpenAPI Spring";
|
||||||
protected String configPackage = "org.openapitools.configuration";
|
protected String configPackage = "org.openapitools.configuration";
|
||||||
protected String basePackage = "org.openapitools";
|
protected String basePackage = "org.openapitools";
|
||||||
@ -103,7 +106,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
invokerPackage = "org.openapitools.api";
|
invokerPackage = "org.openapitools.api";
|
||||||
artifactId = "openapi-spring";
|
artifactId = "openapi-spring";
|
||||||
|
|
||||||
// clioOptions default redifinition need to be updated
|
// clioOptions default redefinition need to be updated
|
||||||
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
|
updateOption(CodegenConstants.INVOKER_PACKAGE, this.getInvokerPackage());
|
||||||
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
|
updateOption(CodegenConstants.ARTIFACT_ID, this.getArtifactId());
|
||||||
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||||
@ -113,6 +116,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
|||||||
|
|
||||||
// spring uses the jackson lib
|
// spring uses the jackson lib
|
||||||
additionalProperties.put("jackson", "true");
|
additionalProperties.put("jackson", "true");
|
||||||
|
additionalProperties.put("openbrace", OPEN_BRACE);
|
||||||
|
additionalProperties.put("closebrace", CLOSE_BRACE);
|
||||||
|
|
||||||
cliOptions.add(new CliOption(TITLE, "server title name or client service name").defaultValue(title));
|
cliOptions.add(new CliOption(TITLE, "server title name or client service name").defaultValue(title));
|
||||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code").defaultValue(this.getConfigPackage()));
|
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code").defaultValue(this.getConfigPackage()));
|
||||||
|
@ -24,25 +24,25 @@ public class ClientConfiguration {
|
|||||||
|
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
{{#isBasic}}
|
{{#isBasic}}
|
||||||
{{=<% %>=}}@Value("${<%title%>.security.<%name%>.username:}")<%={{ }}=%>
|
@Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username:{{closebrace}}")
|
||||||
private String {{{name}}}Username;
|
private String {{{name}}}Username;
|
||||||
|
|
||||||
{{=<% %>=}}@Value("${<%title%>.security.<%name%>.password:}")<%={{ }}=%>
|
@Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.password:{{closebrace}}")
|
||||||
private String {{{name}}}Password;
|
private String {{{name}}}Password;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.username")
|
@ConditionalOnProperty(name = "{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username")
|
||||||
public BasicAuthRequestInterceptor {{{name}}}RequestInterceptor() {
|
public BasicAuthRequestInterceptor {{{name}}}RequestInterceptor() {
|
||||||
return new BasicAuthRequestInterceptor(this.{{{name}}}Username, this.{{{name}}}Password);
|
return new BasicAuthRequestInterceptor(this.{{{name}}}Username, this.{{{name}}}Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
{{/isBasic}}
|
{{/isBasic}}
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
{{=<% %>=}}@Value("${<%title%>.security.<%name%>.key:}")<%={{ }}=%>
|
@Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key:{{closebrace}}")
|
||||||
private String {{{name}}}Key;
|
private String {{{name}}}Key;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.key")
|
@ConditionalOnProperty(name = "{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key")
|
||||||
public ApiKeyRequestInterceptor {{{name}}}RequestInterceptor() {
|
public ApiKeyRequestInterceptor {{{name}}}RequestInterceptor() {
|
||||||
return new ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{{name}}}Key);
|
return new ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{{name}}}Key);
|
||||||
}
|
}
|
||||||
@ -50,15 +50,15 @@ public class ClientConfiguration {
|
|||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() {
|
public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() {
|
||||||
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails());
|
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
{{#isCode}}
|
{{#isCode}}
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
public AuthorizationCodeResourceDetails {{{name}}}ResourceDetails() {
|
public AuthorizationCodeResourceDetails {{{name}}}ResourceDetails() {
|
||||||
AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
|
AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
|
||||||
details.setAccessTokenUri("{{{tokenUrl}}}");
|
details.setAccessTokenUri("{{{tokenUrl}}}");
|
||||||
@ -69,8 +69,8 @@ public class ClientConfiguration {
|
|||||||
{{/isCode}}
|
{{/isCode}}
|
||||||
{{#isPassword}}
|
{{#isPassword}}
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
public ResourceOwnerPasswordResourceDetails {{{name}}}ResourceDetails() {
|
public ResourceOwnerPasswordResourceDetails {{{name}}}ResourceDetails() {
|
||||||
ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
|
ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
|
||||||
details.setAccessTokenUri("{{{tokenUrl}}}");
|
details.setAccessTokenUri("{{{tokenUrl}}}");
|
||||||
@ -80,8 +80,8 @@ public class ClientConfiguration {
|
|||||||
{{/isPassword}}
|
{{/isPassword}}
|
||||||
{{#isApplication}}
|
{{#isApplication}}
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
public ClientCredentialsResourceDetails {{{name}}}ResourceDetails() {
|
public ClientCredentialsResourceDetails {{{name}}}ResourceDetails() {
|
||||||
ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
|
ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
|
||||||
details.setAccessTokenUri("{{{tokenUrl}}}");
|
details.setAccessTokenUri("{{{tokenUrl}}}");
|
||||||
@ -91,8 +91,8 @@ public class ClientConfiguration {
|
|||||||
{{/isApplication}}
|
{{/isApplication}}
|
||||||
{{#isImplicit}}
|
{{#isImplicit}}
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||||
public ImplicitResourceDetails {{{name}}}ResourceDetails() {
|
public ImplicitResourceDetails {{{name}}}ResourceDetails() {
|
||||||
ImplicitResourceDetails details = new ImplicitResourceDetails();
|
ImplicitResourceDetails details = new ImplicitResourceDetails();
|
||||||
details.setUserAuthorizationUri("{{{authorizationUrl}}}");
|
details.setUserAuthorizationUri("{{{authorizationUrl}}}");
|
||||||
|
@ -22,24 +22,24 @@ import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
|
|||||||
@EnableConfigurationProperties
|
@EnableConfigurationProperties
|
||||||
public class ClientConfiguration {
|
public class ClientConfiguration {
|
||||||
|
|
||||||
@Value("${openAPIPetstore.security.apiKey.key:}")
|
@Value("${openapipetstore.security.apiKey.key:}")
|
||||||
private String apiKeyKey;
|
private String apiKeyKey;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(name = "openAPIPetstore.security.apiKey.key")
|
@ConditionalOnProperty(name = "openapipetstore.security.apiKey.key")
|
||||||
public ApiKeyRequestInterceptor apiKeyRequestInterceptor() {
|
public ApiKeyRequestInterceptor apiKeyRequestInterceptor() {
|
||||||
return new ApiKeyRequestInterceptor("header", "api_key", this.apiKeyKey);
|
return new ApiKeyRequestInterceptor("header", "api_key", this.apiKeyKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("openAPIPetstore.security.petstoreAuth.client-id")
|
@ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id")
|
||||||
public OAuth2FeignRequestInterceptor petstoreAuthRequestInterceptor() {
|
public OAuth2FeignRequestInterceptor petstoreAuthRequestInterceptor() {
|
||||||
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), petstoreAuthResourceDetails());
|
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), petstoreAuthResourceDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty("openAPIPetstore.security.petstoreAuth.client-id")
|
@ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id")
|
||||||
@ConfigurationProperties("openAPIPetstore.security.petstoreAuth")
|
@ConfigurationProperties("openapipetstore.security.petstoreAuth")
|
||||||
public ImplicitResourceDetails petstoreAuthResourceDetails() {
|
public ImplicitResourceDetails petstoreAuthResourceDetails() {
|
||||||
ImplicitResourceDetails details = new ImplicitResourceDetails();
|
ImplicitResourceDetails details = new ImplicitResourceDetails();
|
||||||
details.setUserAuthorizationUri("http://petstore.swagger.io/api/oauth/dialog");
|
details.setUserAuthorizationUri("http://petstore.swagger.io/api/oauth/dialog");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user