Swagger 验证错误:数据与来自';其中之一';
我发现错误Swagger 验证错误:数据与来自';其中之一';,swagger,Swagger,我发现错误数据与'oneOf'中具有以下规范的任何架构不匹配: { "info": { "version": "1.0.0", "title": "REST API" }, "paths": { "/doit": { "post": { "responses": { "200": { "description": "Successful response" }
数据与'oneOf'
中具有以下规范的任何架构不匹配:
{
"info": {
"version": "1.0.0",
"title": "REST API"
},
"paths": {
"/doit": {
"post": {
"responses": {
"200": {
"description": "Successful response"
}
},
"parameters": [
{
"type": "object",
"schema": {
"$ref": "#/definitions/ResponseDefinition"
},
"required": "true",
"name": "docs",
"in": "body"
}
]
}
}
},
"swagger": "2.0",
"definitions": {
"ResponseDefinition": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": ""
}
}
}
}
}
来自swagger工具验证程序的完整错误:
#/paths/~1doit/post/parameters/0: Data does not match any schemas from 'oneOf'
#/paths/~1doit/post/parameters/0: Data does not match any schemas from 'oneOf'
#/required: Expected type boolean but found type string
#/: Missing required property: type
#/paths/~1doit/post/parameters/0: Additional properties not allowed: in,name,required,schema
我不理解错误或如何解决。您不能在
正文
参数中包含类型
。这就是为什么会有模式
。试试这个:
{
"info": {
"version": "1.0.0",
"title": "REST API"
},
"paths": {
"/doit": {
"post": {
"responses": {
"200": {
"description": "Successful response"
}
},
"parameters": [
{
"schema": {
"$ref": "#/definitions/ResponseDefinition"
},
"required": "true",
"name": "docs",
"in": "body"
}
]
}
}
},
"swagger": "2.0",
"definitions": {
"ResponseDefinition": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": ""
}
}
}
}
}
对我来说,是不正确的apidoc导致了这个错误。此文档产生了以下错误:
/**
* @openapi
* /init:
* get:
* description: Tells the app an environment it should use
* parameters:
* - name: version
* in: query
* description: app version, for example "4.0.0"
* required: true
* type: string
* responses:
* 200:
* description: Description
*/
请注意,参数
当我将type
放在parameters
->schema
下时,它开始生效:
/**
* @openapi
* /init:
* get:
* description: Tells the app an environment it should use
* parameters:
* - name: version
* in: query
* description: app version, for example "4.0.0"
* required: true
* schema:
* type: string
* responses:
* 200:
* description: Description
*/
你介意引用你从哪里得到这个factoid吗?你指的是什么factoid?你回答的第一行。检查下的字段表。