I am using an API first approach to define my APIs with postman and OpenAPI 3.0. However I’ve encountered a problem with the examples when generating collections from the API specification.
When I am autogenerating a collection from the schema below, two examples are generated for post /products (one for the 201 response status and another for the 400). However both of them get assigned the same request example (validRequest).
Is there a way to assign the validRequest example to the response 201 and the wrongRequest to the response 400?
paths:
/products:
post:
summary: Add Product
description: Creates a new product.
operationId: addProduct
tags:
- Products
requestBody:
description: A product schema.
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
examples:
wrongRequest:
category: Jeans
brand: Union
invalidRequest:
category: UknownCategory
brand: Union
responses:
'201':
description: Successful creation of product.
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
example:
success: true
'400':
description: Error.
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
example:
success: false