connexion icon indicating copy to clipboard operation
connexion copied to clipboard

allOf doesn't work with multipart/form-data

Open alfechner opened this issue 1 year ago • 0 comments

Description

I use multipart/form-data content type.

The following spec works just fine:

openapi: 3.0.3
info:
  title: LIQUID Dataset Service
  version: 1.0.0
paths:
  /foo:
    post:
      x-openapi-router-controller: liquid_dataset_service.controllers.dataset_controller
      operationId: create_bar
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                bar:
                  type: string
      responses:
        204:
          description: No Content

In the next spec I used allOf to assemble objects (in this minimal example I only use one object):

openapi: 3.0.3
info:
  title: LIQUID Dataset Service
  version: 1.0.0
paths:
  /foo:
    post:
      x-openapi-router-controller: liquid_dataset_service.controllers.dataset_controller
      operationId: create_bar
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              allOf:
                - type: object
                  properties:
                    bar:
                      type: string
      responses:
        204:
          description: No Content

Expected behaviour

Spec two should behave exactly like spec one.

Actual behaviour

Server raises error: ExtraParameterProblem(status_code=400, detail='Extra formData parameter(s) bar not in spec')

Steps to reproduce

Create a controller function, e.g.:

def create_bar(bar):
    return

Use the second spec from above. Adjust property x-openapi-router-controller accordingly.

Fire up the swagger page and run the request.

Additional info:

Output of the commands:

  • python --version: Python 3.11.6
  • pip show connexion | grep "^Version\:": Version: 3.0.5

alfechner avatar Feb 09 '24 09:02 alfechner