Ask a Question

Extend swagger ui with own endpoints

pete_123
New Contributor

Extend swagger ui with own endpoints

We are using Swagger Ui with Spring Boot and use some of the spring boot "magic" crud methods like findAllById which can automatically be translated into a query. In addition we added some endpoints in the Repository classes with native queries. They don't appear in the swagger ui that can be called from the browser via http://localhost:8080/rest/swagger-ui.html

Our personalized endpoints work as expected, but are not documented in the swagger ui.

 

Can you please give me a hint how to extend the api interface? Some keywords to search for would probably be plenty to read more about this topic.

 

Thanks and kind regards, Pete

2 REPLIES 2
ponelat
Staff

Hi @pete_123 

 

The best starting point will be the exact (Spring) library used to render SwaggerUI (and more importantly, the OpenAPI.json file that powers SwaggerUI).

 

Two that I can think of include https://github.com/springdoc/springdoc-openapi and http://springfox.github.io/ .

 

Typically you'd add annotations to your classes and methods to add them as REST controllers and the library should pick those up, if not there may be a missing configuration or you may need to add other annotations. It'll depend on which library is used.

 

Hope that helps!

 

pete_123
New Contributor

Thanks a lot! That helped me to continue searching for a solution. I didn't find any OpenApi dependencies, but many comments saying it's used. I'll look for the mentioned annotations and try them out. Hopefully this solves the issue.

 

Great help! Thanks!

cancel
Showing results for 
Search instead for 
Did you mean: