我制作了我的第一个swagger api spec并且dredd给出了错误:
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)
所以我给参数提供了一个默认值,现在从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.
我想在规范中提供示例ID,但我在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
},
答案 0 :(得分:3)
根据
https://dredd.readthedocs.io/en/latest/how-to-guides/#example-values-for-request-parameters
Dredd支持 "parameters": [
{
"name": "id_person",
"in": "path",
"description": "ID of person to update",
"required": true,
"type": "integer",
"format": "int64",
"x-example": 1
},
扩展属性以指定参数示例:
{{1}}