Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple API documentation in one Swagger file

Is it possible to have multiple (somehow separated) REST API documentations but only in one swagger yaml file?

Or can the swagger yaml contain only one API documentation?

Because I have 2 REST API developed by me, and I want to have a common swagger ui instead of two, which I could manage with a gateway like Tyk.

like image 974
victorio Avatar asked Nov 07 '22 05:11

victorio


1 Answers

You can do it with swagger.io tags

For example in spring (springfox-swagger) you need just to put the same tag on multiple API classes and it will merge them in one group in the swagger UI.

@Api(value = "First API", tags = {"first-api"})  
public class FirstApi { ... }

@Api(tags = {"first-api"})  
public class SecondApi { ... }

In the swagger UI you will see only one API (first-api) with all the methods inside from both classes.

like image 166
Nikola Andreev Avatar answered Nov 15 '22 08:11

Nikola Andreev