I'm trying to define a swagger documentation for my 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
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
, e.g. "type": "string"
.
2) default
is not used with required parameters, it's only used with optional parameters. 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.