Support definition of Schema property order
See original GitHub issueThere has been some discussion in smallrye/smallrye-open-api#87 around ways for a user of MP-OAI to define the order of properties read during annotation/class scanning. Although maybe not technically significant for formats like JSON and YAML, predicable order does help with readability and may be significant for formats like XML.
Several annotations are in common use today by the various serialization frameworks that could be looked at for an idea of how to implement the same option in MP-OAI
javax.json.bind.annotation.JsonbPropertyOrder
javax.xml.bind.annotation.XmlType#propOrder
com.fasterxml.jackson.annotation.JsonPropertyOrder
One possible option is to define a new String[] propertyOrder
attribute in @Schema
that behaves similarly to the three format-specific annotations listed above.
Other things to consider:
- Ordering when inheritance is involved, should align with common behavior of existing serialization frameworks (suggestions below)
- Parent fields with order specified (excluding any fields that the child explicitly provides order for)
- Child fields with order specified
- Parent fields without order specified
- Child fields without order specified
- Clarity around precedence of ordering. The model reader’s ordering and the static file would supersede any ordering defined in annotations
- Potential
mp.openapi
configuration option to override ordering
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:24 (24 by maintainers)
Top Results From Across the Web
Order - Schema.org Type
Property Expected Type Description
billingAddress PostalAddress The billing address for the order.
customer Organization or. Person Party placing the order or paying the invoice.
discount Number...
Read more >object — Understanding JSON Schema 2020-12 documentation
The value of properties is an object, where each key is the name of a property and each value is a schema used...
Read more >Resource type schema - CloudFormation Command Line ...
This meta-schema provides a means of validating your resource specification ... Contains properties that specify the resource type's support for tags.
Read more >Schema Definition Properties - Software AG Documentation
Property. Description ; Ordered. Specifies whether records must appear in the flat file in the same order in which they appear in a...
Read more >OpenAPI Specification - Version 3.0.3 - Swagger
However, to support documentation needs, the format property is an open string ... by a format property follow the type definition in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What are the group’s thoughts on placing the new
@Order
annotation in theorg.eclipse.microprofile.openapi.annotations
package (rather than inmedia
) to allow for re-use with other items (e.g. ordering of parameters or other things we haven’t though of) in the future?I’m in agreement about not re-using the solution to #360. It might take some time to determine a good approach there and I think whatever solution we come up with will probably be too verbose for here.