2016-11-24 60 views
0

我需要把中間件YAML打電話到另一個路徑另一個文件就像我在做我的imfv或者我們叫它config.js文件,這可能嗎?在我的配置文件中,我寫了以下內容:如何在YAML文件中調用另一個文件,就像我在配置文件中一樣?

"mw": __dirname + "/lib/mw/list.js", 

我需要一個類似的YAML。

> paths: /: 
>  get: 
>  parameters: 
>   - name: limit 
>   in: query 
>   description: number of pets to return 
>   type: integer 
>   default: 11 
>   minimum: 11 
>   maximum: 10000 
>  responses: 
>   200: 
>   description: List all pets 
>   schema: 
>    title: Pets 
>    type: array 
>    items: 
>    $ref: '#/definitions/Pet' 
>  post: 
>  parameters: 
>   - name: pet 
>   in: body 
>   description: The pet JSON you want to post 
>   schema: 
>    $ref: '#/definitions/Pet' 
>   required: true 
>  responses: 
>   200: 
>   description: Make a new pet definitions: Pet: 
>  type: object 
>  properties: 
>  name: 
>   type: string 
>  birthday: 
>   type: integer 
>   format: int32 

$ ref:'#/ definitions/Pet'每調用一次定義都會調用,所以它與commonfields是類似的嗎?

回答

0

當你閱讀YAML specification你會看到,有沒有指明「包括」機制。

如果您需要該功能,請在您的程序中加載YAML,或者如果您希望使其更加通用,請調整您使用的庫來加載YAML以具備此功能(非標準功能)。

+0

感謝您的回答。 我可以在我的配置文件中創建一個commonfields嗎?或者我必須使用「定義」標記並在$ ref中調用它們? –

+0

'$ ref'只是YAML中的一個字符串標量,沒什麼特別的。 YAML中阻止某些重複的唯一機制是錨/別名和從中派生出來的「合併」鍵,但似乎並不涵蓋你需要的東西。 – Anthon

+0

路徑: /: 後: 參數: - .. 模式: $ REF: '#/定義/寵物' 要求:真正 迴應: 200: 放: 參數: - .. 模式: $ REF: '#/定義/寵物' 要求:真正 迴應: 200: 定義: 寵物: 類型:對象 屬性: 南e: 類型:字符串 生日: 類型:整數 格式:int32 $ ref:'#/ definitions/Pet'每調用一次定義都會調用,所以它和commonfields是類似的吧? –

相關問題