hapic
hapic copied to clipboard
Support for required with marshmallow and file on pyramid ?
Currently
In this environmment:
- hapic
- marshmallow
- pyramid.
using input file with schema like:
files = marshmallow.fields.Raw(required=True, description="a file")
Do not work properly because of required = True check: Without file: normal behavior:
❯ http -a [email protected]:[email protected] --form POST http://localhost:6543/api/v2/workspaces/1/files
HTTP/1.1 400 Bad Request
Content-Length: 118
Content-Type: application/json
Date: Tue, 03 Sep 2019 08:10:13 GMT
Server: waitress
Set-Cookie: session_key=f922244fe7632e1503a4d7be19558025db968fcd535240b2ada24e84ad3de217104c1e5b; expires=Mon, 03-Sep-2018 08:10:13 GMT; Path=/; SameSite=Lax
{
"code": 2001,
"details": {
"files": [
"Missing data for required field"
]
},
"message": "Validation error of input data"
}
With file: error
❯ http -a [email protected]:[email protected] --form POST http://localhost:6543/api/v2/workspaces/1/files files@/home/user/image.jpg
HTTP/1.1 500 Internal Server Error
Content-Length: 107
Content-Type: application/json
Date: Tue, 03 Sep 2019 08:09:04 GMT
Server: waitress
Set-Cookie: session_key=3046282046ce7ea42286579dc0f77bf2f63b65fb42da3084df764760898a54b71843d46d; expires=Mon, 03-Sep-2018 08:09:05 GMT; Path=/; SameSite=Lax
{
"code": null,
"details": {
"error_detail": {}
},
"message": "argument of type 'SimpleFile' is not iterable"
}
Expected
Support required for file in this case too, check also actual support in other framework and serpyco.