user1022788
user1022788

Reputation: 447

API Gateway (Kong or Tyk):. Can I have swagger-ui on gateway?

I am in the process of implementing an API Gateway as a point of access to several existing APIs that run as microservices.

Each microservice API is defined in OpenAPI and runs an instance of swagger-ui to document and expose endpoints. Everything is written in Ruby on Rails as separate API-only projects.

I'm looking at Kong or Tyk in the role of API Gateway. Is it possible with either project to run swagger-ui on the gateway to document available routes through the gateway and to allow authenticated users to try the various endpoints exposed by the different services in one place rather than per-service? If not, does either project provide such an interface in any form?

Upvotes: 0

Views: 2819

Answers (3)

user18125870
user18125870

Reputation: 16

Yes for Tyk. You can design with Swagger-UI and import the generated OpenAPI specification into Tyk gateway for the routes. The gateway immediately populates the routes and start proxying API traffic. You can then choose to further enforce authentication or add middleware to these routes.

https://tyk.io/docs/getting-started/using-oas-definitions/create-an-oas-api/

For consumption, you can also publish APIs on to Tyk's developer portal with OpenAPI documentation.

https://tyk.io/docs/tyk-stack/tyk-developer-portal/enterprise-developer-portal/getting-started-with-enterprise-portal/publish-api-products-and-plans/

Upvotes: 0

user2311578
user2311578

Reputation: 943

Speaking for Kong, it does not provide this. But you can host a Swagger-UI instance behind the gateway just like a regular service. Swagger-UI is capable of serving multiple specs. Have a look at the urls parameter of the config:

https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/

You will get a dropdown box on the top right to select the desired service.

The swagger docs should have a server url according to your API gateway and also the desired authentication scheme(s). If the request goes through an API gateway, it must have the correct authentication mechanism in place.

Keep in mind that you may have to have CORS configured, if Swagger-UI and your services are served from different domains.

Upvotes: 1

Teknetik
Teknetik

Reputation: 178

I am only familiar with Kong so I can only speak for that product. Kong has what is known as the "developer portal" it is intended to integrate with the gateway itself and serve API specs to allow consumers to view.

You could certainly serve your own HTML-type applications via the Kong Gateway product too but this might be an optimal solution to save the resource required to do so.

Personally, I use their Insomnia product (like postman) to maintain and push the Swagger specs direct to the dev portal.

Upvotes: 0

Related Questions