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] Incorrect openapi schema when using serialization_alias #1328

Open
enadeau opened this issue Nov 1, 2024 · 0 comments
Open

[BUG] Incorrect openapi schema when using serialization_alias #1328

enadeau opened this issue Nov 1, 2024 · 0 comments

Comments

@enadeau
Copy link

enadeau commented Nov 1, 2024

Describe the bug
When using serialization_alias on Field the alias is correctly used in the response (with the by_alias flag) but not used for the openapi schema.

Here is a short example:

class MySchema(ninja.Schema):
    foo: str = ninja.Field(..., alias="alias1")
    bar: str = ninja.Field(..., serialization_alias="alias2")


@router.get("foo", response=MySchema, by_alias=True)
def foo(request) -> MySchema:
    return {
        "alias1": "lalala",
        "bar": "bububub",
    }

Here we see that the response contains the alias1 and alias2 field while the schema contains the says that the fields are alias 1 and bar
image

Versions (please complete the following information):

  • Python version: 3.9.17
  • Django version: 3.2.25
  • Django-Ninja version: 1.3.0
  • Pydantic version: 2.9.2
@enadeau enadeau changed the title [BUG] Incorrect openapi schema when using [BUG] Incorrect openapi schema when using serialization_alias Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant