Neha
Neha

Reputation: 805

How to integrate swagger-ui in my application

I am trying to integrate swagger with camel project

following this example https://github.com/smparekh/camel-example-servlet-rest-tomcat

How do i access swagger-ui using this example project ?

I delopyed the war file in tomcat.

and access http://localhost:8080/camel-example-servlet-rest-tomcat/api-docs i get this ...

{"apiVersion":"1.2.3","swaggerVersion":"1.2","apis":[{"path":"/user","description":"User rest service"}],"info":{"title":"User Services","description":"Camel Rest Example with Swagger that provides an User REST service"}}

BUT MY QUESTION IS - how do i access swagger-ui/index.html?

what is the exact URL to access swagger-UI?

Upvotes: 13

Views: 56904

Answers (5)

Anand
Anand

Reputation: 1871

To access swagger2 it is

http://localhost:${port}/${contextPath}/swagger-ui.html

Upvotes: 2

DolphinJava
DolphinJava

Reputation: 2752

You must copy the contents of the dist folder of swagger-ui into your project's webapp folder.

In index.html,

  window.swaggerUi = new SwaggerUi({
  url: "http://petstore.swagger.wordnik.com/api/api-docs",
  dom_id: "swagger-ui-container",

you must replace url with this

 http://localhost:8080/camel-example-servlet-rest-tomcat/api-docs

For details, Follow this link to integrate swagger-ui.

https://github.com/swagger-api/swagger-ui

Upvotes: 10

Travis D
Travis D

Reputation: 376

These are your Swagger Docs:

{"apiVersion":"1.2.3","swaggerVersion":"1.2","apis":[{"path"...

Now you need Swagger-UI to consume them. You can install it anywhere. There is no hard requirement that you put Swagger-UI in your project. You just need to edit the index.html file to point to your docs path (the JSON output above.)

Upvotes: 0

StasKolodyuk
StasKolodyuk

Reputation: 4524

You should use http://localhost:${port}/${contextPath}/swagger/index.html

Upvotes: 3

noor
noor

Reputation: 1691

http://localhost:8080/camel-example-servlet-rest-tomcat/{basepath}/dist/index.html if you have copied dist folder as is. If you have renamed dist folder, use the new name instead of dist. replace basepath with basepath you have configured in web.xml. The code snippet for that looks like this:

<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>/rest</param-value>
</init-param>

Upvotes: 1

Related Questions