Appreciate direction on best way to leverage the basePath feature of swagger-ui
New to Swagger,
I am needing to specify an alternative path to be used in the try it exec section of swagger api documentation.
i.e. Need "/api" to be introduce only in the try it exec section
- Curl:
curl -X GET "http://localhost:8080/myproject-mw/api/myOneOfMyEndPoint" -H "accept: application json"
- Request URL:
http://localhost:8080/myproject-my/api/myOneOfMyEndPoint
But, due to the specific implementation (out of my control) of the front and back end design ... the normal mapping (via RequestMapping anotation) needs to remian without the "/api" (i.e. "/myOneOfMyEndPoint" without the prepended "/api" ) in order for the front end to be able to work with the back end.
@RequestMapping(value = "/myOneOfMyEndPoint", method = RequestMethod.GET, produces = "application/json")
@ApiOperation(value = "Method to fetch blah, blah and more blah in the system",
notes = "Method to fetch all blah, blah and more blah in the system that will return - myCustomPageDTO",
response = myCustomPageDTO.class,
responseContainer = "myCustomPageDTO")
public StatusPageDTO myOneOfMyEndPoint() {
.... my code ....
}
So, currently ...
I have the swagger-ui.html (dynamic redering) working with annotation. Using the following...
<springfox-swagger2-version>2.8.0</springfox-swagger2-version>
<springfox-swaggerui-version>2.8.0</springfox-swaggerui-version>
- I think and hope that one solution could be with using / leveraging basePath, but not sure what would be the best way to do so.
Any direction / suggestion would be appriciated.
NOTE: THE FOLLOWING WAS THE MINIMUM THAT I NEEDED TO INTRODUCE SWAGGER-UI TO THE EXSISTING PROJECT (swagger-ui works as expected but need the custom URL in try it area):
1) Added the two lines ("<springfox- ... >") to pom.xml :
<properties>
...
<springfox-swagger2-version>2.8.0</springfox-swagger2-version>
<springfox-swaggerui-version>2.8.0</springfox-swaggerui-version>
</properties>
2) Added the two <dependency> for "<!--SpringfoxSwaggerdependency -->" and four <dependency> for "<!-- Jaxbdependency -->" to pom.xml :
<dependencies>
...
3) Added the import and @ApiOperation() to ExsistingController.java :
import io.swagger.annotations.ApiOperation;
...
4) Added the two <mvc:resources ...> to src/main/webapp/WEB-INF/spring-servlet.xml :
5) Added the one line "<!-- Swagger2 Configuration -->" to src/main/webapp/WEB-INF/spring-servlet.xml :
<beans>
...
...
</beans>