Skip to content

Commit 7439ae6

Browse files
committed
Add support for paginated return types in Spring code generation
1 parent 8a4246c commit 7439ae6

3 files changed

Lines changed: 137 additions & 40 deletions

File tree

docs/generators/spring.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
6868
|modelPackage|package for generated models| |org.openapitools.model|
6969
|openApiNullable|Enable OpenAPI Jackson Nullable library. Not supported by `microprofile` library.| |true|
7070
|optionalAcceptNullable|Use `ofNullable` instead of just `of` to accept null values when using Optional.| |true|
71+
|paginatedReturnType|Set container type to use for collection responses when the operation has vendor extension `x-spring-paginated`. Applies only to collection responses.|<dl><dt>**LIST**</dt><dd>Keep using `java.util.List` for collection responses (default).</dd><dt>**SLICE**</dt><dd>Use `org.springframework.data.domain.Slice` for collection responses when `x-spring-paginated` is enabled.</dd><dt>**PAGE**</dt><dd>Use `org.springframework.data.domain.Page` for collection responses when `x-spring-paginated` is enabled.</dd></dl>|LIST|
7172
|parentArtifactId|parent artifactId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
7273
|parentGroupId|parent groupId in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
7374
|parentVersion|parent version in generated pom N.B. parentGroupId, parentArtifactId and parentVersion must all be specified for any of them to take effect| |null|
@@ -112,24 +113,24 @@ These options may be applied as additional-properties (cli) or configOptions (pl
112113

113114
## SUPPORTED VENDOR EXTENSIONS
114115

115-
| Extension name | Description | Applicable for | Default value |
116-
| -------------- | ----------- | -------------- | ------------- |
117-
|x-discriminator-value|Used with model inheritance to specify value for discriminator that identifies current model|MODEL|
118-
|x-implements|Ability to specify interfaces that model must implements|MODEL|empty array
119-
|x-setter-extra-annotation|Custom annotation that can be specified over java setter for specific field|FIELD|When field is array & uniqueItems, then this extension is used to add `@JsonDeserialize(as = LinkedHashSet.class)` over setter, otherwise no value
120-
|x-tags|Specify multiple swagger tags for operation|OPERATION|null
121-
|x-accepts|Specify custom value for 'Accept' header for operation|OPERATION|null
122-
|x-content-type|Specify custom value for 'Content-Type' header for operation|OPERATION|null
123-
|x-class-extra-annotation|List of custom annotations to be added to model|MODEL|null
124-
|x-field-extra-annotation|List of custom annotations to be added to property|FIELD, OPERATION_PARAMETER|null
125-
|x-operation-extra-annotation|List of custom annotations to be added to operation|OPERATION|null
126-
|x-spring-paginated|Add `org.springframework.data.domain.Pageable` to controller method. Can be used to handle `page`, `size` and `sort` query parameters. If these query parameters are also specified in the operation spec, they will be removed from the controller method as their values can be obtained from the `Pageable` object.|OPERATION|false
127-
|x-version-param|Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false|OPERATION_PARAMETER|null
128-
|x-pattern-message|Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable|FIELD, OPERATION_PARAMETER|null
129-
|x-size-message|Add this property whenever you need to customize the invalidation error message for the size or length of a variable|FIELD, OPERATION_PARAMETER|null
130-
|x-minimum-message|Add this property whenever you need to customize the invalidation error message for the minimum value of a variable|FIELD, OPERATION_PARAMETER|null
131-
|x-maximum-message|Add this property whenever you need to customize the invalidation error message for the maximum value of a variable|FIELD, OPERATION_PARAMETER|null
132-
|x-spring-api-version|Value for 'version' attribute in @RequestMapping (for Spring 7 and above).|OPERATION|null
116+
| Extension name | Description | Applicable for | Default value |
117+
| -------------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -------------- | ------------- |
118+
|x-discriminator-value| Used with model inheritance to specify value for discriminator that identifies current model |MODEL|
119+
|x-implements| Ability to specify interfaces that model must implements |MODEL|empty array
120+
|x-setter-extra-annotation| Custom annotation that can be specified over java setter for specific field |FIELD|When field is array & uniqueItems, then this extension is used to add `@JsonDeserialize(as = LinkedHashSet.class)` over setter, otherwise no value
121+
|x-tags| Specify multiple swagger tags for operation |OPERATION|null
122+
|x-accepts| Specify custom value for 'Accept' header for operation |OPERATION|null
123+
|x-content-type| Specify custom value for 'Content-Type' header for operation |OPERATION|null
124+
|x-class-extra-annotation| List of custom annotations to be added to model |MODEL|null
125+
|x-field-extra-annotation| List of custom annotations to be added to property |FIELD, OPERATION_PARAMETER|null
126+
|x-operation-extra-annotation| List of custom annotations to be added to operation |OPERATION|null
127+
|x-spring-paginated| Add `org.springframework.data.domain.Pageable` to controller method. Can be used to handle `page`, `size` and `sort` query parameters. If these query parameters are also specified in the operation spec, they will be removed from the controller method as their values can be obtained from the `Pageable` object. Can be modified with paginatedReturnType configOption |OPERATION|false
128+
|x-version-param| Marker property that tells that this parameter would be used for endpoint versioning. Applicable for headers & query params. true/false |OPERATION_PARAMETER|null
129+
|x-pattern-message| Add this property whenever you need to customize the invalidation error message for the regex pattern of a variable |FIELD, OPERATION_PARAMETER|null
130+
|x-size-message| Add this property whenever you need to customize the invalidation error message for the size or length of a variable |FIELD, OPERATION_PARAMETER|null
131+
|x-minimum-message| Add this property whenever you need to customize the invalidation error message for the minimum value of a variable |FIELD, OPERATION_PARAMETER|null
132+
|x-maximum-message| Add this property whenever you need to customize the invalidation error message for the maximum value of a variable |FIELD, OPERATION_PARAMETER|null
133+
|x-spring-api-version| Value for 'version' attribute in @RequestMapping (for Spring 7 and above). |OPERATION|null
133134

134135

135136
## IMPORT MAPPING

0 commit comments

Comments
 (0)