2017-06-15 54 views
1

我正在爲我的API創建招搖,但對於具有相同方法的相同端點,我遇到了問題。這裏有兩個相同的端點(/令牌),它們具有相同的httpMethod POST,並且兩者在主體中具有不同的參數。在用戶界面上沒有顯示第一個端點。同一端點上的相同HTTP方法未顯示

這是我的昂首闊步代碼:

"/token": { 
     "post": { 
     "tags": [ 
      "Authorisation" 
     ], 
     "summary": "Get Token by Username and Password", 
     "operationId": "6bfe7ad3-64e8-4550-8fc9-c93ff30f4f0e", 
     "consumes": [ 
      "application/x-www-form-urlencoded" 
     ], 
     "parameters": [ 
        ], 
     "responses": { 
      "200": { 
      "schema": { 
       "$ref": "#/definitions/getTokenResponse" 
      } 
      } 
     }, 
     "security": [ 
      { 
      "basic_auth": [] 
      } 
     ] 
     }, 
     "post": { 
     "tags": [ 
      "Authorisation" 
     ], 
     "summary": "Refresh Acces Token", 
     "operationId": "6bfe7ad3-64e8-4550-8fc9-c93ff30f4f0e", 
     "consumes": [ 
      "application/x-www-form-urlencoded" 
     ], 
     "parameters": [ 
       ], 
     "responses": { 
      "200": { 
      "schema": { 
       "$ref": "#/definitions/getTokenResponse" 
      } 
      } 
     }, 
     "security": [ 
      { 
      "basic_auth": [] 
      } 
     ] 
     } 
} 

回答

2

每個HTTP方法只能每個路徑中使用一次。您不能爲同一路徑創建兩個POST。

即將OpenAPI的規範3.0將支持oneOf這將允許你定義在相同的操作替代有效載荷,如:

paths: 
    /token: 
    requestBody: 
     content: 
     application/x-www-form-urlencoded: 
      oneOf: 
      - $ref: '#/components/schemas/getTokenRequest' 
      - $ref: '#/components/schemas/refreshTokenRequest' 

但在所述OpenAPI /揚鞭2.0這是不可能的。

相關問題