[Java][Spring] remove 'size', 'page' and 'sort' query params if using 'x-spring-paginated' (#8315) (#21016)

* [Java][Spring] remove 'size', 'page' and 'sort' query params if using 'x-spring-paginated' (#8315)

* Properly implement samples, fixing build issues

---------

Co-authored-by: Tobias Fischer <t.fischer@goldflam.de>
This commit is contained in:
30p87
2025-04-23 09:47:17 +02:00
committed by GitHub
parent 72de5bc952
commit ee7927a525
20 changed files with 312 additions and 7 deletions

View File

@@ -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<List<Pet>> findPetsByTags(
@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List<String> 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);
}

View File

@@ -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<List<Pet>> findPetsByTags(List<String> tags, final Pageable pageable) {
default ResponseEntity<List<Pet>> findPetsByTags(List<String> tags,
String size, final Pageable pageable) {
getRequest().ifPresent(request -> {
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {

View File

@@ -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: