Multiple API documentation in one Swagger file

victorio picture victorio · Jun 28, 2018 · Viewed 9.2k times · Source

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.

Answer

Nikola Andreev picture Nikola Andreev · Jun 24, 2020

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.