-
Notifications
You must be signed in to change notification settings - Fork 10
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
support additionalProperties false #26
Comments
This behavior can be modified with the unknown option, which accepts one of the following:
https://marshmallow.readthedocs.io/en/stable/quickstart.html#handling-unknown-fields |
default is RAISE |
Now, the default output is changed # this is auto-generated by swagger-marshmallow-codegen
from __future__ import annotations
from marshmallow import (
Schema,
fields,
INCLUDE,
RAISE,
)
class Person(Schema):
name = fields.String(required=True)
class Meta:
unknown = INCLUDE
class Person_AdditionalProperties_True(Schema):
name = fields.String(required=True)
class Meta:
unknown = INCLUDE
class Person_AdditionalProperties_False(Schema):
name = fields.String(required=True)
class Meta:
unknown = RAISE from {
"version": "2.0.0",
"definitions": {
"Person": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
]
},
"Person_AdditionalProperties_True": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
],
"additionalProperties": true
},
"Person_AdditionalProperties_False": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [
"name"
],
"additionalProperties": false
}
}
}
|
if you need strict output -- this is old behavior, add $ swagger-marshmallow-codegen 01person.yaml --strict-additional-properties 01person.yaml
# this is auto-generated by swagger-marshmallow-codegen
from __future__ import annotations
from marshmallow import (
Schema,
fields,
INCLUDE,
RAISE,
)
class Person(Schema):
name = fields.String(required=True)
class Person_AdditionalProperties_True(Schema):
name = fields.String(required=True)
class Meta:
unknown = INCLUDE
class Person_AdditionalProperties_False(Schema):
name = fields.String(required=True)
class Meta:
unknown = RAISE need Meta.unknown even Person class, run with |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No description provided.
The text was updated successfully, but these errors were encountered: