Reputation: 1639
I made my first swagger api spec and dredd gave error:
error: Compilation error in file '../../docs/swagger.json':
Required URI parameter 'id_person' has no example or default value. (person > /person/{id_person} > Updates a already existing person ID with form data)
So I gave a default value to the parameter and now getting warning from dredd:
Required URI parameter 'id_person' has a default value.
Default value for a required parameter doesn't make sense from API description perspective. Use example value instead.
I want to give example IDs in the spec, but I cannot find how to in the Swagger Specification.
My snip of my swagger:
"post": {
"tags": ["person"],
"summary": "Updates a already existing person ID with form data",
"operationId": "createNewPerson",
"consumes": ["application/x-www-form-urlencoded"],
"produces": ["application/json", "application/xml"],
"parameters": [
{
"name": "id_person",
"in": "path",
"description": "ID of person to update",
"required": true,
"type": "integer",
"format": "int64",
"default": 1
},
Upvotes: 1
Views: 1953
Reputation: 97629
According to
https://dredd.readthedocs.io/en/latest/how-to-guides/#example-values-for-request-parameters
Dredd supports the x-example
extension property to specify the parameter examples:
"parameters": [
{
"name": "id_person",
"in": "path",
"description": "ID of person to update",
"required": true,
"type": "integer",
"format": "int64",
"x-example": 1
},
Upvotes: 4