fix: sort openapi type schema#4239
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4239 +/- ##
=======================================
Coverage 98.38% 98.38%
=======================================
Files 348 348
Lines 15895 15895
Branches 1756 1756
=======================================
Hits 15638 15638
Misses 121 121
Partials 136 136 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@provinzkraut any chance you could take a look at this as you responded to the initial issue? Sorry for the tag! |
provinzkraut
left a comment
There was a problem hiding this comment.
Looks good. I like the idea you suggested of using oneOf instead though. Would you want to give implementing that a try as well?
|
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4239 |
|
Thanks! I'll take a look and see if it's straightforward. |
|
After some digging, this seems like it was explicit behavior added here. I'm not quite clear on what the ramifications of changing this back would be; however, in my testing I did note that I might leave this alone to prevent causing a regression to someone else! 😅 |
Description
Literal[*] | NoneConsider the following OpenAPI schema type:
{'type': ['null', 'string'], 'enum': ['1', None]}Currently, there are scenarios (with environmental differences) in which this can instead be rendered as:
{'type': ['string', 'null'], 'enum': ['1', None]}This can cause issues with continuous integration in monorepos where generated openapi json is checked into the source tree and validated for changes.
Another discussion that this might spawn is why this is not in the OAPI 3.0
oneOfformat instead -{'oneOf': [{'type': 'string', 'const': '1'}, {'type': 'null'}]}This appears to be consistently sorted by something else in Litestar's openapi generation.
Fixes #3646