django-ninja icon indicating copy to clipboard operation
django-ninja copied to clipboard

Possibility to provide custom examples for schemas

Open roma-glushko opened this issue 3 years ago • 1 comments

Hi folks,

FastAPI leverages Pydantic possibility to generate OpenAPI schema which besides other stuff also includes generation of the custom examples:

  • https://fastapi.tiangolo.com/tutorial/schema-extra-example/#pydantic-schema_extra
  • https://pydantic-docs.helpmanual.io/usage/schema/#schema-customization

Is this possible to have the same custom examples with Django Ninja? I could not get it work easily :(

UPD: I can see that openapi.json file contains all needed information about examples, so it seems like Swagger UI/layout thing that doesn't show examples

roma-glushko avatar Dec 26 '21 11:12 roma-glushko

@roma-glushko

well it work for me on default settings:

CleanShot 2022-01-31 at 12 48 59

which version for django/django-ninja do you use ?

vitalik avatar Jan 31 '22 10:01 vitalik

I just opened PR https://github.com/vitalik/django-ninja/pull/588

xncbf avatar Oct 12 '22 07:10 xncbf