Skip to content
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

additionalProperties=false is not set when using default Marshmallow schema options #821

Open
mwgamble opened this issue Jan 29, 2023 · 2 comments

Comments

@mwgamble
Copy link

The default value for the Marshmallow schema option unknown is RAISE. I expected this to result in additionalProperties: false being set on the generated schema. Unfortunately, this doesn't currently happen. Unless the unknown option is set explicitly, no additionalProperties keyword is added to the generated schema.

Is adding support for this feasible? I don't really want to have to manually add the necessary metadata to all my schemas.

@lafrech
Copy link
Member

lafrech commented Jan 29, 2023

I guess you're right.

This could be fixed here:

if hasattr(Meta, "unknown") and Meta.unknown != marshmallow.EXCLUDE:
jsonschema["additionalProperties"] = Meta.unknown == marshmallow.INCLUDE

Would you like to do the fix + tests and send a PR?

Thanks.

@mwgamble
Copy link
Author

I don't have time to work on a PR at the moment sorry :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants