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: order of types in openapi spec is not consistent in json rendering #3646

Open
4 tasks
atom-andrew opened this issue Jul 25, 2024 · 2 comments
Open
4 tasks
Labels
Bug 🐛 This is something that is not working as expected OpenAPI This is related to our OpenAPI schema

Comments

@atom-andrew
Copy link

atom-andrew commented Jul 25, 2024

Description

We are seeing the order of types change in openapi generation, which makes comparing golden versions of the openapi spec problematic. I think the specific problem we are seeing comes from

schema_types = list(set(schema_types))
where we use the set operation to uniquify the list of types. The order doesn't matter to the correctness of the openapi spec, so perhaps the responsibility for ensuring a determistic spec file could also come from the serializer, but either way it would be helpful if we could always render the same openapi spec the same way.

URL to code causing the issue

No response

MCVE

# Your MCVE code here

Steps to reproduce

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

No response

Logs

No response

Litestar Version

2.9.1

Platform

  • Linux
  • Mac
  • Windows
  • Other (Please specify in the description above)

Note

While we are open for sponsoring on GitHub Sponsors and
OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.
Fund with Polar
@atom-andrew atom-andrew added the Bug 🐛 This is something that is not working as expected label Jul 25, 2024
@provinzkraut
Copy link
Member

Having this be consistent makes sense to me. There are 2 ways to fix this: Either sort the items after they have been deduplicated, or remove the usage of a set entirely. Sorting is easier, but not using a set to begin with gives us the opportunity to preserve order, which, while not necessary, could be a bit nicer to work with.

@atom-andrew Since you've already figured out what the issue is, would you be interested in submitting a PR with a fix? :)

@atom-andrew
Copy link
Author

@provinzkraut I'm happy to submit a PR but it wasn't obvious to me where this would be tested. Can you give me a tip about where it would make sense to include a test for this? Thanks.

@JacobCoffee JacobCoffee added the OpenAPI This is related to our OpenAPI schema label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐛 This is something that is not working as expected OpenAPI This is related to our OpenAPI schema
Projects
None yet
Development

No branches or pull requests

3 participants