Skip to content

Form data not accepted as POST requestBody #156

@NTICompass

Description

@NTICompass

I have a yaml file using OpenAPI 3.0.3. All my POST requests have their requestBody described, and they all use application/x-www-form-urlencoded.

When rendered, none of the POST requests show the request data, even when using :examples:.

Here's an example from my yaml file:

  /login:
    post:
      description: Login and get user info
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                email:
                  type: string
                password:
                  type: string
              required:
                - email
                - password
      responses:
        200:
          description: User Info
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserInfo'

Here's how I am trying to render this:

.. openapi:: /openapi.yaml
   :examples:

Here's what gets rendered on the HTML page:
27 06 2024_shot_15:53:05

So, the response gets shown correctly, but not the requestBody.

Looking at openapi30.py, I see the following

if request_content and 'application/json' in request_content:

It's assuming that the requestBody will always be application/json, but my API uses application/x-www-form-urlencoded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions