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: Pydantic json_schema_extra fields aren't all merged #3722

Closed
1 of 4 tasks
provinzkraut opened this issue Sep 8, 2024 · 0 comments · Fixed by #3721
Closed
1 of 4 tasks

Bug: Pydantic json_schema_extra fields aren't all merged #3722

provinzkraut opened this issue Sep 8, 2024 · 0 comments · Fixed by #3721
Labels
Bug 🐛 This is something that is not working as expected

Comments

@provinzkraut
Copy link
Member

provinzkraut commented Sep 8, 2024

Description

When defining schema overrides on a Pydantic model via json_schema_extra, not all of them are applied to the generated schema

MCVE

import pydantic

from litestar import Litestar, get


class Model(pydantic.BaseModel):
    with_title: str = pydantic.Field(title="WITH_title")
    with_extra_title: str = pydantic.Field(json_schema_extra={"title": "WITH_extra"})


@get("/example")
async def example_route() -> Model:
    return Model(with_title="1", with_extra_title="2")


app = Litestar([example_route])
schema = app.openapi_schema.to_schema()
props = schema["components"]["schemas"]["Model"]["properties"]

assert props["with_title"] == {"title": "WITH_title", "type": "string"}
assert props["with_extra_title"] == {"title": "WITH_extra", "type": "string"}

Litestar Version

2.11

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
@provinzkraut provinzkraut added the Bug 🐛 This is something that is not working as expected label Sep 8, 2024
@github-project-automation github-project-automation bot moved this to Triage in Overview Sep 8, 2024
provinzkraut added a commit that referenced this issue Sep 8, 2024
provinzkraut added a commit that referenced this issue Sep 14, 2024
provinzkraut added a commit that referenced this issue Sep 15, 2024
provinzkraut added a commit that referenced this issue Sep 15, 2024
@github-project-automation github-project-automation bot moved this from Triage to Closed in Overview Sep 15, 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
Projects
Status: Closed
Development

Successfully merging a pull request may close this issue.

1 participant