2017-12-18 191 views
0

我可以成功將以下OpenAPI定義導入到Azure API管理中。爲什麼導入OpenAPI定義時,「模式」從「響應」對象中消失?

但是,當我導出OpenAPI定義時,「架構」名稱已從「響應」對象中刪除。因此,我的門戶中的開發人員未顯示此操作的架構或示例。

如果將我的API定義添加到the official editor,那麼我的API定義是有效的並且功能正確。

如何防止模式被剝離?

{ 
    "swagger": "2.0", 
    "info": { 
    "title": "Foo", 
    "description": "Foo", 
    "version": "1" 
    }, 
    "host": "example.org", 
    "schemes": [ 
    "https" 
    ], 
    "paths": { 
    "/foo": { 
     "get": { 
     "summary": "List all foo.", 
     "responses": { 
      "200": { 
      "description": "Success.", 
      "schema": { 
       "$ref": "#/definitions/Foo" 
      } 
      } 
     } 
     } 
    } 
    }, 
    "definitions": { 
    "Foo": { 
     "type": "object", 
     "properties": { 
     "example": { 
      "type": "string", 
      "description": "An example." 
     } 
     } 
    } 
    } 
} 

回答

0

當定義在根對象或操作對象中缺少「產生」名稱時,似乎會出現此問題。

例如,下面的定義應該成功導入,然後在沒有「模式」被剝離的情況下導出。請注意,「產品」名稱已添加到根對象中,位於「方案」和「路徑」之間

{ 
    "swagger": "2.0", 
    "info": { 
    "title": "Foo", 
    "description": "Foo", 
    "version": "1" 
    }, 
    "host": "example.org", 
    "schemes": [ 
    "https" 
    ], 
    "produces": ["application/json"] 
    "paths": { 
    "/foo": { 
     "get": { 
     "summary": "List all foo.", 
     "responses": { 
      "200": { 
      "description": "Success.", 
      "schema": { 
       "$ref": "#/definitions/Foo" 
      } 
      } 
     } 
     } 
    } 
    }, 
    "definitions": { 
    "Foo": { 
     "type": "object", 
     "properties": { 
     "example": { 
      "type": "string", 
      "description": "An example." 
     } 
     } 
    } 
    } 
} 
相關問題