How to change url of Swagger SpringMVC UI - spring

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

Related

Quarkus+Apache Camel+Swagger ui

I'm currently working on Quarkus with swagger ui and followed a link to test it below link successfully https://quarkus.io/guides/openapi-swaggerui.
but is there any way to implement apache camel route with swagger ui in quarkus? kindly help me.
If you add the camel-quarkus-openapi-java extension to your application, then you can add documentation to your REST DSL routes and have it rendered as an OpenAPI document. There's more information on how to do this here:
https://camel.apache.org/manual/latest/rest-dsl.html
Then you can configure the default URL that the Swagger UI points to.
For example, assuming you configured your Camel OpenAPI documentation to be served at /openapi.yaml, you can configure the Quarkus Swagger UI extension to consume it.
camel.rest.api-context-path = /openapi.yaml
quarkus.swagger-ui.urls.camel = /openapi.yaml

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.

The HAL Browser doesn't get autoconfigured correctly in spring-data-rest

I have install HAL Browser in my spring boot app.
In the documentation they say it will be started at http://localhost:8080.
but it got started at http://localhost:8080/api which is my repositories.
So it override the base path of my spring-data-rest api.
Then inside the HAL browser app, I can see all of my repositories.
If I try a GET, it try's to query them under http://localhost:8080/api/api/entities , which return 404.
The original endpoint http://localhost:8080/api/entities also return 404.
Is the plugin broken with latest spring, spring-data, spring-hateoas modules ?
If I change the data rest api path to "/" it work fine.
Also, I would like to know if it's possible to authorize the client using OAuth. I use spring-security-oauth and all the request are rejected .
Edit It appear the plugin doesn't support different path than /
Also, it is not possible to support spring-data-oauth, my best chance is to install HAL Browser my self
You don't need to use complete URL like http://localhost:8080/api/entities
You should use only the URI like -
/api/api/entities

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 customize Grails Spring Security Core 2 login / logout controller and views?

I am using the new Grails Spring Security Core 2.0 plugin and am wondering how i can customize the login view and the LoginController/LogoutController?
The previous versions of the plugin generated these files but now it seems that I have to copy them from the plugin to my project. Is this the correct approach?
And if so, can I put the copied controllers and views into another package then the original ones. IntelliJ seems to dislike having the same artifacts in the same package.
By default in version 2.0 logouts are only allowed via POST requests. To change this to allow GET requests add the following to your Config.groovy file.
grails.plugin.springsecurity.logout.postOnly = false
Once you have that set you can link directly to logout controller in order to logout
<g:link controller="logout">logout</g:link>
If you want to find more info on what else was changed in version 2 look to the What's New in Version 2.0 documentation
Another option would be to use a remote link which by default uses the "post" method
<g:remoteLink class="logout" controller="logout">${message(code: 'springSecurity.logout.link')}</g:remoteLink>
I don't think any of the above answers actually answer the question.
If you want to override the controllers and the views in your web-app then yes copy them up into your web-app. You can even give them a different package hierarchy if you wish as the spring-security-core plugin seems to reference them by URL and yours would replace them.
This works because controllers and views declared in the main web-app take precedence over those that are in the plugins.
However if you are doing this in another plugin thats when things get a bit tricky. See this questiona and answer for a solution to that problem

Resources