-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
What to do about multiple nested schemas warning? #444
Comments
As I explained in marshmallow-code/flask-smorest#57, since a field is excluded, these are indeed different schemas, so apispec is doing the right thing by creating separate schemas in the spec. We added a warning because we figured the user might not be aware of this (your example proves us right) and he would probably want to set explicit names himself (manually or with a custom name resolver) rather than relying on the default name+increment. Since you seem to think the default automatic naming is fine, there are two things we could do
|
I'm fine with the behavior I just want to shut it up. |
I used marshmallow-code/flask-smorest#38 (comment) as a base for the custom schema resolver, but I don't know how to check if |
Any decision made about this? In most cases a custom resolver would do exactly the same things as the base resolver except for the warning.. so an option to silent the warning would be appealing |
any update about this? |
For now I have silenced the warning and I forgot about it. Not a very elegant solution, but it seems to work:
Probably an official option to silence the warning would be better, but for the moment this very rough approach is enough for me |
@mdantonio I've tried to put it under my flask def create_app(config_name):
app = Flask("FOO")
app.config.from_object(config_by_name[config_name])
register_extensions(app)
register_blueprints(app)
configure_logger(app)
warnings.filterwarnings(
"ignore",
message="Multiple schemas resolved to the name Gateway. The name has been modified. Either manually add each of the schemas with a different name or provide a custom schema_name_resolver.",
)
return app I also tried to use only some part of the warning message "Multiple schemas resolved to the name ", but doesn't work too warnings.filterwarnings(
"ignore",
message="Multiple schemas resolved to the name "
) |
Try to move it before the loading of the endpoints, probably after the blueprints registration the app already raised such warnings |
Nice idea, worked like a charm. Now I can have clean log. Thank you. |
Originally reported here: marshmallow-code/flask-smorest#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',)))
: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 aboutexclude
causes it to think there are multiple versions of the schema and it all explodes.The text was updated successfully, but these errors were encountered: