gpt4 book ai didi

api - Swagger 错误 |数据与 'oneOf' 中的任何架构都不匹配

转载 作者:行者123 更新时间:2023-12-01 13:49:29 25 4
gpt4 key购买 nike

我正在使用 Swagger 规范设计 API。 Unfournately,我正面临一个我无法解决的错误。

Data does not match any schemas from 'oneOf'


检查 inner property ,我发现了一个更具描述性的错误:

OBJECT_MISSING_REQUIRED_PROPERTY

Missing required property: $ref


重读 spec ,我看没必要加 $ref属性(property)在 parameters “部分”,所以我很困惑和卡住了。
错误在第 34 行。
{
"swagger": "2.0",
"info": {
"title": "###",
"version": "0.1.0"
},
"host": "api.###",
"basePath": "/",
"schemes": [
"https"
],
"produces": [
"application/json"
],
"paths": {
"/social-networks": {
"get": {
"summary": "Retrieves all social networks.",
"description": "Retrieves all social networks supported by ### along with the constraints of each one.",
"responses": {
"200": {
"description": "",
"examples": {
"application/json": {}
}
}
}
}
},
"/social-networks/{name}": {
"get": {
"summary": "Retrieves a social network.",
"description": "Retrieves the social network whose name matches with the specified path parameter.",
"parameters": [
{
"name": "name",
"in": "path",
"description": "The name of the social network.",
"required": "true",
"type": "string"
}
],
"responses": {
"200": {
"description": ""
}
}
}
}
}
我究竟做错了什么?

最佳答案

required路径参数的值应该是 true .你的是字符串"true" .

您的 JSON 也无效,您缺少一个 }在末尾。这是 YAML 中 Swagger 的固定版本:

---
swagger: "2.0"
info:
title: "###"
version: "0.1.0"
host: "api.###"
basePath: "/"
schemes:
- "https"
produces:
- "application/json"
paths:
/social-networks:
get:
summary: "Retrieves all social networks."
description: "Retrieves all social networks supported by ### along with the constraints of each one."
responses:
200:
description: ""
examples:
application/json: {}
/social-networks/{name}:
get:
summary: "Retrieves a social network."
description: "Retrieves the social network whose name matches with the specified path parameter."
parameters:
-
name: "name"
in: "path"
description: "The name of the social network."
required: true
type: "string"
responses:
200:
description: ""

关于api - Swagger 错误 |数据与 'oneOf' 中的任何架构都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33066507/

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