From fb07d9720f7ad75c4b647171e3d40d58fba5c430 Mon Sep 17 00:00:00 2001 From: Jonathan Ryan Date: Wed, 13 May 2020 10:37:17 -0400 Subject: [PATCH 1/7] Process @Parameter annotations in method parameters as MergedAnnotations --- .../org/springdoc/core/AbstractRequestBuilder.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java index ad78f6d84..67c5d35a7 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java @@ -61,6 +61,8 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.AnnotatedElementUtils; +import org.springframework.core.annotation.MergedAnnotation; +import org.springframework.core.annotation.MergedAnnotations; import org.springframework.http.HttpMethod; import org.springframework.util.CollectionUtils; import org.springframework.validation.BindingResult; @@ -174,7 +176,13 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod, for (MethodParameter methodParameter : parameters) { // check if query param Parameter parameter = null; - io.swagger.v3.oas.annotations.Parameter parameterDoc = methodParameter.getParameterAnnotation(io.swagger.v3.oas.annotations.Parameter.class); + MergedAnnotation parameterMergedAnnotation = + MergedAnnotations.from(methodParameter.getParameterAnnotations()).get(io.swagger.v3.oas.annotations.Parameter.class); + io.swagger.v3.oas.annotations.Parameter parameterDoc = null; + if (parameterMergedAnnotation.isPresent()) { + parameterDoc = parameterMergedAnnotation.synthesize(); + } + final String pName = methodParameter.getParameterName(); ParameterInfo parameterInfo = new ParameterInfo(pName, methodParameter); From 8f5fa2b3612ed29ad1165ab0ddfff1faa65b0db3 Mon Sep 17 00:00:00 2001 From: Jonathan Ryan Date: Mon, 18 May 2020 14:53:27 -0400 Subject: [PATCH 2/7] Make compatible with older Spring versions --- .../org/springdoc/core/AbstractRequestBuilder.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java index 67c5d35a7..bb3a9e70f 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java @@ -35,7 +35,6 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; - import javax.validation.constraints.DecimalMax; import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Max; @@ -57,7 +56,6 @@ import io.swagger.v3.oas.models.parameters.RequestBody; import org.apache.commons.lang3.StringUtils; import org.springdoc.core.customizers.ParameterCustomizer; - import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.AnnotatedElementUtils; @@ -176,12 +174,9 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod, for (MethodParameter methodParameter : parameters) { // check if query param Parameter parameter = null; - MergedAnnotation parameterMergedAnnotation = - MergedAnnotations.from(methodParameter.getParameterAnnotations()).get(io.swagger.v3.oas.annotations.Parameter.class); - io.swagger.v3.oas.annotations.Parameter parameterDoc = null; - if (parameterMergedAnnotation.isPresent()) { - parameterDoc = parameterMergedAnnotation.synthesize(); - } + io.swagger.v3.oas.annotations.Parameter parameterDoc = AnnotatedElementUtils.findMergedAnnotation( + AnnotatedElementUtils.forAnnotations(methodParameter.getParameterAnnotations()), + io.swagger.v3.oas.annotations.Parameter.class); final String pName = methodParameter.getParameterName(); ParameterInfo parameterInfo = new ParameterInfo(pName, methodParameter); From 6e1e3bd9fe9f9f96a594bd4e188460a3303cce50 Mon Sep 17 00:00:00 2001 From: Jonathan Ryan Date: Mon, 18 May 2020 15:08:18 -0400 Subject: [PATCH 3/7] Update AbstractRequestBuilder.java --- .../main/java/org/springdoc/core/AbstractRequestBuilder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java index bb3a9e70f..9c4f3a22b 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java @@ -35,6 +35,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; + import javax.validation.constraints.DecimalMax; import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Max; @@ -56,6 +57,7 @@ import io.swagger.v3.oas.models.parameters.RequestBody; import org.apache.commons.lang3.StringUtils; import org.springdoc.core.customizers.ParameterCustomizer; + import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.AnnotatedElementUtils; From 4a1480b89478737c4e1c18569a6cee176c603ec7 Mon Sep 17 00:00:00 2001 From: Jonathan Ryan Date: Mon, 18 May 2020 15:08:40 -0400 Subject: [PATCH 4/7] Update AbstractRequestBuilder.java --- .../main/java/org/springdoc/core/AbstractRequestBuilder.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java index 9c4f3a22b..0f7c7c960 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestBuilder.java @@ -61,8 +61,6 @@ import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.AnnotatedElementUtils; -import org.springframework.core.annotation.MergedAnnotation; -import org.springframework.core.annotation.MergedAnnotations; import org.springframework.http.HttpMethod; import org.springframework.util.CollectionUtils; import org.springframework.validation.BindingResult; From 9e1f65cf9f3401daff5c88898494da07c7944549 Mon Sep 17 00:00:00 2001 From: Jonathan Ryan Date: Tue, 19 May 2020 16:34:46 -0400 Subject: [PATCH 5/7] Add tests --- .../org/springdoc/api/app119/AccountId.java | 49 ++++ .../api/app119/MetaAnnotationController.java | 163 +++++++++++ .../api/app119/SpringDocApp118Test.java | 31 +++ .../src/test/resources/results/app119.json | 258 ++++++++++++++++++ 4 files changed, 501 insertions(+) create mode 100644 springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/AccountId.java create mode 100644 springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/MetaAnnotationController.java create mode 100644 springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp118Test.java create mode 100644 springdoc-openapi-webmvc-core/src/test/resources/results/app119.json diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/AccountId.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/AccountId.java new file mode 100644 index 000000000..7111df427 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/AccountId.java @@ -0,0 +1,49 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ +package test.org.springdoc.api.app119; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.core.annotation.AliasFor; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; + +@Target({PARAMETER, METHOD, ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Parameter(description = "non alias description") +public @interface AccountId { + + @AliasFor(annotation = Parameter.class, value = "name") + String name() default ""; + + @AliasFor(annotation = Parameter.class, value = "example") + String example() default "123456"; + + @AliasFor(annotation = Parameter.class, value = "in") + ParameterIn in() default ParameterIn.DEFAULT; + + @AliasFor(annotation = Parameter.class, value = "schema") + Schema schema() default @Schema(); +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/MetaAnnotationController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/MetaAnnotationController.java new file mode 100644 index 000000000..16bdf4c10 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/MetaAnnotationController.java @@ -0,0 +1,163 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ +package test.org.springdoc.api.app119; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springframework.core.annotation.AliasFor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; + +@RestController +public class MetaAnnotationController { + + @GetMapping(value = "/simpleTest/{accountId}") + String simpleTest(@PathVariable @AccountId String accountId) { + return accountId; + } + + /** + * When there is a top level {@code @Parameter} annotation it has precedence over the meta-annotation + * So the id parameter should have all the defaults, with a name of "id" + */ + @GetMapping(value = "/testTopLevelParamAnnotationOverrides/{accountId}") + String testTopLevelParamAnnotationOverrides(@PathVariable @AccountId @Parameter(name = "id") String accountId) { + return accountId; + } + + @GetMapping(value = "/testQueryParam") + String testQueryParam(@RequestParam @AccountId String accountId) { + return accountId; + } + + /** + * {@code @AliasFor} in the {@code @AccountId} annotation allows us to override the default it provides. + */ + @GetMapping(value = "/testAliasFor") + String testAliasFor(@RequestParam @AccountId(example = "OVERRIDDEN EXAMPLE") String accountId) { + return accountId; + } + + /** + * This should inherent all the attributes of {@code @AccountId}, but give it a different name + */ + @Target({PARAMETER, METHOD, ANNOTATION_TYPE}) + @Retention(RetentionPolicy.RUNTIME) + @AccountId(name = "queryAccountId") + @interface QueryAccountId { + } + + @GetMapping(value = "/testMetaMetaAnnotation/{accountId}") + String testMetaMetaAnnotation( + @RequestParam @QueryAccountId String queryAccountId, + @PathVariable @AccountId String accountId) { + return accountId; + } + + @Target({PARAMETER, METHOD, ANNOTATION_TYPE}) + @Retention(RetentionPolicy.RUNTIME) + @Parameter + @interface TestAllAttributesAsAlias { + + @AliasFor(annotation = Parameter.class, attribute="name") + String name() default "name"; + + @AliasFor(annotation = Parameter.class, attribute="in") + ParameterIn in() default ParameterIn.QUERY; + + @AliasFor(annotation = Parameter.class, attribute="description") + String description() default "desc"; + + @AliasFor(annotation = Parameter.class, attribute="required") + boolean required() default true; + + @AliasFor(annotation = Parameter.class, attribute="deprecated") + boolean deprecated() default true; + + @AliasFor(annotation = Parameter.class, attribute="allowEmptyValue") + boolean allowEmptyValue() default true; + + @AliasFor(annotation = Parameter.class, attribute="style") + ParameterStyle style() default ParameterStyle.DEEPOBJECT; + + @AliasFor(annotation = Parameter.class, attribute="explode") + Explode explode() default Explode.TRUE; + + @AliasFor(annotation = Parameter.class, attribute="allowReserved") + boolean allowReserved() default true; + + @AliasFor(annotation = Parameter.class, attribute="schema") + Schema schema() default @Schema(name = "special schema", implementation = Boolean.class); + + @AliasFor(annotation = Parameter.class, attribute="array") + ArraySchema array() default @ArraySchema(); + + @AliasFor(annotation = Parameter.class, attribute="content") + Content[] content() default {}; + + @AliasFor(annotation = Parameter.class, attribute="hidden") + boolean hidden() default false; + + @AliasFor(annotation = Parameter.class, attribute="examples") + ExampleObject[] examples() default {}; + + @AliasFor(annotation = Parameter.class, attribute="example") + String example() default "1234"; + + @AliasFor(annotation = Parameter.class, attribute="extensions") + Extension[] extensions() default {}; + + @AliasFor(annotation = Parameter.class, attribute="ref") + String ref() default ""; + } + + @GetMapping(value = "/testAllAttributesAsAlias/") + String testAllAttributesAsAlias( + @RequestParam @TestAllAttributesAsAlias String name) { + return name; + } + + @Target({PARAMETER, METHOD, ANNOTATION_TYPE}) + @Retention(RetentionPolicy.RUNTIME) + @Parameter(name = "name", description = "desc", schema = @Schema(implementation = Boolean.class)) + @interface TestNoAliasFors { + } + + @GetMapping(value = "/testNoAliasFors/") + String testNoAliasFors( + @RequestParam @TestAllAttributesAsAlias String name) { + return name; + } +} diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp118Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp118Test.java new file mode 100644 index 000000000..b19f670f3 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp118Test.java @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 the original author or authors. + * * + * * Licensed under the Apache License, Version 2.0 (the "License"); + * * you may not use this file except in compliance with the License. + * * You may obtain a copy of the License at + * * + * * https://www.apache.org/licenses/LICENSE-2.0 + * * + * * Unless required by applicable law or agreed to in writing, software + * * distributed under the License is distributed on an "AS IS" BASIS, + * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * * See the License for the specific language governing permissions and + * * limitations under the License. + * + */ +package test.org.springdoc.api.app119; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import test.org.springdoc.api.AbstractSpringDocTest; + + +/** + * Tests Spring meta-annotations as method parameters + */ +public class SpringDocApp118Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app119.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app119.json new file mode 100644 index 000000000..bf4ffdc95 --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/app119.json @@ -0,0 +1,258 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/simpleTest/{accountId}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "simpleTest", + "parameters": [ + { + "name": "accountId", + "in": "path", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testTopLevelParamAnnotationOverrides/{accountId}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testTopLevelParamAnnotationOverrides", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testQueryParam": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testQueryParam", + "parameters": [ + { + "name": "accountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testAliasFor": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testAliasFor", + "parameters": [ + { + "name": "accountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": "OVERRIDDEN EXAMPLE" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testMetaMetaAnnotation/{accountId}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testMetaMetaAnnotation", + "parameters": [ + { + "name": "queryAccountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + }, + { + "name": "accountId", + "in": "path", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testAllAttributesAsAlias/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testAllAttributesAsAlias", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "desc", + "required": true, + "deprecated": true, + "allowEmptyValue": true, + "style": "deepObject", + "explode": true, + "allowReserved": true, + "schema": { + "type": "boolean" + }, + "example": 1234 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testNoAliasFors/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testNoAliasFors", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "desc", + "required": true, + "deprecated": true, + "allowEmptyValue": true, + "style": "deepObject", + "explode": true, + "allowReserved": true, + "schema": { + "type": "boolean" + }, + "example": 1234 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} From 8abdc75931ef63603dc5b5254d5dd094ed6a3ba7 Mon Sep 17 00:00:00 2001 From: Jonathan Ryan Date: Tue, 19 May 2020 16:44:03 -0400 Subject: [PATCH 6/7] Move to 120 --- .../api/{app119 => app120}/AccountId.java | 2 +- .../MetaAnnotationController.java | 2 +- .../SpringDocApp120Test.java} | 4 +- .../src/test/resources/results/app120.json | 332 ++++++++++++++++++ 4 files changed, 336 insertions(+), 4 deletions(-) rename springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/{app119 => app120}/AccountId.java (97%) rename springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/{app119 => app120}/MetaAnnotationController.java (99%) rename springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/{app119/SpringDocApp118Test.java => app120/SpringDocApp120Test.java} (89%) create mode 100644 springdoc-openapi-webmvc-core/src/test/resources/results/app120.json diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/AccountId.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/AccountId.java similarity index 97% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/AccountId.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/AccountId.java index 7111df427..b4a8d4d0f 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/AccountId.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/AccountId.java @@ -15,7 +15,7 @@ * * limitations under the License. * */ -package test.org.springdoc.api.app119; +package test.org.springdoc.api.app120; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/MetaAnnotationController.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java similarity index 99% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/MetaAnnotationController.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java index 16bdf4c10..0002ef726 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/MetaAnnotationController.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java @@ -15,7 +15,7 @@ * * limitations under the License. * */ -package test.org.springdoc.api.app119; +package test.org.springdoc.api.app120; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp118Test.java b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java similarity index 89% rename from springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp118Test.java rename to springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java index b19f670f3..28bc22f97 100644 --- a/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app119/SpringDocApp118Test.java +++ b/springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java @@ -15,7 +15,7 @@ * * limitations under the License. * */ -package test.org.springdoc.api.app119; +package test.org.springdoc.api.app120; import org.springframework.boot.autoconfigure.SpringBootApplication; import test.org.springdoc.api.AbstractSpringDocTest; @@ -24,7 +24,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp118Test extends AbstractSpringDocTest { +public class SpringDocApp120Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json new file mode 100644 index 000000000..008f0966f --- /dev/null +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json @@ -0,0 +1,332 @@ +{ +<<<<<<< HEAD + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/simpleTest/{accountId}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "simpleTest", + "parameters": [ + { + "name": "accountId", + "in": "path", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testTopLevelParamAnnotationOverrides/{accountId}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testTopLevelParamAnnotationOverrides", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testQueryParam": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testQueryParam", + "parameters": [ + { + "name": "accountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testAliasFor": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testAliasFor", + "parameters": [ + { + "name": "accountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": "OVERRIDDEN EXAMPLE" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testMetaMetaAnnotation/{accountId}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testMetaMetaAnnotation", + "parameters": [ + { + "name": "queryAccountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + }, + { + "name": "accountId", + "in": "path", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testAllAttributesAsAlias/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testAllAttributesAsAlias", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "desc", + "required": true, + "deprecated": true, + "allowEmptyValue": true, + "style": "deepObject", + "explode": true, + "allowReserved": true, + "schema": { + "type": "boolean" + }, + "example": 1234 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testNoAliasFors/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testNoAliasFors", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "desc", + "required": true, + "deprecated": true, + "allowEmptyValue": true, + "style": "deepObject", + "explode": true, + "allowReserved": true, + "schema": { + "type": "boolean" + }, + "example": 1234 + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +======= + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/multi": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Multiple files and JSON payloads as multi part request", + "operationId": "multiFilesInMultiPart", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "params": { + "$ref": "#/components/schemas/JsonRequest" + }, + "file1": { + "type": "string", + "description": "This is file1", + "format": "binary" + }, + "file2": { + "type": "string", + "description": "This is file2", + "format": "binary" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "JsonRequest": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "description": "This is the configuration" + } + } + } +>>>>>>> origin/master +} From 503d81c9b28deb92005b867534241bd95e13bb78 Mon Sep 17 00:00:00 2001 From: Jonathan Ryan Date: Tue, 19 May 2020 16:57:52 -0400 Subject: [PATCH 7/7] Fix left over merge --- .../src/test/resources/results/app120.json | 88 ++----------------- 1 file changed, 7 insertions(+), 81 deletions(-) diff --git a/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json b/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json index 008f0966f..565fe81d0 100644 --- a/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json +++ b/springdoc-openapi-webmvc-core/src/test/resources/results/app120.json @@ -1,5 +1,4 @@ { -<<<<<<< HEAD "openapi": "3.0.1", "info": { "title": "OpenAPI definition", @@ -15,7 +14,7 @@ "/simpleTest/{accountId}": { "get": { "tags": [ - "hello-controller" + "meta-annotation-controller" ], "operationId": "simpleTest", "parameters": [ @@ -47,7 +46,7 @@ "/testTopLevelParamAnnotationOverrides/{accountId}": { "get": { "tags": [ - "hello-controller" + "meta-annotation-controller" ], "operationId": "testTopLevelParamAnnotationOverrides", "parameters": [ @@ -77,7 +76,7 @@ "/testQueryParam": { "get": { "tags": [ - "hello-controller" + "meta-annotation-controller" ], "operationId": "testQueryParam", "parameters": [ @@ -109,7 +108,7 @@ "/testAliasFor": { "get": { "tags": [ - "hello-controller" + "meta-annotation-controller" ], "operationId": "testAliasFor", "parameters": [ @@ -141,7 +140,7 @@ "/testMetaMetaAnnotation/{accountId}": { "get": { "tags": [ - "hello-controller" + "meta-annotation-controller" ], "operationId": "testMetaMetaAnnotation", "parameters": [ @@ -183,7 +182,7 @@ "/testAllAttributesAsAlias/": { "get": { "tags": [ - "hello-controller" + "meta-annotation-controller" ], "operationId": "testAllAttributesAsAlias", "parameters": [ @@ -220,7 +219,7 @@ "/testNoAliasFors/": { "get": { "tags": [ - "hello-controller" + "meta-annotation-controller" ], "operationId": "testNoAliasFors", "parameters": [ @@ -256,77 +255,4 @@ } }, "components": {} -======= - "openapi": "3.0.1", - "info": { - "title": "OpenAPI definition", - "version": "v0" - }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "paths": { - "/multi": { - "post": { - "tags": [ - "hello-controller" - ], - "summary": "Multiple files and JSON payloads as multi part request", - "operationId": "multiFilesInMultiPart", - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "params": { - "$ref": "#/components/schemas/JsonRequest" - }, - "file1": { - "type": "string", - "description": "This is file1", - "format": "binary" - }, - "file2": { - "type": "string", - "description": "This is file2", - "format": "binary" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "JsonRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - } - }, - "description": "This is the configuration" - } - } - } ->>>>>>> origin/master }