Skip to content

Commit b88a3e4

Browse files
committed
Serialization to openapi of org.springframework.data.domain.Sort is not done correctly. Fixes #2447
1 parent e893628 commit b88a3e4

File tree

3 files changed

+34
-22
lines changed
  • springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/models
  • springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results

3 files changed

+34
-22
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/models/SortObject.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424
package org.springdoc.core.converters.models;
2525

2626
import com.fasterxml.jackson.annotation.JsonProperty;
27+
import io.swagger.v3.oas.annotations.media.ArraySchema;
28+
import io.swagger.v3.oas.annotations.media.Schema;
2729

2830
/**
2931
* The type Sort response.
3032
* @author bnasslahsen
3133
*/
34+
@ArraySchema(arraySchema = @Schema(implementation = SortObject.class))
3235
public class SortObject {
3336

3437
/**

springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app24.json

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,24 @@
105105
"format": "int32"
106106
},
107107
"sort": {
108-
"$ref": "#/components/schemas/SortObject"
109-
},
110-
"numberOfElements": {
111-
"type": "integer",
112-
"format": "int32"
113-
},
114-
"pageable": {
115-
"$ref": "#/components/schemas/PageableObject"
108+
"type": "array",
109+
"items": {
110+
"$ref": "#/components/schemas/SortObject"
111+
}
116112
},
117113
"first": {
118114
"type": "boolean"
119115
},
120116
"last": {
121117
"type": "boolean"
122118
},
119+
"pageable": {
120+
"$ref": "#/components/schemas/PageableObject"
121+
},
122+
"numberOfElements": {
123+
"type": "integer",
124+
"format": "int32"
125+
},
123126
"empty": {
124127
"type": "boolean"
125128
}
@@ -133,7 +136,16 @@
133136
"format": "int64"
134137
},
135138
"sort": {
136-
"$ref": "#/components/schemas/SortObject"
139+
"type": "array",
140+
"items": {
141+
"$ref": "#/components/schemas/SortObject"
142+
}
143+
},
144+
"paged": {
145+
"type": "boolean"
146+
},
147+
"unpaged": {
148+
"type": "boolean"
137149
},
138150
"pageNumber": {
139151
"type": "integer",
@@ -142,12 +154,6 @@
142154
"pageSize": {
143155
"type": "integer",
144156
"format": "int32"
145-
},
146-
"paged": {
147-
"type": "boolean"
148-
},
149-
"unpaged": {
150-
"type": "boolean"
151157
}
152158
}
153159
},

springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app27.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@
6363
"format": "int64"
6464
},
6565
"sort": {
66-
"$ref": "#/components/schemas/SortObject"
66+
"type": "array",
67+
"items": {
68+
"$ref": "#/components/schemas/SortObject"
69+
}
70+
},
71+
"paged": {
72+
"type": "boolean"
73+
},
74+
"unpaged": {
75+
"type": "boolean"
6776
},
6877
"pageNumber": {
6978
"type": "integer",
@@ -72,12 +81,6 @@
7281
"pageSize": {
7382
"type": "integer",
7483
"format": "int32"
75-
},
76-
"paged": {
77-
"type": "boolean"
78-
},
79-
"unpaged": {
80-
"type": "boolean"
8184
}
8285
}
8386
},

0 commit comments

Comments
 (0)