Skip to content

Commit

Permalink
Serialization to openapi of org.springframework.data.domain.Sort is w…
Browse files Browse the repository at this point in the history
…rong for Spring Boot >2.x. Fixes #2725
  • Loading branch information
bnasslahsen committed Oct 2, 2024
1 parent 618a836 commit 2dc72a2
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Optional;

import org.springdoc.core.converters.SortOpenAPIConverter;
import org.springdoc.core.converters.models.SortObject;
import org.springdoc.core.customizers.DataRestDelegatingMethodParameterCustomizer;
import org.springdoc.core.providers.ObjectMapperProvider;
import org.springdoc.core.providers.RepositoryRestConfigurationProvider;
Expand Down Expand Up @@ -71,7 +70,6 @@ public class SpringDocSortConfiguration {
@Lazy(false)
SortOpenAPIConverter sortOpenAPIConverter(ObjectMapperProvider objectMapperProvider) {
getConfig().replaceParameterObjectWithClass(org.springframework.data.domain.Sort.class, org.springdoc.core.converters.models.Sort.class);
getConfig().replaceWithClass(org.springframework.data.domain.Sort.class, SortObject.class);
return new SortOpenAPIConverter(objectMapperProvider);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,17 @@
"format": "int32"
},
"sort": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SortObject"
}
},
"first": {
"type": "boolean"
"$ref": "#/components/schemas/SortObject"
},
"last": {
"type": "boolean"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"first": {
"type": "boolean"
},
"numberOfElements": {
"type": "integer",
"format": "int32"
Expand All @@ -136,16 +133,7 @@
"format": "int64"
},
"sort": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SortObject"
}
},
"paged": {
"type": "boolean"
},
"unpaged": {
"type": "boolean"
"$ref": "#/components/schemas/SortObject"
},
"pageNumber": {
"type": "integer",
Expand All @@ -154,25 +142,25 @@
"pageSize": {
"type": "integer",
"format": "int32"
},
"paged": {
"type": "boolean"
},
"unpaged": {
"type": "boolean"
}
}
},
"SortObject": {
"type": "object",
"properties": {
"direction": {
"type": "string"
},
"nullHandling": {
"type": "string"
},
"ascending": {
"empty": {
"type": "boolean"
},
"property": {
"type": "string"
"sorted": {
"type": "boolean"
},
"ignoreCase": {
"unsorted": {
"type": "boolean"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,7 @@
"format": "int64"
},
"sort": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SortObject"
}
},
"paged": {
"type": "boolean"
},
"unpaged": {
"type": "boolean"
"$ref": "#/components/schemas/SortObject"
},
"pageNumber": {
"type": "integer",
Expand All @@ -81,25 +72,25 @@
"pageSize": {
"type": "integer",
"format": "int32"
},
"paged": {
"type": "boolean"
},
"unpaged": {
"type": "boolean"
}
}
},
"SortObject": {
"type": "object",
"properties": {
"direction": {
"type": "string"
},
"nullHandling": {
"type": "string"
},
"ascending": {
"empty": {
"type": "boolean"
},
"property": {
"type": "string"
"sorted": {
"type": "boolean"
},
"ignoreCase": {
"unsorted": {
"type": "boolean"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@
"type": "integer",
"format": "int64"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"size": {
"type": "integer",
"format": "int32"
Expand All @@ -243,10 +234,16 @@
"format": "int32"
},
"sort": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SortObject"
}
"$ref": "#/components/schemas/SortObject"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"numberOfElements": {
"type": "integer",
Expand All @@ -260,48 +257,39 @@
"PageableObject": {
"type": "object",
"properties": {
"offset": {
"type": "integer",
"format": "int64"
},
"sort": {
"$ref": "#/components/schemas/SortObject"
},
"paged": {
"type": "boolean"
},
"pageNumber": {
"type": "integer",
"format": "int32"
"unpaged": {
"type": "boolean"
},
"pageSize": {
"type": "integer",
"format": "int32"
},
"offset": {
"pageNumber": {
"type": "integer",
"format": "int64"
},
"sort": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SortObject"
}
},
"unpaged": {
"type": "boolean"
"format": "int32"
}
}
},
"SortObject": {
"type": "object",
"properties": {
"direction": {
"type": "string"
},
"nullHandling": {
"type": "string"
},
"ascending": {
"empty": {
"type": "boolean"
},
"property": {
"type": "string"
"unsorted": {
"type": "boolean"
},
"ignoreCase": {
"sorted": {
"type": "boolean"
}
}
Expand All @@ -317,15 +305,6 @@
"type": "integer",
"format": "int64"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"size": {
"type": "integer",
"format": "int32"
Expand All @@ -341,10 +320,16 @@
"format": "int32"
},
"sort": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SortObject"
}
"$ref": "#/components/schemas/SortObject"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"numberOfElements": {
"type": "integer",
Expand All @@ -366,15 +351,6 @@
"type": "integer",
"format": "int64"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"size": {
"type": "integer",
"format": "int32"
Expand All @@ -390,10 +366,16 @@
"format": "int32"
},
"sort": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SortObject"
}
"$ref": "#/components/schemas/SortObject"
},
"pageable": {
"$ref": "#/components/schemas/PageableObject"
},
"first": {
"type": "boolean"
},
"last": {
"type": "boolean"
},
"numberOfElements": {
"type": "integer",
Expand All @@ -406,4 +388,4 @@
}
}
}
}
}
Loading

0 comments on commit 2dc72a2

Please sign in to comment.