Skip to content
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

Order of properties in class not maintained #314

Closed
marceloverdijk opened this issue Apr 29, 2020 · 7 comments
Closed

Order of properties in class not maintained #314

marceloverdijk opened this issue Apr 29, 2020 · 7 comments
Labels
duplicate This issue or pull request already exists

Comments

@marceloverdijk
Copy link

Especially with a code first approach I would assume the order of the properties as defined in a class will be maintained in the generated schema.

But instead the properties in the generated schema are alphabetically.

I tried configuring the order strategy in the JsonbConfig of my Quarkus app but Jsonb seems not to have an option to keep the order of the properties in the class, unlike e.g. Jackson supports this.

I also tried switching to quarkus-resteasy-jackson (instead of jsonb) and the actual JSON output is ordered as in the class, but the generated openapi schema the properties are still ordered alphabetically.

@phillip-kruger
Copy link
Member

Will this help: eclipse/microprofile-open-api#359 ?

@marceloverdijk
Copy link
Author

Yes exactly that.
I read your comment about the @Order annotation and keeping in sync.

You mean with this keeping the order in the generated openapi doc the same as in actual json output?
So this would be an annotation used by both Jsonb and MP openapi?

@MikeEdgar
Copy link
Member

It would be OpenAPI only. Please try JsonbPropertyOrder on your POJO.

@MikeEdgar
Copy link
Member

I say that mainly because @Order won't be available for a while yet.

@marceloverdijk
Copy link
Author

Yes, @JsonbPropertyOrder is picked up both in the generated openapi schema and the actual json output of the service.

It's unfortunate Jsonb doesn't support a natural sorting option that can be set globally.
Anyway it does the trick for now. Thx.

@marceloverdijk
Copy link
Author

PS: Created this issue in the Jsonb spec project to introduce a global NATURAL support option. Probably a long shot...

@MikeEdgar
Copy link
Member

Thanks @marceloverdijk. I am going to go ahead and close this as the root cause is the same as #87. Please feel free to re-open if you feel differently, etc.

@MikeEdgar MikeEdgar added the duplicate This issue or pull request already exists label May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants