[英]Swagger editor says: is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>
I'm trying to define a swagger documentation for my API. 我正在尝试为我的API定义一个详尽的文档。 Swagger editor keeps saying
is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>
I checked the specification and a parameter should have name, in required, description
and default
if not in: body
http://swagger.io/specification/#parameterObject 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
Thanks 谢谢
{
"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"
}
}
}
}
}
}
There are two issues: 有两个问题:
1) Parameters are missing a type
, eg "type": "string"
. 1)参数缺少
type
,例如"type": "string"
。
2) default
is not used with required parameters, it's only used with optional parameters. 2)
default
值不与必需参数一起使用,仅与可选参数一起使用。 The default value is the value that the server uses if the client does not send this parameter. 默认值是如果客户端不发送此参数,则服务器使用的值。 But if a parameter is required, the client must always send it and the default value is never used.
但是,如果需要参数,则客户端必须始终发送该参数,并且永远不会使用默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.