How to Define Swagger for application/x-www-form-urlencoded Request with Array

Viewed 1082

I have an API whose curl request is as follows:

curl --request POST \
  --url 'http://some.url/api/Resource/findByIds' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'data[ids][]=100025' \
  --data 'data[ids][]=100028'

How can this be represented in an OpenAPI (Swagger) request definition & example (version 3)?

This is what I have so far, but I can't seem to get the example to show correctly.

    api/Resource/findByIds:
      post:
        summary: Find resource by IDs
        requestBody:
          content:
            application/x-www-form-urlencoded:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      ids:
                        type: array
                        description: IDs of resources to fetch
                        items:
                          type: integer
                encoding:
                  data:
                    style: deepObject
                    explode: true
              example:
                data:
                  ids: [2334, 234, 20043]
0 Answers
Related