Swagger 编辑说:不完全是 <#/definitions/parameter>,<#/definitions/jsonReference>
Swagger editor says: is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>
我正在尝试为我的 API 定义一个 swagger 文档。 Swagger 编辑一直在说 is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>
我检查了规范,参数应该有 name, in required, description
和 default
如果没有 in: body
http://swagger.io/specification/#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
不与必需参数一起使用,仅与可选参数一起使用。如果客户端不发送此参数,则默认值是服务器使用的值。但是如果需要一个参数,客户端必须总是发送它并且从不使用默认值。
我正在尝试为我的 API 定义一个 swagger 文档。 Swagger 编辑一直在说 is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>
我检查了规范,参数应该有 name, in required, description
和 default
如果没有 in: body
http://swagger.io/specification/#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
不与必需参数一起使用,仅与可选参数一起使用。如果客户端不发送此参数,则默认值是服务器使用的值。但是如果需要一个参数,客户端必须总是发送它并且从不使用默认值。