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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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 (6225a82) to head (b94e700).
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       15845    15847    +2     
  Branches     1749     1750    +1     
=======================================
+ Hits        15587    15589    +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.

Copy link

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 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
1 participant