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

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?

Related

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.

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

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

Generate api documentation without creating rest with swagger2

I'm new to spring and swagger so I have some difficulties with generating API documentation using swagger. I've done API documentation at http://localhost:8080/swagger-ui.html, but I have to export generated API documentation to the other website. Is there a way to generate just json or yml file without displaying documentation at swagger-ui.html?

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