marshmallow-code / marshmallow-code/apispec
What to do about multiple nested schemas warning?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 202
- Avg merge
- 3h 38m
- Merged PRs (30d)
- 3
Description
Originally reported here: https://github.com/Nobatek/flask-rest-api/issues/57 - see there for more input
--
I'm using marshmallow v3-rc5 and using two-way nesting
Using this technique I get the following error if I attempt to use something like @blp.response(CreatorSchema(many=True, exclude=('follower_count',))):
/Users/cyber/.virtualenvs/luve-pim5aQIP/lib/python3.7/site-packages/apispec/ext/marshmallow/common.py:143:
UserWarning: Multiple schemas resolved to the name Creator. The name has been modified. Either manually add each of the schemas with a different name or provide a custom schema_name_resolver.
and see multiple versions of the schema in swagger (Creator, Creator1).
If I remove the exclude arg to my schemas and make new schemas then everything works perfectly. Something about exclude causes it to think there are multiple versions of the schema and it all explodes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the @blp.response entry point and inspect how marshmallow schemas using exclude are passed into apispec's schema resolution. Reproduce the two-way nesting case from the issue, then verify that Swagger/OpenAPI output no longer creates duplicate Creator schemas.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100