cancel
Showing results for 
Search instead for 
Did you mean: 

In a POST operation, is it possible to have multiple examples for each property in the requestBody ?

SOLVED
Highlighted
New Contributor

In a POST operation, is it possible to have multiple examples for each property in the requestBody ?

Reading over the swagger documentation, it seems to me like the `properties` in the `requestBody` of a `POST` operation are much more limited than the `parameters` of a `GET` operation.

 

In my API I am allowing users to make either a `GET` or a `POST` request using the same parameters. In a `POST` request the parameters will be in the body instead of in the path. When defining the parameters for the GET operation, I am able to give multiple examples for each parameter. However when defining the properties for the POST operation on the same path, it seems that the examples are conceived mainly for full objects. I can give multiple examples of a full JSON object, but I can't give multiple examples for each `property` within an `application/x-www-form-urlencoded` body serialization?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Hi @johndorazio,

Your understanding is correct.

Multiple examples per property will be supported in the next version of the spec, OpenAPI 3.1 (which is in the RC stage now). The syntax will be as follows:

type: object
properties:
  id:
    type: integer
    examples:
      - 1
      - 15
  username:
    type: string
    examples:
      - guest
      - john
      - jane

Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

2 REPLIES 2
Highlighted
Moderator

Hi @johndorazio,

Your understanding is correct.

Multiple examples per property will be supported in the next version of the spec, OpenAPI 3.1 (which is in the RC stage now). The syntax will be as follows:

type: object
properties:
  id:
    type: integer
    examples:
      - 1
      - 15
  username:
    type: string
    examples:
      - guest
      - john
      - jane

Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

Highlighted
New Contributor

Ok eagerly awaiting the next release!

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors