Springdoc Open API UI - BaseLayout doesn't works - spring

I went through: https://springdoc.org/springdoc-properties.html#springdoc-openapi-core-properties before raisng the question, but look like things are not working.
I want to use BaseLayout and also wanted to change the theme of the Open API Specification response as its in black.
I am using Spring Boot v2.2.2.RELEASE and springdoc-openapi-ui V1.2.30.
# Open API Configurations
springdoc.api-docs.path=/api-docs
springdoc.swagger-ui.path=/swagger-ui-ref.html
springdoc.swagger-ui.display-request-duration=true
springdoc.swagger-ui.tagsSorter=alpha
springdoc.swagger-ui.doc-expansion=no
springdoc.swagger-ui.layout=BaseLayout
Even after putting the above configurations, default configuration is not taking into an effect.

This issue is fixed since v1.2.31:
https://github.com/springdoc/springdoc-openapi/issues/536

Related

Open API (Swagger) non working in Spring Boot when adding context path

I have a Spring Boot application exposing REST services that are easily called on addresses like
http://localhost:8080/<controller_mapping>/<service_mapping>.
I've been asked to modify my settings in order to add a context path and have my services to respond on
http://localhost:8080//gesev-mensa/<controller_mapping>/<service_mapping>.
Thus I edited my application.properties adding
server.servlet.context-path=/gesev-mensa
Everything works but I can't call Swagger on old address
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
I get the error Failed to load remote configuration
As suggested, I tried to add property
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
but problem persists.
I guess Swagger should be reachable at
http://localhost:8080/gesev-mensa/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
but that doesn't work.
Any hint?
Thanks for support.
Try removing
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
from your properties,
And your swagger will be available in
http://localhost:8080/gesev-mensa/swagger-ui/index.html
As per your current configuration with,
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
Swagger will be available in
http://localhost:8080/gesev-mensa/gesev-mensa/swagger-ui/index.html

How to hide Models section from swagger UI in spring boot?

I have a spring boot project in which I have integrated the swagger, for API documentation.
Now the problem is by default it is displaying the Models section, which is a security concern. I have tried, but unable to hide it. Also have gone through this link here
How to hide the Models section in Swagger UI?
But in this also, they are refering to some index.html file, but I only have backend with no frontend. So how to achieve the same, please help.
Thanks
Found it, Look at this github link.
https://github.com/eugenp/tutorials/blob/master/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/swagger2boot/configuration/SpringFoxConfig.java

Custom swagger documentation/ Where is my swagger setup?

I have a jhipster based Spring project, which uses yarn/angular on the front end, and Spring on the back. I am with trying to figure out how to customize the swagger page. Currently it auto-populates new API's using swagger-ui, which is great, but I needed to add more custom info to those API's, hence my problem.
But I'm confused on what's running swagger. It looks like there's a node package called swagger-ui-dist and I also see a src/main/webapp folder with a swagger-ui folder, containing an index.html page.
I think what I pretty much want is to replace the current swagger-ui auto setup, with swagger that reads a file that I can create online using Swagger editor.
Apologies, for what I hope are simple questions. I'm brand new at swagger and npm/yarn.
Thanks
So after a bit more research, I found you could create your own OpenAPI doc, but an easier method in Spring is to annotate the endpoint methods with the #APIOperation annotation. There are other swagger specific annotations as well.
In the parameters, you can give value="", notes="" and a number of other customized values that will clarify what your API does in Swagger. Then swagger auto fills it in when bringing up your swagger page.
I hope that helps anyone with the same issue I had.

How to set up a swagger-ui standalone server/application?

I would like to set up a standalone swagger-ui application, to view the different APIs from different servers in one central place.
In a second step I would like to customise swagger-ui to show multiple APIs at once.
I don't want to add swagger-ui to all the servers that provide swagger api-docs though.
To do so I would like to use spring boot and thought this should be an easy task. However, I have trouble getting it to work.
Here is what I did:
Generated a Spring Boot application using https://start.spring.io
included spring-boot-starter-web
added io.springfox:springfox-swagger-ui:2.3.1 dependency
When opening http://localhost:8080/swagger-ui.html I see a 404 error and UI seems broken:
Is there any reason for using Spring-boot instead of a simple web server for this?
See for example here with Nginx, including some basic authentication (pretty old link but still looking alright), or in the ReadMe of the swagger-ui github reposiory directly for easily serving with Connect/gulp-serve inside Docker (the setup can also be reproduced directly without Docker if wanted).
Also I have no idea why you're getting resources requested by the page on a different port... Just ask in case you still need help now on this topic.

How to change url of Swagger SpringMVC UI

I use swagger-springmvc in a spring-boot project and everything works fine but when I add the swagger-spring-mvc-ui dependency to my project, swagger-ui overloads my request mapping for the base url. I'm pretty shure there's a way to point the UI to another url. Does anybody know how to change the default-path of swagger-ui?
You are using old version 0.8.8 which from com.mangofactory
I recommend you to use version 2.3.1 from io.springfox
Note: If you follow the tutorial you can access swagger without having to download Swagger-UI manually
http://localhost:8080/your-app-root/swagger-ui.html
Document Url is now available at
http://localhost:8080/your-app-root/v2/api-docs
You can change document url by specifying a property source in appication.properties file using
springfox.documentation.swagger.v2.path
reference to the changes
spring boot demo
tutorial

Resources