smallrye-open-api: Don't automatically sort object fields
I wondered why my OpenAPI file under Thorntail didn’t look like I expected it to.
Classes under components.schemas always have sorted fields instead of their original order in the Java class.
I think it’s because you are using ClassInfo from Jandex internally to get the field info. Unfortunately ClassInfo does automatic field sorting: https://github.com/wildfly/jandex/blob/61d1115e0a0f15dcfb2b0bbd082100f847963529/src/main/java/org/jboss/jandex/ClassInfo.java#L557
There seems to be no option to disable this behavior. Neither in this implementation, nor in Jandex ClassInfo. I suggest not to alter the property order or at least make it optional (default: false). Thanks 😃
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 21 (15 by maintainers)
I’m all for pushing ideas up to the MP spec level to resolve, but let’s not wait on that ceremony to include changes into the implementation
Bringing this one up at the spec level seems the ideal solution to me. We should figure out the specific morphology over there (perhaps you can join us @MikeEdgar ?), but this isn’t a bad suggestion.
Side node: I’m generally against adding options unless we figure we really need them; it’s just going to become a maintenance and documentation pain in the long term (and eventual fun of conflicting options, and such).
(2) also seems a great idea to me, and that could be done regardless.
As you proposed, I created a PR over at Jandex: https://github.com/wildfly/jandex/pull/61
If that gets merged and you don’t want to add annotation driven control for sorting, this issue could be solved by changing one or two lines:
indexer.index(contentStream, true, false);Otherwise implementation could become a bit messy, because we’d need to read annotations before the indexer reads the class stream.