Using node dredd against my API. I opted for using yml file as this is a std that is familiar with my team.
Here is an example snippet we have functioning correctly:
/api/station/{id}:
get:
produces:
- application/json; charset=utf-8
parameters:
- name: id
in: path
required: true
type: string
description: DynamoDB ID of the station to edit
x-example: 'daf04a00-c3bf-11e7-a913-b76623d265c4'
responses:
200:
description: Returns a single station
schema:
$ref: '#/definitions/station'
I think I can guess how to define alternate response object, i assume just add to the object eg:
responses:
200:
description: Returns a single station
schema:
$ref: '#/definitions/station'
422:
description: Failed validation
In the dredd docs: https://dredd.readthedocs.io/en/latest/how-to-guides.html#multiple-requests-and-responses-within-one-api-blueprint-action
There is an example how to send multiple requests to the same end point.. but this is for the API Blueprint format and not yaml.
Does anyone know how to pass multiple requests to the same endpoint using the yaml format? I cannot see any docs on how to do this
Right below the section in docs you linked there's Testing non-2xx Responses with Swagger:
The Swagger format allows to specify multiple responses for a single operation. By default Dredd tests only responses with
2xx
status codes. Responses with other codes are marked as skipped and can be activated in hooks - see Testing non-2xx Responses with Swagger.Default responses are ignored by Dredd. Also, as of now, only
application/json
media type is supported inproduces
andconsumes
. Other media types are skipped.