-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Generating Json Schema for nested models that have overlapping model names. #1912
Labels
bug V1
Bug related to Pydantic V1.X
Comments
It doesn't appear the |
jusexton
added a commit
to jusexton/pydantic
that referenced
this issue
Dec 2, 2020
…ctly when building map of models to create schema from (pydantic#1912)
jusexton
added a commit
to jusexton/pydantic
that referenced
this issue
Dec 2, 2020
…ultiple `BaseModel` with the same names declared in separate classes (pydantic#1912)
4 tasks
jusexton
added a commit
to jusexton/pydantic
that referenced
this issue
Dec 29, 2020
…ultiple `BaseModel` with the same names declared in separate classes (pydantic#1912)
15 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug
I'm trying to generate a schema that includes several models that have nested models. The inner-most models have identical name,
Params
, but since they are used only inside the class, there is no name clash. However, when adding outer models to the same schema, both inner-mostParams
models end up in the same ref location:{'$ref': '#/definitions/Params'}
, which I believe causes the error I see:KeyError: <class '__main__.A.Params'>
.I believe some fully-qualified path in '$ref' would resolve this, something like:
As a workaround, I wonder if there a way I can adjust prefix of each model independently? Or is there a way to put schema of nested classes "in-place", without creating a "$ref"?
Here is a complete minimal example:
Output of
python -c "import pydantic.utils; print(pydantic.utils.version_info())"
:The text was updated successfully, but these errors were encountered: