Specify swagger.json url for swagger UI wildfly swarm

1.5k views Asked by At

I have REST application with Wildfly Swarm and using default settings I have swagger.json on url /swagger or /swagger.json and ui for swagger on url /swagger-ui. But UI parsing petstore from example by default. How is it possible to configure default path for UI to my json file? I have next dependencies for swagger:

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>swagger</artifactId>
</dependency>
<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>swagger-webapp</artifactId>
</dependency>
3

There are 3 answers

0
bram000 On

You can create your own Swagger-ui webapplication. Just take the static files (html, js, css, img) from an example project. Now you can edit the index.html and define your own specific swagger.json location.

0
Alex L. On

There is a servlet in swagger-webapp that does what you are looking for. It's just not documented at all. https://github.com/thorntail/thorntail/blob/master/fractions/swagger-webapp/src/main/java/org/wildfly/swarm/swagger/webapp/runtime/SwaggerDefaultUrlChangerServlet.java

I added this system-property to my project-defaults.yml and now swagger-ui launches pointing to my swagger.json

swarm:
  swagger:
    web-app:
      json:
        path: /rest/swagger.json
0
Martijn Burger On

You could give the swagger-ui an url parameter that links to your swagger.json. For instance:

http://localhost:8080/swagger-ui/index.html?url=/swagger.json