-
-
Notifications
You must be signed in to change notification settings - Fork 396
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 schema is using a higher version json schema than open api #418
Comments
Hi @shughes-uk do you have some simple snippet that can be used to reproduce this bug ? |
Example api with paginate from django.contrib import admin
from django.urls import path
from ninja import NinjaAPI, Schema
from ninja.pagination import paginate
api = NinjaAPI()
@api.get("/add")
@paginate
def add(request, a: int, b: int, **kwargs):
return [{"result": a + b}]
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", api.urls),
] Running python manage.py runserver &
pip openapi-python-client
openapi-python-client generate --url http://127.0.0.1:8000/api/openapi.json Running this outputs
It's a little obtuse but those errors are from their pydantic representation of the openapi schema. This issue over on fast-api may be more helpful than the issue I linked in the ticket tiangolo/fastapi#3541 |
vitalik
added a commit
that referenced
this issue
Jun 3, 2022
@shughes-uk this is fixed in 0.18+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
It seems pydantic is generating schema in line with the latest json schema draft, but openapi expects an older version.
This issue has some info, and fastapi appears to have solved it but it might be worth solving this in ninja too.
pydantic/pydantic#1164
The outcome of this at the moment is codegen tools for openapi do not work correctly with ninja produced openapi docs.
swagger codegen simply silently fails, https://github.com/openapi-generators/openapi-python-client explodes
The type causing the issue is used as part of the default pagination decorator so I imagine this applies to most ninja users.
The text was updated successfully, but these errors were encountered: