Fix #23933: Added @JsonPropertyOrder annotation to Spring Boot generator#23957
Fix #23933: Added @JsonPropertyOrder annotation to Spring Boot generator#23957thesauravpoddar wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
No issues found across 1598 files
Note: This PR contains a large number of files. cubic only reviews up to 100 files per PR, so some files may not have been reviewed. cubic prioritizes the most important files to review.
On a pro plan you can use ultrareview for larger PRs.
Re-trigger cubic
|
HI! @Zomzo can you please look at the pull request |
|
thanks for the pr please resolve the merge conflicts when you've time. cc @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08) |
|
@cubic-dev-ai ultrareview |
@thesauravpoddar Ultrareview is only available on the Pro plan. Upgrade here to get access. |
This PR adds the @JsonPropertyOrder annotation to Spring Boot generator to fix the problem that Jackson 3 by default sorts properties alphabetically instead of following the logical order of the generated classes. It ensures that JSON properties are serialized in the logical order defined in the OpenAPI specification, while correctly excluding
enum modelsfrom the class-level annotation. I addes proper import for@JsonPropertyOrder annotation.Updated the
POJO.mustachefor spring boot with@JsonPropertyOrder annotationand updated theAbstractJavaCodegenwith adding import statement of@JsonPropertyOrder annotationunder methodprocessOpts.And updated the
SpringCodegenclass in which i updated the methodpostProcessModelProperty.Then finally adding test code for this in 'SpringCodegenTest.java' class
cc @Zomzog @martin-mfg @cachescrubber @welshm
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Add
@JsonPropertyOrderto generated Spring Boot models so JSON follows the OpenAPI field order instead of Jackson 3’s alphabetical sort. Enum models are excluded from the class-level annotation.Bug Fixes
JsonPropertyOrderimport mapping inAbstractJavaCodegen.pojo.mustacheto apply@JsonPropertyOrderand emitJSON_PROPERTY_*constants.SpringCodegento importJsonPropertyOrderfor non-enum models only.SpringCodegenTestand regenerated Spring sample models.Migration
Written for commit 465a7af. Summary will update on new commits.