diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md index 21fc99f6982..6916e9defea 100644 --- a/docs/generators/java-camel.md +++ b/docs/generators/java-camel.md @@ -127,7 +127,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |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, 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-spring-paginated|Add `org.springframework.data.domain.Pageable` to controller method. Can be used to handle `page`, `size` and `sort` query parameters. If these query parameters are also specified in the operation spec, they will be removed from the controller method as their values can be obtained from the `Pageable` object.|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 |x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null diff --git a/docs/generators/spring.md b/docs/generators/spring.md index fe41ea1f32a..36ac0bc2689 100644 --- a/docs/generators/spring.md +++ b/docs/generators/spring.md @@ -120,7 +120,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |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, 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-spring-paginated|Add `org.springframework.data.domain.Pageable` to controller method. Can be used to handle `page`, `size` and `sort` query parameters. If these query parameters are also specified in the operation spec, they will be removed from the controller method as their values can be obtained from the `Pageable` object.|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 |x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java index 2f175b564d7..64ffe79c9b5 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/VendorExtension.java @@ -10,7 +10,7 @@ import java.util.List; public enum VendorExtension { X_IMPLEMENTS("x-implements", ExtensionLevel.MODEL, "Ability to specify interfaces that model must implements", "empty array"), - X_SPRING_PAGINATED("x-spring-paginated", ExtensionLevel.OPERATION, "Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters", "false"), + X_SPRING_PAGINATED("x-spring-paginated", ExtensionLevel.OPERATION, "Add `org.springframework.data.domain.Pageable` to controller method. Can be used to handle `page`, `size` and `sort` query parameters. If these query parameters are also specified in the operation spec, they will be removed from the controller method as their values can be obtained from the `Pageable` object.", "false"), X_SPRING_PROVIDE_ARGS("x-spring-provide-args", ExtensionLevel.OPERATION, "Allows adding additional hidden parameters in the API specification to allow access to content such as header values or properties", "empty array"), X_DISCRIMINATOR_VALUE("x-discriminator-value", ExtensionLevel.MODEL, "Used with model inheritance to specify value for discriminator that identifies current model", ""), X_SETTER_EXTRA_ANNOTATION("x-setter-extra-annotation", ExtensionLevel.FIELD, "Custom annotation that can be specified over java setter for specific field", "When field is array & uniqueItems, then this extension is used to add `@JsonDeserialize(as = LinkedHashSet.class)` over setter, otherwise no value"), diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java index 5237520ce9d..4d1f9438f05 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java @@ -996,6 +996,8 @@ public class SpringCodegen extends AbstractJavaCodegen * Add dynamic imports based on the parameters and vendor extensions of an operation. * The imports are expanded by the mustache {{import}} tag available to model and api * templates. + * + * #8315 Also handles removing 'size', 'page' and 'sort' query parameters if using 'x-spring-paginated'. */ @Override public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List servers) { @@ -1023,6 +1025,15 @@ public class SpringCodegen extends AbstractJavaCodegen if (DocumentationProvider.SPRINGDOC.equals(getDocumentationProvider())) { codegenOperation.imports.add("ParameterObject"); } + + // #8315 Spring Data Web default query params recognized by Pageable + List defaultPageableQueryParams = new ArrayList<>( + Arrays.asList("page", "size", "sort") + ); + + // #8315 Remove matching Spring Data Web default query params if 'x-spring-paginated' with Pageable is used + codegenOperation.queryParams.removeIf(param -> defaultPageableQueryParams.contains(param.baseName)); + codegenOperation.allParams.removeIf(param -> param.isQueryParam && defaultPageableQueryParams.contains(param.baseName)); } if (codegenOperation.vendorExtensions.containsKey("x-spring-provide-args") && !provideArgsClassSet.isEmpty()) { codegenOperation.imports.addAll(provideArgsClassSet); diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml index 8f8655b4f37..b903c4f68c2 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml @@ -137,6 +137,31 @@ paths: items: type: string collectionFormat: csv + - name: size + in: header + description: 'A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.' + required: false + type: string + - name: size + in: query + description: 'The number of items to return per page. Test QueryParam for issue #8315 - must be removed when x-spring-paginated:true is used.' + required: true + type: integer + minimum: 1 + default: 20 + - name: page + in: query + description: 'The page to return, starting with page 0. Test QueryParam for issue #8315 - must be removed when x-spring-paginated:true is used.' + required: true + type: integer + minimum: 0 + default: 0 + - name: sort + in: query + description: 'The sorting to apply to the Pageable object. Test QueryParam for issue #8315 - must be removed when x-spring-paginated:true is used.' + required: true + type: string + default: id,asc responses: '200': description: successful operation diff --git a/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml b/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml index 9a1152bb06a..fbf17da6424 100644 --- a/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml +++ b/modules/openapi-generator/src/test/resources/2_0/petstore-with-spring-pageable.yaml @@ -133,6 +133,31 @@ paths: items: type: string collectionFormat: csv + - name: size + in: header + description: 'A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.' + required: false + type: string + - name: size + in: query + description: 'The number of items to return per page. Test QueryParam for issue #8315 - must be removed when x-spring-paginated:true is used.' + required: true + type: integer + minimum: 1 + default: 20 + - name: page + in: query + description: 'The page to return, starting with page 0. Test QueryParam for issue #8315 - must be removed when x-spring-paginated:true is used.' + required: true + type: integer + minimum: 0 + default: 0 + - name: sort + in: query + description: 'The sorting to apply to the Pageable object. Test QueryParam for issue #8315 - must be removed when x-spring-paginated:true is used.' + required: true + type: string + default: id,asc responses: '200': description: successful operation diff --git a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml index 0d3f66f4ab1..ba52d9622c0 100644 --- a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing-with-spring-pageable.yaml @@ -171,6 +171,38 @@ paths: type: array items: type: string + - description: "A test HeaderParam for issue #8315 - must NOT be removed when\ + \ x-spring-paginated:true is used." + in: header + name: size + schema: + type: string + - description: "The number of items to return per page. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + in: query + name: size + required: true + schema: + default: 20 + minimum: 1 + type: integer + - description: "The page to return, starting with page 0. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + in: query + name: page + required: true + schema: + default: 0 + minimum: 0 + type: integer + - description: "The sorting to apply to the Pageable object. Test QueryParam\ + \ for issue #8315 - must be removed when x-spring-paginated:true is used." + in: query + name: sort + required: true + schema: + default: "id,asc" + type: string responses: 200: description: successful operation diff --git a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml index bd045d28262..dcf0075a21f 100644 --- a/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-spring-pageable.yaml @@ -136,6 +136,38 @@ paths: type: array items: type: string + - description: "A test HeaderParam for issue #8315 - must NOT be removed when\ + \ x-spring-paginated:true is used." + in: header + name: size + schema: + type: string + - description: "The number of items to return per page. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + in: query + name: size + required: true + schema: + default: 20 + minimum: 1 + type: integer + - description: "The page to return, starting with page 0. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + in: query + name: page + required: true + schema: + default: 0 + minimum: 0 + type: integer + - description: "The sorting to apply to the Pageable object. Test QueryParam\ + \ for issue #8315 - must be removed when x-spring-paginated:true is used." + in: query + name: sort + required: true + schema: + default: "id,asc" + type: string responses: 200: description: successful operation diff --git a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java index 5b80ec1cf77..a95f571f429 100644 --- a/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -135,6 +135,7 @@ public interface PetApi { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated @@ -165,6 +166,7 @@ public interface PetApi { ) ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @ApiParam(value = "A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.") @RequestHeader(value = "size", required = false) String size, @ApiIgnore final Pageable pageable ); diff --git a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java index fc8dc11d46d..94a59908371 100644 --- a/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/openapi3/client/petstore/spring-cloud-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -138,6 +138,7 @@ public interface PetApi { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated @@ -168,6 +169,7 @@ public interface PetApi { ResponseEntity> findPetsByTags( @NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "tags", required = true) List tags, + @Parameter(name = "size", description = "A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.", in = ParameterIn.HEADER) @RequestHeader(value = "size", required = false) String size, @ParameterObject final Pageable pageable ); diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java index 06a00735c20..23e10454271 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApi.java @@ -148,6 +148,7 @@ public interface PetApi { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated @@ -179,9 +180,10 @@ public interface PetApi { default ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @ApiParam(value = "A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.") @RequestHeader(value = "size", required = false) String size, @ApiIgnore final Pageable pageable ) { - return getDelegate().findPetsByTags(tags, pageable); + return getDelegate().findPetsByTags(tags, size, pageable); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java index 286c2be5022..4833a24c520 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -89,13 +89,15 @@ public interface PetApiDelegate { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated * @see PetApi#findPetsByTags */ @Deprecated - default ResponseEntity> findPetsByTags(List tags, final Pageable pageable) { + default ResponseEntity> findPetsByTags(List tags, + String size, final Pageable pageable) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/resources/openapi.yaml index 83bb676d210..615aa861b54 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern-without-j8/src/main/resources/openapi.yaml @@ -189,6 +189,47 @@ paths: type: string type: array style: form + - description: "A test HeaderParam for issue #8315 - must NOT be removed when\ + \ x-spring-paginated:true is used." + explode: false + in: header + name: size + required: false + schema: + type: string + style: simple + - description: "The number of items to return per page. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: size + required: true + schema: + default: 20 + minimum: 1 + type: integer + style: form + - description: "The page to return, starting with page 0. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: page + required: true + schema: + default: 0 + minimum: 0 + type: integer + style: form + - description: "The sorting to apply to the Pageable object. Test QueryParam\ + \ for issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: sort + required: true + schema: + default: "id,asc" + type: string + style: form responses: "200": content: diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java index 06a00735c20..23e10454271 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApi.java @@ -148,6 +148,7 @@ public interface PetApi { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated @@ -179,9 +180,10 @@ public interface PetApi { default ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @ApiParam(value = "A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.") @RequestHeader(value = "size", required = false) String size, @ApiIgnore final Pageable pageable ) { - return getDelegate().findPetsByTags(tags, pageable); + return getDelegate().findPetsByTags(tags, size, pageable); } diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java index 286c2be5022..4833a24c520 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/java/org/openapitools/api/PetApiDelegate.java @@ -89,13 +89,15 @@ public interface PetApiDelegate { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated * @see PetApi#findPetsByTags */ @Deprecated - default ResponseEntity> findPetsByTags(List tags, final Pageable pageable) { + default ResponseEntity> findPetsByTags(List tags, + String size, final Pageable pageable) { getRequest().ifPresent(request -> { for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) { if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { diff --git a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/resources/openapi.yaml index 83bb676d210..615aa861b54 100644 --- a/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-spring-pageable-delegatePattern/src/main/resources/openapi.yaml @@ -189,6 +189,47 @@ paths: type: string type: array style: form + - description: "A test HeaderParam for issue #8315 - must NOT be removed when\ + \ x-spring-paginated:true is used." + explode: false + in: header + name: size + required: false + schema: + type: string + style: simple + - description: "The number of items to return per page. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: size + required: true + schema: + default: 20 + minimum: 1 + type: integer + style: form + - description: "The page to return, starting with page 0. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: page + required: true + schema: + default: 0 + minimum: 0 + type: integer + style: form + - description: "The sorting to apply to the Pageable object. Test QueryParam\ + \ for issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: sort + required: true + schema: + default: "id,asc" + type: string + style: form responses: "200": content: diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java index ecf74b30fb1..6432f800b20 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/java/org/openapitools/api/PetApi.java @@ -169,6 +169,7 @@ public interface PetApi { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated @@ -200,6 +201,7 @@ public interface PetApi { default ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @ApiParam(value = "A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.") @RequestHeader(value = "size", required = false) String size, @ApiIgnore final Pageable pageable ) { getRequest().ifPresent(request -> { diff --git a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/resources/openapi.yaml index 83bb676d210..615aa861b54 100644 --- a/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-spring-pageable-without-j8/src/main/resources/openapi.yaml @@ -189,6 +189,47 @@ paths: type: string type: array style: form + - description: "A test HeaderParam for issue #8315 - must NOT be removed when\ + \ x-spring-paginated:true is used." + explode: false + in: header + name: size + required: false + schema: + type: string + style: simple + - description: "The number of items to return per page. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: size + required: true + schema: + default: 20 + minimum: 1 + type: integer + style: form + - description: "The page to return, starting with page 0. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: page + required: true + schema: + default: 0 + minimum: 0 + type: integer + style: form + - description: "The sorting to apply to the Pageable object. Test QueryParam\ + \ for issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: sort + required: true + schema: + default: "id,asc" + type: string + style: form responses: "200": content: diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java index ecf74b30fb1..6432f800b20 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java +++ b/samples/server/petstore/springboot-spring-pageable/src/main/java/org/openapitools/api/PetApi.java @@ -169,6 +169,7 @@ public interface PetApi { * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * * @param tags Tags to filter by (required) + * @param size A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used. (optional) * @return successful operation (status code 200) * or Invalid tag value (status code 400) * @deprecated @@ -200,6 +201,7 @@ public interface PetApi { default ResponseEntity> findPetsByTags( @NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags, + @ApiParam(value = "A test HeaderParam for issue #8315 - must NOT be removed when x-spring-paginated:true is used.") @RequestHeader(value = "size", required = false) String size, @ApiIgnore final Pageable pageable ) { getRequest().ifPresent(request -> { diff --git a/samples/server/petstore/springboot-spring-pageable/src/main/resources/openapi.yaml b/samples/server/petstore/springboot-spring-pageable/src/main/resources/openapi.yaml index 83bb676d210..615aa861b54 100644 --- a/samples/server/petstore/springboot-spring-pageable/src/main/resources/openapi.yaml +++ b/samples/server/petstore/springboot-spring-pageable/src/main/resources/openapi.yaml @@ -189,6 +189,47 @@ paths: type: string type: array style: form + - description: "A test HeaderParam for issue #8315 - must NOT be removed when\ + \ x-spring-paginated:true is used." + explode: false + in: header + name: size + required: false + schema: + type: string + style: simple + - description: "The number of items to return per page. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: size + required: true + schema: + default: 20 + minimum: 1 + type: integer + style: form + - description: "The page to return, starting with page 0. Test QueryParam for\ + \ issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: page + required: true + schema: + default: 0 + minimum: 0 + type: integer + style: form + - description: "The sorting to apply to the Pageable object. Test QueryParam\ + \ for issue #8315 - must be removed when x-spring-paginated:true is used." + explode: true + in: query + name: sort + required: true + schema: + default: "id,asc" + type: string + style: form responses: "200": content: