-
Notifications
You must be signed in to change notification settings - Fork 21
add flag to preserve ordering of proto fields in openapi spec schema #11
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
Comments
This is a good idea, but this actually appears to be an issue with how jsonschema structures things. Maps don't guarantee order, especially in Go, but there's a further issue where I'm not sure if the order would be maintained in tools that ingest this openapi spec. It looks like there may be a convention to add a field that defines the order, usually with an See here for more information: json-schema-org/json-schema-vocabularies#7 |
thanks for getting back so quickly. original gnostic project was able to preserve the ordering from my experience. from some digging found this old thread. the tool im using to render the spec follows ordering defined in the spec as well. sidenote great project. requires like no proto annotations to get this going and works seamlessly with server reflection. and love the base openapi spec idea. really simplifies things. |
@gtshepard thanks for the praise! I'm considering switching to https://pb33f.io/libopenapi/openapi/, which will give ordered maps for pretty much everything so it should be possible to maintain the order declared in the protobuf file. This will be a large undertaking though so I don't promise that it will be done soon :) I already made some good progress on it though, so let's see how it goes |
@gtshepard I've made a new release that has a new openapi/json schema library which has the behavior that you want here. Cheers! |
wow amazing! thank you |
Uh oh!
There was an error while loading. Please reload this page.
Requesting flag to preserve ordering of proto fields in openapi spec schema
forcing lexicographical ordering of fields is undesirable in settings where controlling the order of properties is useful.
like readability of documentation page that renders the openapi spec. original gnostic project preserves this ordering.
Example
proto message fields are not in lexicographical order
will result in an openapi schema where the fields are in lexicographical order
which is causing json documentation page to render like this
expected it to follow ordering of proto fields like this
The text was updated successfully, but these errors were encountered: