如何摆脱“ API一定不能具有本地定义(即,仅允许$ refs一起使用)”带有Springfox的Swaggerhub标准化错误

问题描述 投票:0回答:1

我具有由SpringFox生成的大胆的api-docs.json定义。下面最小可复制示例:

{
  "swagger": "2.0",
  "info": {
    "description": "Example REST API.",
    "version": "15.11.02",
    "title": "Example REST API",
    "contact": {
      "name": "ExampleTeam",
      "url": "https://example.com/",
      "email": "[email protected]"
    },
    "license": {
      "name": "Apache License 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.txt"
    }
  },
  "host": "d01088db.ngrok.io",
  "basePath": "/cloud",
  "tags": [
    {
      "name": "All Endpoints",
      "description": " "
    }
  ],
  "paths": {
    "/api/v2/users/{userId}/jobs/{jobId}": {
      "get": {
        "tags": [
          "Builds",
          "All Endpoints"
        ],
        "summary": "Get job.",
        "operationId": "getJobUsingGET",
        "produces": [
          "*/*"
        ],
        "parameters": [
          {
            "name": "jobId",
            "in": "path",
            "description": "jobId",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "name": "userId",
            "in": "path",
            "description": "userId",
            "required": true,
            "type": "integer",
            "format": "int64"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "$ref": "#/definitions/APIPipelineJob"
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Not Found"
          }
        },
        "deprecated": false
      }
    }
  },
  "definitions": {
    "APIPipelineJob": {
      "type": "object",
      "properties": {
        "archiveTime": {
          "type": "string",
          "format": "date-time",
          "example": "example"
        },
        "content": {
          "type": "string",
          "example": "example"
        },
        "createTime": {
          "type": "string",
          "format": "date-time",
          "example": "example"
        },
        "id": {
          "type": "integer",
          "format": "int64",
          "example": "example"
        },
        "name": {
          "type": "string",
          "example": "example"
        },
        "selfURI": {
          "type": "string",
          "example": "example"
        },
        "type": {
          "type": "string",
          "example": "example",
          "enum": [
            "BUILD",
            "DEPLOY"
          ]
        },
        "userId": {
          "type": "integer",
          "format": "int64",
          "example": "example"
        }
      },
      "title": "APIPipelineJob",
      "xml": {
        "name": "APIPipelineJob",
        "attribute": false,
        "wrapped": false
      }
    }
  }
}

[将其导入到SwaggerHub时出现标准化错误:

''definitions。*'不允许-> API不得具有本地定义(即仅允许$ refs)]

see

我已经找到推荐的解决方案in SwaggerHub documentation

但是这是我的问题如何实现:

  • 拆分为域(然后使用参考),或
  • 内联架构

使用Springfox

或者也许还有另一种方法可以摆脱上述标准化错误?

swagger-2.0 springfox swaggerhub
1个回答
1
投票
如果进入主页,则将鼠标悬停在左侧的组织上方,然后转到“设置”>“标准化”,您应该会看到一些选项。在底部取消选择“ API不得具有本地定义(即,仅允许$ refs)”。

enter image description here

并且不要忘记保存在右上角!

© www.soinside.com 2019 - 2024. All rights reserved.