Skip to content

fix(openapi): support prefixItems for tuple schema #4132

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

Merged
merged 3 commits into from
May 1, 2025

Conversation

Jannchie
Copy link
Contributor

The previous implementation incorrectly treated Python tuples as arrays with items of a single, uniform type.

This change utilizes prefixItems (OpenAPI 3.1+) to correctly specify the type for each element at its specific position when the field is a tuple. This results in a more accurate and modern OpenAPI schema that precisely reflects the Python tuple structure.

Additionally:

  • Adjusted assertions in test_schema_tuple_with_union as the original expectations seemed incorrect with the proper schema generation.
  • Added a new test case test_schema_tuple.

@Jannchie Jannchie requested review from a team as code owners April 20, 2025 04:35
@github-actions github-actions bot added area/private-api This PR involves changes to the privatized API size: small type/bug pr/external Triage Required 🏥 This requires triage labels Apr 20, 2025
Copy link

codecov bot commented Apr 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.37%. Comparing base (6129482) to head (194a6ab).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4132   +/-   ##
=======================================
  Coverage   98.37%   98.37%           
=======================================
  Files         348      348           
  Lines       15857    15859    +2     
  Branches     1751     1752    +1     
=======================================
+ Hits        15599    15601    +2     
  Misses        123      123           
  Partials      135      135           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@provinzkraut provinzkraut enabled auto-merge (squash) May 1, 2025 08:36
@provinzkraut provinzkraut merged commit af1af6b into litestar-org:main May 1, 2025
28 checks passed
Copy link

github-actions bot commented May 1, 2025

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/4132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/private-api This PR involves changes to the privatized API pr/external pr/internal size: small Triage Required 🏥 This requires triage type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: OpenAPI Schema Generation Incorrect for Tuple Type Hint
2 participants