I try to create api for post request using swagger but cannot determine what parameters I should configure in swagger in order to create this API.
I used postman in order to get all information about the response and implement in swagger.
'/api/v1/labels':
post:
tags:
- devices
summary: 'create new label'
description: 'create new label to a given device'
operationId: createNewLabel
produces:
- application/json
parameters:
- name: x-access-token
description: 'cognito token'
in: header
type: string
required: true
- in: body
name: body
description: add label details
required: true
schema:
$ref: '#/definitions/labelRequest'
responses:
'201':
schema:
$ref: '#/definitions/labelRequest'
description: Created
and this is the definition I wrote:
labelRequest:
type: object
items:
$ref: '#/definitions/labelRequestBody'
labelRequestBody:
type: object
properties:
device_ids:
type: array
items:
type: string
example: ["9bc11e25-4db2-4780-b761-390e3806082a"]
format: uuid
name:
type: string
example: new_label
This is the API call:
https:///api/v1/labels
with those headers:
x-access-token
and with this body as payload:
{
"device_ids":["ea4b9daa-07cd-4cd6-981f-c86e1e81f04c"],
"name":"labelName"
}
expected result is: 201 (created)