4

G'Evening,

We're trying to implement Swagger into an existing REST-project, running on a Wildlfly with Java EE. The purpose is to generate the documentation for the REST-API during runtime.

However, after adding the necessary dependancies (io.swagger:swagger-jaxrs) to our Gradle setup, we tried setting up the Swagger generator via the web.xml

<servlet-mapping>
<servlet-name>SwaggerConfig</servlet-name>
<url-pattern>/api/documentation</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>SwaggerConfig</servlet-name>
<servlet-class>io.swagger.jaxrs.config.DefaultJaxrsConfig</servlet-class>
<init-param>
<param-name>api.version</param-name>
<param-value>1.0.0</param-value>
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>http://localhost:8080/api/documentation</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet> 

We do manage to address the servlet under */api/documentation via SOAP, but there doesn't seem to be any documentation, JSON-file or otherwise, generated, nor do we seem to be able to figure out where/how to set-up the generation.

Any help, advice, or a link to a guide that we may have missed, would be highly appreciated.

Alblaka
  • 51
  • 1
  • 5

2 Answers2

0

Swagger generates an HTML page which is accessible while your back-end server is running.

Try /api/index.html

Sedky A
  • 184
  • 2
  • 15
  • Neither /api/index.html nor /api/documentation/index.html lead to any valid site, the server merely returns a 404. – Alblaka Nov 07 '17 at 08:52
0

Try api/documentation/swagger.json that is where my file was hiding :)

I followed the guide in the swagger-core git hub repo step be step (and very carefully) and it worked for me (the resteasy guide since you are using wildfly): https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-RESTEasy-2.X-Project-Setup-1.5

Note that this only supplies you with the swagger file, to use it to build the swagger gui you will need to use the swagger-ui package

Shai Rippel
  • 428
  • 1
  • 4
  • 12