How to integrate swagger-ui in my application

I am trying to integrate swagger with a camel

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

How can I access Swagger-UI using this sample project?

I deleted the war file in the cat.

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 recreation service"}], "info": {"title": "User Services", "description": "An example of a camel ride with Swagger providing the user's REST service"}}

BUT MY QUESTION - how can I access swagger-ui / index.html?

What is the exact URL to access the Swagger-UI?

+8
source share
5 answers

You must copy the contents of the dist swagger-ui folder to the folder of your web project project.

In index.html,

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

you should replace url with this

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

See this link for swagger-ui integration for more details.

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

+8
source

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

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

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

+1
source

These are your Swagger docs:

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

Now you need to use Swagger-UI to use them. You can install it anywhere. There is no strict requirement that you add Swagger-UI to your project. You just need to edit the index.html file to point to your document path (JSON output above).

0
source

To access swagger2 this

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

Source: https://habr.com/ru/post/984802/


All Articles