2

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>
Nikita
  • 1,465
  • 3
  • 15
  • 17
  • Can you provide more detail for what you mean by "But UI parsing petstore from example by default"? – Ken Jan 01 '17 at 19:18
  • @Ken, When I use swagger-webapp dependency it will just map swagger-ui app on url /swagger-ui. By default in swagger-ui in index.html url with swagger.json is set to [link](http://petstore.swagger.io/v2/swagger.json) but I want to use my own /swagger.json, so I need to override this index.html – Nikita Jan 01 '17 at 19:45
  • 1
    I'm not sure that's supported at present. Could you file an issue with as much detail as possible here: https://issues.jboss.org/browse/SWARM – Ken Jan 03 '17 at 19:39

3 Answers3

0

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
Martijn Burger
  • 7,315
  • 8
  • 54
  • 94
0

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.

bram000
  • 528
  • 4
  • 5
0

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
Alex L.
  • 89
  • 6