Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -716,8 +717,21 @@ private String getDefaultValue(String parameterName, PageableDefault pageableDef
String defaultValue = null;
switch (parameterName) {
case "size":
if (pageableDefault != null)
defaultValue = String.valueOf(pageableDefault.size());
if (pageableDefault != null) {
// "size" is aliased as "value"
int size = pageableDefault.size();
Object defaultSize;
try {
defaultSize = PageableDefault.class.getMethod("size").getDefaultValue();
} catch (NoSuchMethodException e) {
LOGGER.warn(e.getMessage());
defaultSize = null;
}
if (Objects.deepEquals(size, defaultSize)) {
size = pageableDefault.value();
}
defaultValue = String.valueOf(size);
}
else if (isRepositoryRestConfigurationPresent())
defaultValue = String.valueOf(optionalRepositoryRestConfigurationProvider.get().getRepositoryRestConfiguration().getDefaultPageSize());
else if (isSpringDataWebPropertiesPresent())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ public String getPatientList3(@PageableDefault(size = 100)
@ParameterObject Pageable pageable) {
return "bla";
}

@GetMapping("/test4")
public String getPatientList4(@PageableDefault(100)
@ParameterObject Pageable pageable) {
return "bla";
}
}
56 changes: 56 additions & 0 deletions springdoc-openapi-data-rest/src/test/resources/results/app13.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,62 @@
}
],
"paths": {
"/test4": {
"get": {
"tags": [
"hello-controller"
],
"operationId": "getPatientList4",
"parameters": [
{
"name": "page",
"in": "query",
"description": "Zero-based page index (0..N)",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"default": 0
}
},
{
"name": "size",
"in": "query",
"description": "The size of the page to be returned",
"required": false,
"schema": {
"minimum": 1,
"type": "integer",
"default": 100
}
},
{
"name": "sort",
"in": "query",
"description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
"required": false,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/hal+json": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/test3": {
"get": {
"tags": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,10 @@ public String getPatientList3(@PageableDefault(size = 100)
@ParameterObject Pageable pageable) {
return "bla";
}

@GetMapping("/test4")
public String getPatientList4(@PageableDefault(100)
@ParameterObject Pageable pageable) {
return "bla";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,62 @@
}
],
"paths": {
"/test4": {
"get": {
"tags": [
"hello-controller"
],
"operationId": "getPatientList4",
"parameters": [
{
"name": "page",
"in": "query",
"description": "Zero-based page index (0..N)",
"required": false,
"schema": {
"minimum": 0,
"type": "integer",
"default": 0
}
},
{
"name": "size",
"in": "query",
"description": "The size of the page to be returned",
"required": false,
"schema": {
"minimum": 1,
"type": "integer",
"default": 100
}
},
{
"name": "sort",
"in": "query",
"description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
"required": false,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
"/test3": {
"get": {
"tags": [
Expand Down