2017-12-18 194 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." 
     } 
     } 
    } 
    } 
} 
相关问题