Swagger文件正在与warnig一起正常工作。
{
'swagger': "2.0",
"info": {
"version": "3.0",
"title": "Sample Service",
},
"schemes": [ "http" ],
"host": "sampleservice.azurewebsites.net",
"paths": {
"/": {
"post": {
"summary": "Sample service",
"description": "sample service",
"parameters": [
{
"name": "Input",
"in": "body",
"description": "valid input",
"schema": {
"type": "object",
"properties": {
"MainAttr-1": {
"required": [ "Attr-1" ],
"type": "object",
"properties": {
"Attr-1": {
"description": "Attr-1",
"required": true,
"type": "string"
},
"Attr-2": {
"description": "Attr-2",
"required": false,
"type": "string"
},
"Attr-3": {
"description": "Attr-3",
"required": false,
"type": "boolean"
},
"Attr-4": {
"description": "Attr-4",
"required": false,
"type": "boolean"
},
"Attr-5": {
"description": "Attr-5",
"required": false,
"type": "string"
}
}
},
"MainAttr-2": {
"type": "array",
"items": {
"type": "object",
"required": [ "Attr-1", "Attr-3", "Attr-5", "Attr-8" ],
"properties": {
"Attr-1": {
"description": "Attr-1",
"required": true,
"type": "string"
},
"Attr-2": {
"description": "Attr-2",
"required": false,
"type": "string"
},
"Attr-3": {
"description": "Attr-3",
"required": true,
"type": "boolean"
},
"Attr-4": {
"description": "Attr-4",
"required": false,
"type": "boolean"
},
"Attr-5": {
"description": "Attr-5",
"required": true,
"type": "string"
},
"Attr-6": {
"description": "Attr-6",
"required": false,
"type": "string"
},
"Attr-7": {
"description": "Attr-7",
"required": false,
"type": "string"
},
"Attr-8": {
"description": "Attr-8",
"required": true,
"type": "string"
}
}
}
}
}
}
}
],
"responses": {
"200": {
"description": "success"
}
}
}
}
}
}

问题-1)应删除警告。
问题-2) "MainAttr-2“中的Attr-3是布尔型属性,是必需的。但是当我从下拉列表中选择'false‘时,它被视为无效输入。它只将“true”视为有效输入。(所需的任何布尔属性都是这样的)
由于这个警告,我无法传递代码。
提前谢谢。
发布于 2016-12-07 16:08:04
'swagger'更改为"swagger"。JSON需要字符串周围的双引号。required属性从所有属性定义(Attr-1到Attr-8)中删除,并在对象级别使用required列表(在MainAttr-1和MainAttr-2下)。
"MainAttr-1":{“必需”:"Attr-1",<-列出此数组中所需的属性"type":"object"," properties ":{ "Attr-1":{ "description":"Attr-1“," required ":true,<--删除"type":"string“},除此之外,你的规格没问题。
https://stackoverflow.com/questions/41021488
复制相似问题