2015-09-09 49 views
2

我有這個YAML代碼的招搖,我需要創建我自己的類型(名爲MyOwnType)。在Swagger中創建我自己的類型

如果我使用「MyOwnType」發生編譯錯誤。在架構

paths: 
    /in/total: 
    get: 
     summary: My summary. 
     description: My description. 

     parameters: 
     - name: total 
      in: query 
      description: Total. 
      required: true 
      type: MyOwnType # -- THIS LINE OCCURS ERROR -- 
      format: MyOwnType 
     responses: 
     201: 
      description: Respose 
      schema: 
      $ref: '#/definitions/MyOwnType' 

definitions: 
    MyOwnType: 
    properties: 
     var: 
     type: string 
     description: data. 

我創建了一個定義 「MyOwnType」 我可以使用這樣的: 「 '#/定義/ MyOwnType' $ REF」。

但是我怎樣才能在參數類型上使用「MyOwnType」定義呢?

回答

2

查詢參數不能有JSON模式。如果你想爲你的參數模式,你應該改變你的參數inbodyformData和使用schema鍵:

swagger: '2.0' 
info: 
    version: 0.0.0 
    title: '<enter your title>' 
paths: 
    /in/total: 
    get: 
     summary: My summary. 
     description: My description. 

     parameters: 
     - name: total 
      in: body 
      description: Total. 
      required: true 
      schema: 
      $ref: '#/definitions/MyOwnType' 
     responses: 
     201: 
      description: Respose 
      schema: 
      $ref: '#/definitions/MyOwnType' 

definitions: 
    MyOwnType: 
    properties: 
     var: 
     type: string 
     description: data.