相关疑难解决方法(0)

如何将swagger 2.0 JSON文件分解为多个模块

我正在尝试将我的API文档分解为多个可以独立编辑的JSON文件.我能够找到的所有示例都使用Swagger 1.2模式,该模式具有"api":{}对象以便将其分解.这似乎在2.0模式(http://json.schemastore.org/swagger-2.0)中缺失.所有定义的都是单个"路径"数组,它将所有API端点捆绑到该单个数组中.这在swagger-ui中的效果是有一个单独的"默认"类别,所有内容都被捆绑在一起,我无法分辨它.

TLDR:如何从swagger 2.0模式中的路径中拆分操作

{
  "swagger": "2.0",
  "info": {
    "description": "My API",
    "version": "1.0.0",
    "title": "My API",
    "termsOfService": "http://www.domain.com",
    "contact": {
      "name": "support@domain.com"
    }
  },
  "basePath": "/",
  "schemes": [
    "http"
  ],
  "paths": {
    "Authorization/LoginAPI": {
      "post": {
        "summary": "Authenticates you to the system and produces a session token that will be used for future calls",
        "description": "",
        "operationId": "LoginAPI",
        "consumes": [
          "application/x-www-form-urlencoded"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [{
          "in": "formData",
          "name": "UserName",
          "description": "Login Username",
          "required": true, …
Run Code Online (Sandbox Code Playgroud)

swagger swagger-ui swagger-2.0

35
推荐指数
2
解决办法
3万
查看次数

标签 统计

swagger ×1

swagger-2.0 ×1

swagger-ui ×1