remidavid
2 years agoNew Member
In path parameter and response mapping
Not sure what location for this but here is my problem
I have a swagger where I have a GET path for example /v1/product/1234
I have 200 response examples where one has user id 1234 and the other has 5678. How do I setup the path parameter examples to match the ones in the response?
paths:
'/v1/products/{productId}':
get:
summary: Retieve product information
operationId: getProductById
parameters:
- $ref: '#/components/parameters/productId'
responses:
'200':
$ref: '#/components/responses/success'
components:
parameters:
productId:
name: productId
in: path
required: true
description: The unique identifier of the product to retrieve
schema:
type: string
format: uuid
examples:
prod1:
summary: a product id
value: 1234
prod2:
summary: another product id
value: 5678
schemas:
Product:
type: object
required:
- id
- name
- type
properties:
id:
type: string
format: uuid
name:
type: string
type:
type: string
enum:
- electronic
- furniture
- music
- tools
- service
- outdoor
- food
description:
type: string
Error:
type: object
required:
- message
properties:
message:
description: A human readable error message
type: string
responses:
success:
description: Product information returned successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Product'
examples:
prod1:
$ref: '#/components/examples/prod1'
prod2:
$ref: '#/components/examples/prod2'
examples:
prod1:
summary: prod 1
value:
id: 1234
name: asdf
type: outdoor
description: asdfasdf
prod2:
summary: dfgh
value:
id: 5678
name: dfgh
type: food
description: dfgh