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

Bug: tags are sorted alphabetically in OpenAPI projection #1603

Closed
cogwirrel opened this issue Feb 6, 2023 · 0 comments · Fixed by #1604
Closed

Bug: tags are sorted alphabetically in OpenAPI projection #1603

cogwirrel opened this issue Feb 6, 2023 · 0 comments · Fixed by #1604

Comments

@cogwirrel
Copy link
Contributor

cogwirrel commented Feb 6, 2023

I've noticed that the order of tags is not preserved from the @tags trait when the model is converted to OpenAPI.

For example, if I have the following model:

@tags(["foo", "bar", "baz"])
operation SayHello {
  ...
}

The generated spec will include:

"tags": ["bar", "baz", "foo"]

Looks like the culprit lines are here:

https://github.com/awslabs/smithy/blob/dc9eb9fa89b3f369b9ea99b1358e0b870039bd71/smithy-openapi/src/main/java/software/amazon/smithy/openapi/model/OpenApi.java#L136

https://github.com/awslabs/smithy/blob/dc9eb9fa89b3f369b9ea99b1358e0b870039bd71/smithy-openapi/src/main/java/software/amazon/smithy/openapi/model/OperationObject.java#L164

It looks like it was sorted as part of this change #45 however the order of tags can matter, for example the openapi code generator can be configured to use only the first tag when generating clients: OpenAPITools/openapi-generator#14465

Please could we preserve the order of tags as specified by users? :)

cogwirrel added a commit to cogwirrel/smithy that referenced this issue Feb 6, 2023
Instead of sorting them lexicographically, preserve the user-specified order of tags.

eg.

`@tags(["one", "two", "three", "four"])`

becomes:

`"tags": ["one", "two", "three", "four"]`

instead of:

`"tags": ["four", "one", "three", "two"]`

fix smithy-lang#1603
sugmanue pushed a commit that referenced this issue Feb 14, 2023
Instead of sorting them lexicographically, preserve the user-specified order of tags.

eg.

`@tags(["one", "two", "three", "four"])`

becomes:

`"tags": ["one", "two", "three", "four"]`

instead of:

`"tags": ["four", "one", "three", "two"]`

fix #1603
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 a pull request may close this issue.

1 participant