如何合并几个swagger JSON文件?

Jok*_*ius 8 swagger

拥有主JSON文件

{"swaggerVersion":"1.2",
 "apiVersion":"1.0",
 "apis":[{"path":"/api1"},{"path":"/api2"},{"path":"/api3"},{"path":"/api4"}]}
Run Code Online (Sandbox Code Playgroud)

和4个apis中的每一个的json文件,每个都适用于swagger库.

但是当我试图将它们全部放入一个json文件中时

 {"swaggerVersion":"1.2",
  "apiVersion":"1.0",
  "apis":[{<api1 json file contents>},{<api2 json file contents>},{<api3 json file contents>},{<api4 json file contents>}]}
Run Code Online (Sandbox Code Playgroud)

它没用.这样做的正确方法是什么?

cbl*_*ley 5

根据Swagger 1.2规范,你不能这样做.

"master"JSON文件(就像你所说的那样)是Swagger API 的资源列表,它只包含"可用资源的清单".

此JSON文档的"apis"属性应该是具有特定结构的Resource Object的数组:

{
  "path": "/pets",
  "description": "Operations about pets."
}
Run Code Online (Sandbox Code Playgroud)

引用规范的API声明部分:

API声明提供有关在资源上公开的API的信息.每个资源应该有一个文件描述.该文件必须在路径字段描述的URL中提供.