-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
[JAVA-SPRING;KOTLIN-SPRING] bugfix - PagedModel<T> - default to custom DTO; allow override via import mapping and schema mapping #23599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Picazsoo
wants to merge
8
commits into
OpenAPITools:master
from
Picazsoo:bugfix/pagedModel-use-import-mapping-and-schema-mapping
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f7c827a
fix(spring): ensure PagedModel uses mapped FQN for item type in code …
Picazsoo 42bd4e1
fix(spring): generate supporting PagedModel files in config package (…
Picazsoo 5780ef7
update samples
Picazsoo 2267cbb
Merge branch 'master' into bugfix/pagedModel-use-import-mapping-and-s…
Picazsoo c837967
update documentation
Picazsoo 7de158b
update documentation
Picazsoo 93bc67a
implement feedback from CR
Picazsoo cc5d628
Merge branch 'master' into bugfix/pagedModel-use-import-mapping-and-s…
Picazsoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
modules/openapi-generator/src/main/resources/JavaSpring/pagedModel.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| package {{configPackage}}; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Simple generic paged response wrapper generated by openapi-generator. | ||
| * | ||
| * <p>Holds a page of content items and pagination metadata. Jackson deserializes this from the | ||
| * standard Spring {@code Page} JSON shape: | ||
| * <pre> | ||
| * { | ||
| * "content": [...], | ||
| * "page": { "size": 20, "totalElements": 100, "totalPages": 5, "number": 0 } | ||
| * } | ||
| * </pre> | ||
| * | ||
| * <p>To use your own class instead, set {@code importMappings.PagedModel} in the generator config. | ||
| */ | ||
| public class PagedModel<T> { | ||
|
|
||
| private List<T> content; | ||
| private PageMetadata page; | ||
|
|
||
| public PagedModel() {} | ||
|
|
||
| public PagedModel(List<T> content, PageMetadata page) { | ||
| this.content = content; | ||
| this.page = page; | ||
| } | ||
|
|
||
| public List<T> getContent() { | ||
| return content; | ||
| } | ||
|
|
||
| public void setContent(List<T> content) { | ||
| this.content = content; | ||
| } | ||
|
|
||
| public PageMetadata getPage() { | ||
| return page; | ||
| } | ||
|
|
||
| public void setPage(PageMetadata page) { | ||
| this.page = page; | ||
| } | ||
|
|
||
| public static class PageMetadata { | ||
|
|
||
| private long size; | ||
| private long totalElements; | ||
| private long totalPages; | ||
| private long number; | ||
|
|
||
| public PageMetadata() {} | ||
|
|
||
| public PageMetadata(long size, long totalElements, long totalPages, long number) { | ||
| this.size = size; | ||
| this.totalElements = totalElements; | ||
| this.totalPages = totalPages; | ||
| this.number = number; | ||
| } | ||
|
|
||
| public long getSize() { | ||
| return size; | ||
| } | ||
|
|
||
| public void setSize(long size) { | ||
| this.size = size; | ||
| } | ||
|
|
||
| public long getTotalElements() { | ||
| return totalElements; | ||
| } | ||
|
|
||
| public void setTotalElements(long totalElements) { | ||
| this.totalElements = totalElements; | ||
| } | ||
|
|
||
| public long getTotalPages() { | ||
| return totalPages; | ||
| } | ||
|
|
||
| public void setTotalPages(long totalPages) { | ||
| this.totalPages = totalPages; | ||
| } | ||
|
|
||
| public long getNumber() { | ||
| return number; | ||
| } | ||
|
|
||
| public void setNumber(long number) { | ||
| this.number = number; | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.