question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support definition of Schema property order

See original GitHub issue

There 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:

  1. Ordering when inheritance is involved, should align with common behavior of existing serialization frameworks (suggestions below)
    1. Parent fields with order specified (excluding any fields that the child explicitly provides order for)
    2. Child fields with order specified
    3. Parent fields without order specified
    4. Child fields without order specified
  2. Clarity around precedence of ordering. The model reader’s ordering and the static file would supersede any ordering defined in annotations
  3. Potential mp.openapi configuration option to override ordering

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:24 (24 by maintainers)

github_iconTop GitHub Comments

1reaction
MikeEdgarcommented, Apr 14, 2020

What are the group’s thoughts on placing the new @Order annotation in the org.eclipse.microprofile.openapi.annotations package (rather than in media) to allow for re-use with other items (e.g. ordering of parameters or other things we haven’t though of) in the future?

1reaction
MikeEdgarcommented, Jul 25, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found