Reputation: 384
@RestController
@RequestMapping("/api")
public class ApplicationController {
@Autowired
private DBInitializer dbInitializer;
@Autowired
ApplicationService service;
@GetMapping
public List<ApplicationEntity> getAllNames() {
return dbInitializer.findAll();
}
@GetMapping(value = "/config")
public String getProperties() {
return service.getLinks();
}
}
That is my controller. In swagger-ui I am unable to view the
localhost:8181/api
However, I am able to view the
localhost:8181/api/config
Can anyone help me to get the base end point on swagger ui.
Thanks in advance !
Edit added - Swagger configuration
swagger:
title: DemoApp API
description: DemoApp API documentation
version: ${info.build.version:0.0.1}
termsOfServiceUrl:
contact:
license:
licenseUrl:
includePattern: "/.*"
Upvotes: 0
Views: 218
Reputation: 91
In your code, it seems there is no functionality on your root mapping i.e. /api
. Thus you may be getting the below error.
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jan 29 05:20:59 GMT 2019
There was an unexpected error (type=Not Found, status=404).
No message available
That is because you didn't give any functionality on your root.
If you want to see something when you call root method, you can try declaring a method with same mapping as
@GetMapping(value = "")
public String getRoot() {
// Your logic
}
That way when you call localhost:8181/api
, this method will be called.
Upvotes: 0
Reputation: 3305
Try assigining empty string in mapping value like following:
@GetMapping(value="")
public List<ApplicationEntity> getAllNames() {
return dbInitializer.findAll();
}
Upvotes: 1