0

How to change Swagger-UI default URL in non Spring environment?

I'm trying to change the swagger-ui default url from:
http://localhost:8080/dist/index.html

to something like:
currentServerURL/basePath/docs.
http://localhost:8080/mms/report/docs
https://swarm.dev.com/mms/report/docs
...

Is there any way to archive this?

I use

  1. Java / jax.ws.rs
  2. Swagger 2.x
  3. OAS v3

I don't use spring and found only spring related answers to this topic



pom.xml

        <!--SWAGGER DEPENDENCIES -->
            <dependency>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-annotations</artifactId>
                <version>2.1.12</version>
            </dependency>
            <dependency>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-jaxrs2</artifactId>
                <version>2.1.12</version>
            </dependency>
            <dependency>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-core</artifactId>
                <version>2.1.12</version>
            </dependency>
            <dependency>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-models</artifactId>
                <version>2.1.12</version>
            </dependency>
            <dependency>
                <groupId>io.swagger.core.v3</groupId>
                <artifactId>swagger-integration</artifactId>
                <version>2.1.12</version>
            </dependency>
            <dependency>

openapi-configuration.json

 {
    "resourcePackages": [
        "com.example.server.webservice.report.app.rest.endpoints"
    ],
    "prettyPrint" : true,
    "cacheTTL": 0,
    "openAPI": {
        "info": {
            "version": "1.0",
            "title": "My Service",
            "description": "",
            "contact": {
                "email": "",
                "name": ""
            },
            "license": {
                "name": "Apache 2.0",
                "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
            }
        },
    "servers": [
    {
      "url": "https://swarm.dev.com:8443/",
      "description": "Development server"
    },
    {
      "url": "https://swarm.stage.com:8443/",
      "description": "Stage server"
    },
    {
      "url": "https://swarm.demo.com:8443/",
      "description": "Demo server"
    },
    {
      "url": "http://localhost:8080/",
      "description": "Local server"
    }
  ]
    }
}
bepieper
  • 1
  • 2
  • Does this answer your question? [Swagger UI redirecting to /swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config](https://stackoverflow.com/questions/62044228/swagger-ui-redirecting-to-swagger-ui-index-htmlconfigurl-v3-api-docs-swagger) – pringi Feb 15 '22 at 09:41

0 Answers0