Connexion: requestBody: required: true doesn't work

Created on 16 Feb 2019  路  5Comments  路  Source: zalando/connexion

Description

Connexion 2.2.0
OpenAPI 3

requestBody:
  required: true

Connexion doesn't validate that a requestBody was provided.

Expected behaviour

400 Bad request -> requestBody is required

Actual behaviour

request is passed through to controller; KeyErrors abound because no requestBody was provided

Steps to reproduce

Submit a POST with no requestBody

Additional info:

Output of the commands:

Python 3.6.8
Version: 2.2.0
bug

Most helpful comment

Any updates when will this be merged ? I need to create an endpoint that can receive an empty body and without this change connexion says None is not of type 'object'.

All 5 comments

Hey @mbalaa-spring
Thanks for filing the issue. That does indeed look like a bug.
Connexion validates the individual schemas, so if you want a workaround, you should be able to mark the schema as required.

Any updates when will this be merged ? I need to create an endpoint that can receive an empty body and without this change connexion says None is not of type 'object'.

@dtkav @ioggstream Can this be merged in? I'm running into issues due to this bug as well.

I don't know if the workaround I wrote is good enough to cover all cases: iirc delving deeper in the subject that was more complex than it seemed (that's why I didn't create a PR).

Ask @dtkav for further infos.

Try setting type property for schema
i.e.

requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object

I worked for my case though.

Was this page helpful?
0 / 5 - 0 ratings