connexion icon indicating copy to clipboard operation
connexion copied to clipboard

requestBody: required: true doesn't work

Open ghost opened this issue 6 years ago • 5 comments

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

ghost avatar Feb 16 '19 03:02 ghost

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.

dtkav avatar Mar 02 '19 03:03 dtkav

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'.

TheBrunoLopes avatar Aug 06 '19 09:08 TheBrunoLopes

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

jamesmazur avatar Nov 08 '19 22:11 jamesmazur

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.

ioggstream avatar Nov 10 '19 16:11 ioggstream

Try setting type property for schema i.e.

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

I worked for my case though.

abdullah-abid-dev avatar Aug 04 '20 19:08 abdullah-abid-dev