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

Support for required with marshmallow and file on pyramid ? #193

Open
inkhey opened this issue Sep 3, 2019 · 0 comments
Open

Support for required with marshmallow and file on pyramid ? #193

inkhey opened this issue Sep 3, 2019 · 0 comments

Comments

@inkhey
Copy link
Contributor

inkhey commented Sep 3, 2019

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.

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

No branches or pull requests

1 participant