Search code examples
swagger-2.0springfoxswaggerhub

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": "[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
      }
    }
  }
}

When I import it to SwaggerHub I got standardization error:

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

see

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?


Solution

  • 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 (i.e. only $refs are allowed)" at the bottom.

    enter image description here

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