Skip to content

Commit 5b9643f

Browse files
author
Marcin Zarebski
committed
Add descriptions to org.springdoc.core.converters.Pageable fields
1 parent 2496dc1 commit 5b9643f

File tree

4 files changed

+45
-20
lines changed

4 files changed

+45
-20
lines changed

springdoc-openapi-data-rest/src/main/java/org/springdoc/core/converters/Pageable.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
package org.springdoc.core.converters;
2020

21+
import io.swagger.v3.oas.annotations.media.ArraySchema;
22+
import io.swagger.v3.oas.annotations.media.Schema;
2123
import org.springframework.lang.Nullable;
2224

2325
import javax.validation.constraints.Max;
@@ -31,14 +33,18 @@ public class Pageable {
3133

3234
@Nullable
3335
@Min(0)
36+
@Schema(description = "Zero-based page index (0..N)", defaultValue = "0")
3437
private Integer page;
3538

3639
@Nullable
3740
@Min(1)
3841
@Max(2000)
42+
@Schema(description = "The size of the page to be returned", defaultValue = "20")
3943
private Integer size;
4044

4145
@Nullable
46+
@ArraySchema(arraySchema = @Schema(description = "Sorting criteria in the format: property(,asc|desc). "
47+
+ "Default sort order is ascending. " + "Multiple sort criteria are supported."))
4248
private List<String> sort;
4349

4450
public Pageable(int page, int size, List<String> sort) {
@@ -47,19 +53,19 @@ public Pageable(int page, int size, List<String> sort) {
4753
this.sort = sort;
4854
}
4955

50-
public int getPage() {
56+
public Integer getPage() {
5157
return page;
5258
}
5359

54-
public void setPage(int page) {
60+
public void setPage(Integer page) {
5561
this.page = page;
5662
}
5763

58-
public int getSize() {
64+
public Integer getSize() {
5965
return size;
6066
}
6167

62-
public void setSize(int size) {
68+
public void setSize(Integer size) {
6369
this.size = size;
6470
}
6571

@@ -68,10 +74,11 @@ public List<String> getSort() {
6874
}
6975

7076
public void setSort(List<String> sort) {
71-
if (sort == null)
77+
if (sort == null) {
7278
this.sort.clear();
73-
else
79+
} else {
7480
this.sort = sort;
81+
}
7582
}
7683

7784
public void addSort(String sort) {
@@ -80,11 +87,15 @@ public void addSort(String sort) {
8087

8188
@Override
8289
public boolean equals(Object o) {
83-
if (this == o) return true;
84-
if (o == null || getClass() != o.getClass()) return false;
90+
if (this == o) {
91+
return true;
92+
}
93+
if (o == null || getClass() != o.getClass()) {
94+
return false;
95+
}
8596
Pageable pageable = (Pageable) o;
86-
return page == pageable.page &&
87-
size == pageable.size &&
97+
return Objects.equals(page, pageable.page) &&
98+
Objects.equals(size, pageable.size) &&
8899
Objects.equals(sort, pageable.sort);
89100
}
90101

springdoc-openapi-data-rest/src/main/java/org/springdoc/core/converters/PageableAsQueryParam.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,22 @@
1818

1919
package org.springdoc.core.converters;
2020

21-
import java.lang.annotation.ElementType;
22-
import java.lang.annotation.Retention;
23-
import java.lang.annotation.RetentionPolicy;
24-
import java.lang.annotation.Target;
25-
2621
import io.swagger.v3.oas.annotations.Parameter;
2722
import io.swagger.v3.oas.annotations.enums.ParameterIn;
2823
import io.swagger.v3.oas.annotations.media.ArraySchema;
2924
import io.swagger.v3.oas.annotations.media.Content;
3025
import io.swagger.v3.oas.annotations.media.Schema;
3126

27+
import java.lang.annotation.ElementType;
28+
import java.lang.annotation.Retention;
29+
import java.lang.annotation.RetentionPolicy;
30+
import java.lang.annotation.Target;
31+
32+
/**
33+
* @deprecated Use {@link org.springdoc.api.annotations.ParameterObject} annotation
34+
* on {@link org.springframework.data.domain.Pageable} method parameter instead.
35+
*/
36+
@Deprecated
3237
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
3338
@Retention(RetentionPolicy.RUNTIME)
3439
@Parameter(in = ParameterIn.QUERY

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,21 @@
6161
"page": {
6262
"minimum": 0,
6363
"type": "integer",
64-
"format": "int32"
64+
"description": "Zero-based page index (0..N)",
65+
"format": "int32",
66+
"default": 0
6567
},
6668
"size": {
6769
"maximum": 2000,
6870
"minimum": 1,
6971
"type": "integer",
70-
"format": "int32"
72+
"description": "The size of the page to be returned",
73+
"format": "int32",
74+
"default": 20
7175
},
7276
"sort": {
7377
"type": "array",
78+
"description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
7479
"items": {
7580
"type": "string"
7681
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,22 @@
2525
"schema": {
2626
"minimum": 0,
2727
"type": "integer",
28-
"format": "int32"
28+
"description": "Zero-based page index (0..N)",
29+
"format": "int32",
30+
"default": 0
2931
}
3032
},
3133
{
3234
"name": "size",
3335
"in": "query",
3436
"required": false,
3537
"schema": {
36-
"default": 20,
3738
"maximum": 2000,
3839
"minimum": 1,
3940
"type": "integer",
40-
"format": "int32"
41+
"description": "The size of the page to be returned",
42+
"format": "int32",
43+
"default": 20
4144
}
4245
},
4346
{
@@ -46,6 +49,7 @@
4649
"required": false,
4750
"schema": {
4851
"type": "array",
52+
"description": "Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported.",
4953
"items": {
5054
"type": "string"
5155
}

0 commit comments

Comments
 (0)