简体   繁体   中英

Swagger editor says: is not exactly one from <#/definitions/parameter>,<#/definitions/jsonReference>

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 , eg "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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM