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] Adding Field examples breaks generated swagger docs #1305

Open
boosh opened this issue Sep 27, 2024 · 0 comments
Open

[BUG] Adding Field examples breaks generated swagger docs #1305

boosh opened this issue Sep 27, 2024 · 0 comments

Comments

@boosh
Copy link

boosh commented Sep 27, 2024

Describe the bug
Using the approach described in #1115 to add a description of a parameter, the generated swagger docs break when the example= property is added. The generated API docs show Could not render Parameters, see the console.

Versions (please complete the following information):

  • Python version: 3.11.6
  • Django version: 5.1
  • Django-Ninja version: 1.3.0
  • Pydantic version: 2.9.2

Example:

from datetime import datetime, timezone
from typing import Annotated
from typing import List

from ninja import Router, Query, Schema, Field

router = Router()

class FilterParams(Schema):
    end: Annotated[
        datetime,
        Field(
            examples=[datetime.now(timezone.utc)],       # fails when this line is uncommented
            description="ISO-formatted timestamp of the latest item to return",
        ),
    ]

@router.get(
    "",
    url_name="list",
    response=List[MySchemaOut],
)
def my_list(request, filters: Query[FilterParams]):
    pass
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