Skip to content

Encoding of request bodies as x-www-form-urlencoded, and handling of arrays/explode #2788

@jdegre

Description

@jdegre

Hi,
A, hopefully, straightforward question on the correct interpretation of the OpenAPI spec.

Regarding the x-www-form-urlencoded encoding of request bodies, such as this example:

      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                foo:
                  type: array
                  items:
                    type: object
                    properties:
                      a:
                        type: integer
                      b:
                        type: integer

How is the foo array supposed to be encoded in the request body? As an exploded array?, such as:

foo={"a":1,"b":2}&foo={"a":3,"b":4}

or not exploded? such as:

foo={"a":1,"b":2},{"a":3,"b":4}

I'm aware that the explode behavior can be explicitly indicated by adding an encoding section with style: form and explode: true/false, but I cannot find in the OpenAPI spec a clear indication of what is the expected behavior when the encoding section is NOT provided.

Out of curiosity, I have tried with Swagger UI and it follows the non-exploded approach (2nd example), but please note that this is not a question about Swagger UI or any other tool. I'm interested in the correct interpretation of the OpenAPI spec.

Thanks in advance!

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