简体   繁体   中英

How to get rid of "API must not have local definitions (i.e. only $refs are allowed)" Swaggerhub standardization error with Springfox

I have swagger api-docs.json definition generated by SpringFox . Below minimal-reproducible-example:

{
  "swagger": "2.0",
  "info": {
    "description": "Example REST API.",
    "version": "15.11.02",
    "title": "Example REST API",
    "contact": {
      "name": "ExampleTeam",
      "url": "https://example.com/",
      "email": "support@example.com"
    },
    "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
      }
    }
  }
}

When I import it to SwaggerHub I got standardization error:

'definitions.*' not allowed -> API must not have local definitions (ie only $refs are allowed)

看

I have found the recommended solution in SwaggerHub documentation

But here is my question how to achieve:

  • split into domains(then using a reference), or
  • inline schemas

with Springfox

Or maybe there is another way to get rid of the above standardization error?

If you go to your home page, then hover over your organization on the left hand side and go to settings > Standardization, you should see some options. Unselect "API must not have local definitions (ie only $refs are allowed)" at the bottom.

在此处输入图片说明

And don't forget to save at the top right!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM