簡體   English   中英

Swagger編輯器說:不是<#/ definitions / parameter>,<#/ definitions / jsonReference>中的一個

[英]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, descriptiondefault包含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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM