I created one micro service with spring boot, I don't have resource folder and i wanted to add swagger support. So I followed as per document
So
Added swagger dependency.
Added docker class as it is
Added swagger's ui dependency
Results
http://localhost:port/myservice/v2/api-docs ->
Response is as per expectation.
http://localhost:port/myservice/v2/api-docs ->
Response is as per expectation.
But
http://localhost:port/myservice/swagger-ui.html ->
Not expected response, on browser console i am getting error
GET http://localhost:port/myservice/configuration/ui 404 (Not Found)
As its microservice, I don't have #EnableWebMvc class.
What Am I missing ?
I had the same problem. Downgrading springfox-swagger-ui to 2.2.2 fixed my problem (as mentioned in the comments by sailor.
Related
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
When I run locally my Spring Boot application with added dependencies springdoc-openapi-ui, I expect to get generated swagger api form for rest methods at url
http://localhost:55555/swagger-ui/index.html, but instead I get response with empty array []. But if I open http://localhost:55555/v3/api-docs, it shows openapi specification for rest methods.
There is no warnings in application log. How can I troubleshoot this library?
P.S. Swagger api form was working shortly before this moment. When problem had been occured, I removed any related configuration properties and beans, but the problem remained
Building a new project downloaded using https://start.spring.io/ does not run on browser.
I have seen some solutions on stackoverflow which require to make some changes or add, but default/out-of-the-box application does not run.
I asked this in Github https://github.com/spring-projects/spring-boot/issues/20603 but was told that i need to add request mappings or something else. There's no default mapping for the root. That's indeed the default error page showing you a 404.
Is there a documentation to "add request mappings or something else" ? It will help if the application run showing some text instead of an error message. This maybe a simple obvious thing for Spring developers but for learners, takes a lot of effort.
http://localhost:8080/
STEPS TO REPRODUCE:
Download new project at https://start.spring.io/
mvn clean package
mvn spring-boot:run
That is the expected behavior right after creating a fresh Spring Boot project. The initializer does not register any endpoint for you, it just gives you the project skeleton you can start working with.
If you want to see something on localhost:8080/ consider adding the following Java class to your project:
#RestController
public class HelloWorldController {
#GetMapping
public String helloWorld() {
return "Hello World!";
}
}
If you are new to Spring/Spring Boot, I can recommend the following resources:
Official Spring Web documentation
Spring Boot Guides
Developing a CRUD API with Spring Boot YouTube course
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
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.