Skip to content

How to create Generic Schema for openapi? #817

Answered by vitalik
hushoujier asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @suuperhu

in pydantic 1.xx you should use special GenericModel - ref

from pydantic.generics import GenericModel
...

class Response(GenericModel, Generic[T1, T2]):
    code: int
    data: T1
    message: T2

next release django ninja will support pydanitc2 - where you do not need to GenericModel

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hushoujier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants