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

add preserveOrder option to avoid sorting keys #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bobvanderlinden
Copy link
Contributor

@bobvanderlinden bobvanderlinden commented Jan 31, 2022

Currently swagger-converter sorts all keys to make sure the output is
deterministic. In some cases, the order of properties matters.

For instance a model that understandably mentions id and name first. For
code generation and example generation it helps to keep these properties
first.

preserveOrder: true may help in these cases.

The current setup for tests was not really made for potentially non-deterministic outputs (which preserveOrder could result in). I left out the test for now, let me know what the best course of action is for this, or whether it should be left ignored.

Currently swagger-converter sorts all keys to make sure the output is
deterministic. In some cases, the order of properties matters.

For instance a model that understandably mentions id and name first. For
code generation and example generation it helps to keep these properties
first.

`preserveOrder: true` may help in these cases.
@IvanGoncharov
Copy link
Collaborator

@bobvanderlinden Sorry for the super late response.
But can we just add code that always puts id and name first?
I think it universally useful feature so why hide it behind the flag?
More properties can be added in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants