forked from loafle/openapi-generator-original
Fix Issue 18224 - Load x-field-extra-annotation in the operation parameter (#18967)
* fix issue 18959 * fix issue 18224 * fix issue 18224 * fix spaces --------- Co-authored-by: Rodrigo Maciel de Almeida <rodrigo.almeida@wefin.com.br>
This commit is contained in:
parent
fb17e5699d
commit
21d3cfe924
@ -80,7 +80,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -120,7 +120,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|x-operation-extra-annotation|List of custom annotations to be added to operation|OPERATION|null
|
||||
|x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false
|
||||
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
|
||||
|
@ -77,7 +77,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono<T>/Flux<T>` or `return T/List<T>/Set<T>` & execute `.block()` inside generated method)|OPERATION|false
|
||||
|
||||
|
||||
|
@ -80,7 +80,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -103,7 +103,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -102,7 +102,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -114,7 +114,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono<T>/Flux<T>` or `return T/List<T>/Set<T>` & execute `.block()` inside generated method)|OPERATION|false
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -89,7 +89,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -92,7 +92,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -85,7 +85,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -82,7 +82,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -114,7 +114,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|x-webclient-blocking|Specifies if method for specific operation should be blocking or non-blocking(ex: return `Mono<T>/Flux<T>` or `return T/List<T>/Set<T>` & execute `.block()` inside generated method)|OPERATION|false
|
||||
|
||||
|
||||
|
@ -96,7 +96,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -87,7 +87,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -110,7 +110,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -105,7 +105,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -89,7 +89,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -88,7 +88,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -96,7 +96,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|
||||
|
||||
## IMPORT MAPPING
|
||||
|
@ -113,7 +113,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
|
||||
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
|
||||
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD|null
|
||||
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
|
||||
|x-operation-extra-annotation|List of custom annotations to be added to operation|OPERATION|null
|
||||
|x-spring-paginated|Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters|OPERATION|false
|
||||
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
|
||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||
X_ACCEPTS("x-accepts", ExtensionLevel.OPERATION, "Specify custom value for 'Accept' header for operation", null),
|
||||
X_CONTENT_TYPE("x-content-type", ExtensionLevel.OPERATION, "Specify custom value for 'Content-Type' header for operation", null),
|
||||
X_CLASS_EXTRA_ANNOTATION("x-class-extra-annotation", ExtensionLevel.MODEL, "List of custom annotations to be added to model", null),
|
||||
X_FIELD_EXTRA_ANNOTATION("x-field-extra-annotation", ExtensionLevel.FIELD, "List of custom annotations to be added to property", null),
|
||||
X_FIELD_EXTRA_ANNOTATION("x-field-extra-annotation", Arrays.asList(ExtensionLevel.FIELD, ExtensionLevel.OPERATION_PARAMETER), "List of custom annotations to be added to property", null),
|
||||
X_OPERATION_EXTRA_ANNOTATION("x-operation-extra-annotation", ExtensionLevel.OPERATION, "List of custom annotations to be added to operation", null),
|
||||
X_VERSION_PARAM("x-version-param", ExtensionLevel.OPERATION_PARAMETER, "Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false", null),
|
||||
X_PATTERN_MESSAGE("x-pattern-message", Arrays.asList(ExtensionLevel.FIELD, ExtensionLevel.OPERATION_PARAMETER), "Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable", null),
|
||||
|
@ -1 +1 @@
|
||||
{{#isHeaderParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}} @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isHeaderParam}}
|
||||
{{#isHeaderParam}}{{#vendorExtensions.x-field-extra-annotation}}{{{vendorExtensions.x-field-extra-annotation}}} {{/vendorExtensions.x-field-extra-annotation}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}} @RequestHeader(value = "{{baseName}}", required = {{#required}}true{{/required}}{{^required}}false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{>dateTimeParam}} {{>optionalDataType}} {{paramName}}{{/isHeaderParam}}
|
@ -1 +1 @@
|
||||
{{#isPathParam}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{>paramDoc}} @PathVariable("{{baseName}}"){{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isPathParam}}
|
||||
{{#isPathParam}}{{#vendorExtensions.x-field-extra-annotation}}{{{vendorExtensions.x-field-extra-annotation}}} {{/vendorExtensions.x-field-extra-annotation}}{{#useBeanValidation}}{{>beanValidationPathParams}}{{/useBeanValidation}}{{>paramDoc}} @PathVariable("{{baseName}}"){{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isPathParam}}
|
@ -1 +1 @@
|
||||
{{#isQueryParam}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/isModel}}{{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
|
||||
{{#isQueryParam}}{{#vendorExtensions.x-field-extra-annotation}}{{{vendorExtensions.x-field-extra-annotation}}} {{/vendorExtensions.x-field-extra-annotation}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{>paramDoc}}{{#useBeanValidation}} @Valid{{/useBeanValidation}}{{^isModel}} @RequestParam(value = {{#isMap}}""{{/isMap}}{{^isMap}}"{{baseName}}"{{/isMap}}{{#required}}, required = true{{/required}}{{^required}}, required = false{{/required}}{{#defaultValue}}, defaultValue = "{{{.}}}"{{/defaultValue}}){{/isModel}}{{>dateTimeParam}}{{#isDeprecated}} @Deprecated{{/isDeprecated}} {{>optionalDataType}} {{paramName}}{{/isQueryParam}}
|
@ -3269,6 +3269,52 @@ public class SpringCodegenTest {
|
||||
.bodyContainsLines("if (b.value.equals(value)) {");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasOperationParameterExtraAnnotation_issue18224() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_18224.yaml");
|
||||
final SpringCodegen codegen = new SpringCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
|
||||
codegen.additionalProperties().put(SpringCodegen.DATE_LIBRARY, "java8-localdatetime");
|
||||
codegen.additionalProperties().put(INTERFACE_ONLY, "true");
|
||||
codegen.additionalProperties().put(USE_RESPONSE_ENTITY, "false");
|
||||
codegen.additionalProperties().put(DELEGATE_PATTERN, "true");
|
||||
codegen.additionalProperties().put(REQUEST_MAPPING_OPTION, "api_interface");
|
||||
codegen.additionalProperties().put(SPRING_CONTROLLER, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
generator.setGenerateMetadata(false); // skip metadata generation
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(files.get("TestApi.java"));
|
||||
javaFileAssert
|
||||
.assertMethod("_postToTest")
|
||||
.assertParameter("groupObj")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("com.test.MyAnnotationInPath")
|
||||
.toParameter()
|
||||
.toMethod()
|
||||
.assertParameter("token")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("com.test.MyAnnotationInQuery")
|
||||
.toParameter()
|
||||
.toMethod()
|
||||
.assertParameter("clientId")
|
||||
.assertParameterAnnotations()
|
||||
.containsWithName("com.test.MyAnnotationInHeader");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasOperationExtraAnnotation_issue15822() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
|
@ -0,0 +1,66 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: sample spec
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/test/{groupObj}:
|
||||
post:
|
||||
summary: Post to test
|
||||
description: ''
|
||||
operationId: postToTest
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/groupObj'
|
||||
- $ref: '#/components/parameters/token'
|
||||
- $ref: '#/components/parameters/clientId'
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ObjTest'
|
||||
responses:
|
||||
201:
|
||||
description: success
|
||||
components:
|
||||
parameters:
|
||||
groupObj:
|
||||
in: path
|
||||
name: groupObj
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
pattern: "[a-zA-Z]"
|
||||
x-pattern-message: "Only letters"
|
||||
x-field-extra-annotation: '@com.test.MyAnnotationInPath'
|
||||
token:
|
||||
in: query
|
||||
name: token
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
pattern: "[0-9a-fA-F]"
|
||||
x-pattern-message: "Only numbers and letters a-f"
|
||||
x-field-extra-annotation: '@com.test.MyAnnotationInQuery'
|
||||
clientId:
|
||||
in: header
|
||||
name: clientId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
pattern: "\\d"
|
||||
x-pattern-message: "Only numbers"
|
||||
x-field-extra-annotation: '@com.test.MyAnnotationInHeader'
|
||||
schemas:
|
||||
ObjTest:
|
||||
description: A model to return
|
||||
type: object
|
||||
properties:
|
||||
field1:
|
||||
type: integer
|
||||
format: int64
|
||||
field2:
|
||||
type: string
|
||||
pattern: "\\w"
|
||||
x-pattern-message: "Only letters, numbers and underscore"
|
||||
field3:
|
||||
type: string
|
||||
pattern: "\\w"
|
Loading…
x
Reference in New Issue
Block a user