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] Field examples not showing in OpenAPI docs #1342

Open
Zerotask opened this issue Nov 21, 2024 · 0 comments
Open

[BUG] Field examples not showing in OpenAPI docs #1342

Zerotask opened this issue Nov 21, 2024 · 0 comments

Comments

@Zerotask
Copy link
Contributor

Zerotask commented Nov 21, 2024

Describe the bug

Example:

class OrganizationPostSchema(Schema):
    email: EmailStr | None = Field(default=None, examples=["[email protected]"])

it does not show in the generated OpenAPI docs.
Although I noticed that you can pass it as:

class OrganizationPostSchema(Schema):
    email: EmailStr | None = Field(default=None, example="[email protected]")

This will show it like this:
image

But example is not a valid parameter for Pydantic's Field class.
Therefore the IDE and mypy will show it as an error.

Versions (please complete the following information):

  • Python version: 3.12
  • Django version: 5.0.x
  • Django-Ninja version: 1.3.0
  • Pydantic version: 2.10.0

The preferred solution would be to display examples the same way as you do currently with example

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