gpt4 book ai didi

swagger - 验证错误:数据与“oneOf”中的任何模式都不匹配

转载 作者:行者123 更新时间:2023-12-03 14:09:19 25 4
gpt4 key购买 nike

我收到以下规范的错误Data does not match any schemas from '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-tools验证程序的完整错误:

#/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


我不了解该错误或如何解决。

最佳答案

您不能在type参数中包含body。这就是为什么有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": ""
}
}
}
}
}

关于swagger - 验证错误:数据与“oneOf”中的任何模式都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30248604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com