-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
JSON:API #41
Comments
hi @HrachMD Not sure I understand... do you have any references/links to this schema validation ? |
Thank you for your response. I mean if we have such response schema:
Then do not return just {'email': '', 'name': ''} |
Maybe we need something like this 👉 https://github.com/django-json-api/django-rest-framework-json-api |
We're having this issue as well, and currently the responses are a bit awkward because JSONAPI uses an "envelope" that the actual data gets wrapped in, so Ninja only ever sees the "envelope" and the resulting names are "wrong" (it basically thinks that every API returns a class of type Maybe it would be nice to have something that takes the proper classes and wraps them in the envelope. |
maybe what you need is custom renderer ? Note: Django Ninja is designed on top of OpenAPI specifcation/standard while JSON:API is an alternative standard technically with custom renderer you can achieve responses like you describe, but autogenerated openapi docs and schema will be useless |
Ah, that makes sense, thank you. |
Does OpenAPI mandate the response schema that APIs should return? What is the recommended way of returning e.g. relationships in Ninja? Currently, if we need to return, for example, a |
@skorokithakis You can use generics to help cleanup the code with embedded pydantic models. Here is an example for JSONAPI: |
Hm, that's an interesting solution, thanks @stephenrauch. I don't think our juniors are going to love it, as generics are a rather advanced type concept, but it seems to solve the problem well, thanks. |
This one also not issue, but a proposal.
It will be very useful for response schema validation in jsonapi standards.
The text was updated successfully, but these errors were encountered: