Why is "/v2/api-docs" getting appended in Swagger base url - spring-boot

I have a springboot application with springfox swagger 2.9.2, for one of my microservice the swagger base url generated in the swagger docs is appending "/v2/api-docs" at the end, for seemingly no apparent reason.
Here is what my application properties file looks like
spring.profiles.active=dev
server.contextPath=/xxxxxxxxxxxx-enterprise/v2/sas
server.port=8070
I have a feeling I am missing something silly.

Because this is the swagger service descriptions default path
From Springfox documentation: https://springfox.github.io/springfox/docs/snapshot/#customizing-the-swagger-endpoints
This can be customized by overriding "springfox.documentation.swagger.v2.path" property

Related

With Spring-Boot and WebJars how do I configure Swagger-UI

I have a Spring-Boot Application, generating swagger JSON at /contextPath/v2/api-docs.
Due to security concerns I have installed Swagger-UI from webJars version: 4.1.3.
Swagger-UI no longer allows ?url as a query parameter.
I have tried placing swagger-config.yaml and swagger-config.json in /resources/static/ and /resources/META-INF/resources/
I have also tried adding a new rest controller for a GET endpoint of
webpack://SwaggerUIBundle/swagger-config.yaml
So far nothing has worked.
When I manually paste the endpoint into "Explore" the Docs load.
So I know the problem isn't with my generated swagger JSON.
So How do I get Swagger-UI to load my Swagger JSON when the page loads?

Disable WADL endpoint generation in swagger documentation using springdoc-openapi

I have a spring boot application that has swagger documentation enabled using springdoc-openapi. For some reason there is an endpoint called /application.wadl is getting created automatically without adding any logic. Is there any way to disable wadl endpoints? I didn't add specific Wadl configuration in application.yml file as well
I managed to find a workaround after looking into the springdoc-openapi documentation. We can use springdoc.packages-to-scan property to scan only controller package as shown below
springdoc:
packages-to-scan:
- com.test.appName.controller

Springboot Hateoas not working as expected

I updated my project's Springboot version from 1.5.10 to 2.2.2. As per the documentation, I did all the necessary changes to resolve HATEOS related compilation errors. But now the HTTP response is not coming as expected. Now, I'm getting "links" instead of "_links". Also, I'm not getting "_embedded" attribute in response anymore.
I did below changes:
Replaced ResourceSupport with RepresentationModel<T>
Replaced Resource with EntityModel
Replaced Resources with CollectionModel
Please help me out in resolving this issue.
It seems like hateoas and swagger do not work together after springboot 2.x.x. I ended up replacing swagger with springdoc-openapi-ui for documentation.

SpringFox context path duplicated when deployed to Tomcat

I have a Spring Boot resource server using SpringFox to generate Swagger UI documentation for the REST API. I'm using Spring version 2.2.4.RELEASE and SpringFox version 3.0.0-SNAPSHOT.
When I run the application self hosted the URLs in the documentation are correct, they look like this:
http://localhost:8080/customers
But when I run the same application on tomcat the URLs look like this:
https://myapp.azurewebsites.net/my-app-1.0.0/my-app-1.0.0/customers
The application path is duplicated for all the APIs, the path should be:
https://myapp.azurewebsites.net/my-app-1.0.0/customers
Another issue is the api-docs link, this is wrong for the self hosted but correct for tomcat hosted environments. Both hosting environments including the application which is wrong when self hosted but then its not duplicated like all the others in tomcat:
http://localhost:8080/my-app-1.0.0/v2/api-docs
Also, the documentation is including the application path in the documentation (not duplicated here). The application path is not included when running self hosted.
I tried specifying the context path in the application.yml file but this had no effect (I tried both server.servlet.contextPath and server.servlet.context-path)
How can I get SpringFox to generate the correct URLs?

using apache camel REST DSL using restlet adding swagger

I am using apache camel REST DSL using springboot. All the configuration works fine. Now I want to add REST documentation using camel swagger java component. The REST DSL and swagger java, works out of the box. I can see the JSON output of the exposed REST services.
Now Question, what steps I need to follow, such that i can view camel REST documentation using swagger-ui?
I searched for answers, however the only solution was to download swagger-ui from github and "copy" <dist> folder to project, this doesn't seems to work, getting 404. URL i am using is localhost:8081\rest\index.html.
I liked the spring-fox swagger2, is it something can be supported in camel?
See this example which includes swagger ui.
https://github.com/apache/camel/tree/master/examples/camel-example-swagger-xml
The index.html file has more details how to access the swagger ui when the application runs.

Resources