Reputation: 23
We developed a API using Eve 0.7 that used allow_unknown
on a nested dict field. This field worked as expected according to the cerberus documentation.
We are now upgrading to Eve 0.8 and our endpoints no longer respect the allow_unknown
parameter in nested dicts.
settings.py
DOMAIN = {
'endpoint': {
'schema': {
'data': {
'type': 'dict',
'allow_unknown': True,
'schema': {
'prop': {'type': 'string'}
}
}
}
}
}
RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE']
app.py
from eve import Eve
app = Eve()
app.run(debug=True)
$ python app.py
Pass
$ curl -d '{"data": {"prop": "test prop"}}' -H 'Content-Type: application/json' http://127.0.0.1:5000/endpoint
{"_updated": "Fri, 08 Jun 2018 19:43:11 GMT", "_created": "Fri, 08 Jun 2018 19:43:11 GMT", "_etag": "e04dd19a6e13c74ccdb5561722bb001b0f5dff28", "_id": "5b1adc4f198a2527650320a4", "_links": {"self": {"title": "Endpoint", "href": "endpoint/5b1adc4f198a2527650320a4"}}, "_status": "OK"}
Fail (would expect this to pass)
$ curl -d '{"data": {"prop": "test prop", "test": 2}}' -H 'Content-Type: application/json' http://127.0.0.1:5000/endpoint
{"_status": "ERR", "_issues": {"data": {"test": "unknown field"}}, "_error": {"code": 422, "message": "Insertion failure: 1 document(s) contain(s) error(s)"}}
Upvotes: 1
Views: 278
Reputation: 6576
This was an actual issue, thanks for reporting it. It is fixed with v0.8.1.dev0.
Thanks for reporting it!
Upvotes: 1