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 UNHANDLED_EXCEPTION_HANDLING = "unhandledException";
|
||||
|
||||
public static final String OPEN_BRACE = "{";
|
||||
public static final String CLOSE_BRACE = "}";
|
||||
|
||||
protected String title = "OpenAPI Spring";
|
||||
protected String configPackage = "org.openapitools.configuration";
|
||||
protected String basePackage = "org.openapitools";
|
||||
@ -103,7 +106,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
invokerPackage = "org.openapitools.api";
|
||||
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.ARTIFACT_ID, this.getArtifactId());
|
||||
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
|
||||
@ -113,6 +116,8 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
|
||||
// spring uses the jackson lib
|
||||
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(CONFIG_PACKAGE, "configuration package for generated code").defaultValue(this.getConfigPackage()));
|
||||
|
@ -24,25 +24,25 @@ public class ClientConfiguration {
|
||||
|
||||
{{#authMethods}}
|
||||
{{#isBasic}}
|
||||
{{=<% %>=}}@Value("${<%title%>.security.<%name%>.username:}")<%={{ }}=%>
|
||||
@Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username:{{closebrace}}")
|
||||
private String {{{name}}}Username;
|
||||
|
||||
{{=<% %>=}}@Value("${<%title%>.security.<%name%>.password:}")<%={{ }}=%>
|
||||
@Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.password:{{closebrace}}")
|
||||
private String {{{name}}}Password;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.username")
|
||||
@ConditionalOnProperty(name = "{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.username")
|
||||
public BasicAuthRequestInterceptor {{{name}}}RequestInterceptor() {
|
||||
return new BasicAuthRequestInterceptor(this.{{{name}}}Username, this.{{{name}}}Password);
|
||||
}
|
||||
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
{{=<% %>=}}@Value("${<%title%>.security.<%name%>.key:}")<%={{ }}=%>
|
||||
@Value("${{openbrace}}{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key:{{closebrace}}")
|
||||
private String {{{name}}}Key;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "{{{title}}}.security.{{{name}}}.key")
|
||||
@ConditionalOnProperty(name = "{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.key")
|
||||
public ApiKeyRequestInterceptor {{{name}}}RequestInterceptor() {
|
||||
return new ApiKeyRequestInterceptor({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{{keyParamName}}}", this.{{{name}}}Key);
|
||||
}
|
||||
@ -50,15 +50,15 @@ public class ClientConfiguration {
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
@Bean
|
||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||
public OAuth2FeignRequestInterceptor {{{name}}}RequestInterceptor() {
|
||||
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), {{{name}}}ResourceDetails());
|
||||
}
|
||||
|
||||
{{#isCode}}
|
||||
@Bean
|
||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||
public AuthorizationCodeResourceDetails {{{name}}}ResourceDetails() {
|
||||
AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails();
|
||||
details.setAccessTokenUri("{{{tokenUrl}}}");
|
||||
@ -69,8 +69,8 @@ public class ClientConfiguration {
|
||||
{{/isCode}}
|
||||
{{#isPassword}}
|
||||
@Bean
|
||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||
public ResourceOwnerPasswordResourceDetails {{{name}}}ResourceDetails() {
|
||||
ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
|
||||
details.setAccessTokenUri("{{{tokenUrl}}}");
|
||||
@ -80,8 +80,8 @@ public class ClientConfiguration {
|
||||
{{/isPassword}}
|
||||
{{#isApplication}}
|
||||
@Bean
|
||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||
public ClientCredentialsResourceDetails {{{name}}}ResourceDetails() {
|
||||
ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
|
||||
details.setAccessTokenUri("{{{tokenUrl}}}");
|
||||
@ -91,8 +91,8 @@ public class ClientConfiguration {
|
||||
{{/isApplication}}
|
||||
{{#isImplicit}}
|
||||
@Bean
|
||||
@ConditionalOnProperty("{{{title}}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{{title}}}.security.{{{name}}}")
|
||||
@ConditionalOnProperty("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}.client-id")
|
||||
@ConfigurationProperties("{{#lambda.lowercase}}{{{title}}}{{/lambda.lowercase}}.security.{{{name}}}")
|
||||
public ImplicitResourceDetails {{{name}}}ResourceDetails() {
|
||||
ImplicitResourceDetails details = new ImplicitResourceDetails();
|
||||
details.setUserAuthorizationUri("{{{authorizationUrl}}}");
|
||||
|
@ -22,24 +22,24 @@ import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
|
||||
@EnableConfigurationProperties
|
||||
public class ClientConfiguration {
|
||||
|
||||
@Value("${openAPIPetstore.security.apiKey.key:}")
|
||||
@Value("${openapipetstore.security.apiKey.key:}")
|
||||
private String apiKeyKey;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "openAPIPetstore.security.apiKey.key")
|
||||
@ConditionalOnProperty(name = "openapipetstore.security.apiKey.key")
|
||||
public ApiKeyRequestInterceptor apiKeyRequestInterceptor() {
|
||||
return new ApiKeyRequestInterceptor("header", "api_key", this.apiKeyKey);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty("openAPIPetstore.security.petstoreAuth.client-id")
|
||||
@ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id")
|
||||
public OAuth2FeignRequestInterceptor petstoreAuthRequestInterceptor() {
|
||||
return new OAuth2FeignRequestInterceptor(new DefaultOAuth2ClientContext(), petstoreAuthResourceDetails());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty("openAPIPetstore.security.petstoreAuth.client-id")
|
||||
@ConfigurationProperties("openAPIPetstore.security.petstoreAuth")
|
||||
@ConditionalOnProperty("openapipetstore.security.petstoreAuth.client-id")
|
||||
@ConfigurationProperties("openapipetstore.security.petstoreAuth")
|
||||
public ImplicitResourceDetails petstoreAuthResourceDetails() {
|
||||
ImplicitResourceDetails details = new ImplicitResourceDetails();
|
||||
details.setUserAuthorizationUri("http://petstore.swagger.io/api/oauth/dialog");
|
||||
|
Loading…
x
Reference in New Issue
Block a user