![](/img/trans.png)
[英]Swagger Editor showing schema error: is not exactly one from definitions
[英]Swagger editor says: is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>
我正在尝试为我的API定义一个详尽的文档。 Swagger编辑器一直说is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>
我检查了规范,如果没有in: body
则参数应该在name, in required, description
和default
包含name, in required, description
in: body
http:// swagger.io/规格/#parameterObject
谢谢
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "semantify.it spec",
"description": "Semantify.it. The APIs can be used to read, update, create and delete values inside the semantify.it database.",
"termsOfService": "http://swagger.io/terms/"
},
"basePath": "/api",
"schemes": [
"http",
"https"
],
"paths": {
"/login": {
"post": {
"tags": [
"Login, Register"
],
"consumes": [
"application/x-www-form-urlencoded"
],
"description": "Login and get a Token",
"parameters": [
{
"name": "identifier",
"in": "formData",
"required": true,
"default": "test-user",
"description": "username or email"
},
{
"name": "password",
"in": "formData",
"required": true,
"default": "test-pass"
}
],
"responses": {
"200": {
"description": "Login success"
}
}
}
}
}
}
有两个问题:
1)参数缺少type
,例如"type": "string"
。
2) default
值不与必需参数一起使用,仅与可选参数一起使用。 默认值是如果客户端不发送此参数,则服务器使用的值。 但是,如果需要参数,则客户端必须始终发送该参数,并且永远不会使用默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.