Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Swagger-UI "Default" Path

I have tried changing the basePath in my json file, which only seems to change the bottom "baseurl" of swagger-UI. I want to get rid of the "Default" that appears as a group title of my swagger-UI. Has anyone been able to fix this problem? I am using Swagger ~2.0.

like image 536
Shawn123 Avatar asked May 11 '15 18:05

Shawn123


People also ask

How do I change the path to Swagger?

The straightforward way is to set property springdoc. swagger-ui. path=/custom/path . It will work perfectly if you can hardcode swagger path in your application.

Where is my Swagger UI URL?

Once your application is started, you can go to http://localhost:8080/q/swagger-ui and play with your API. You can visualize your API's operations and schemas. You can also interact with your API in order to quickly test it.

What is the default Swagger URL?

Add and configure Swagger middleware The generated document describing the endpoints appears as shown in OpenAPI specification (openapi. json). The Swagger UI can be found at https://localhost:<port>/swagger .


1 Answers

The Default is not a path, it's a tag.

In Swagger 2.0, grouping is done using tags. Each operation can be assigned to zero or more tags. In the UI, any operation that has no tag will end up under the Default group.

"/pet/findByStatus": {
  "get": {
    "tags": [
      "pet"
    ],
    "summary": "Finds Pets by status",
    "description": "Multiple status values can be provided with comma seperated strings",
    "operationId": "findPetsByStatus",
    "consumes": [
      "application/xml",
      "application/json",
      "multipart/form-data",
      "application/x-www-form-urlencoded"
    ],
    "produces": [
      "application/xml",
      "application/json"
    ],
    "parameters": [
      {
        "name": "status",
        "in": "query",
        "description": "Status values that need to be considered for filter",
        "required": false,
        "type": "array",
        "items": {
          "type": "string"
        },
        "collectionFormat": "multi",
        "default": "available",
        "enum": [
          "available",
          "pending",
          "sold"
        ]
      }
    ],
    "responses": {
      "200": {
        "description": "successful operation",
        "schema": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Pet"
          }
        }
      },
      "400": {
        "description": "Invalid status value"
      }
    },
    "security": [
      {
        "petstore_auth": [
          "write:pets",
          "read:pets"
        ]
      }
    ]
  }
}

You can see the operations has a tags property with the value of "pet", and that operation would be grouped under that header.

like image 52
Ron Avatar answered Oct 06 '22 20:10

Ron