5

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.

victorio
  • 6,224
  • 24
  • 77
  • 113
  • Yes you can have a single Swagger UI for multiple API definitions. See [How to organise/build a Swagger UI interface for a directory which contains many Swagger definition .json/.yml files](https://stackoverflow.com/questions/39521627/how-to-organise-build-a-swagger-ui-interface-for-a-directory-which-contains-many) and [Swagger UI with Multiple Urls](https://stackoverflow.com/q/44816594/113116) – Helen Jun 28 '18 at 10:48
  • 1
    Almost, but that answers are talking about index.html changes. But here I don't have index.html file, only the yaml itself. – victorio Jun 28 '18 at 10:53
  • Something like this then? [Override “host” and “basePath” at the “/{path}” level](https://stackoverflow.com/q/37157721/113116), [What is the significance of servers property in OpenAPI 3.0?](https://stackoverflow.com/q/50546573/113116) – Helen Jun 28 '18 at 10:56

1 Answers1

1

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.

Nikola Andreev
  • 624
  • 4
  • 18