Optum / kong-spec-expose

Plugin to expose the specification/contract of auth protected API services fronted by the Kong gateway
Apache License 2.0
5 stars 3 forks source link

How to configure and invoke is not clear #1

Closed satishmane closed 5 years ago

satishmane commented 5 years ago

Hi,

my swagger documentation full url is http://apidns:port/documentation.

I configured plug in at global level with swagger documentation url which is spec url : http://apidns:port/documentation.

When I call same url http://kongdns:port/documentation from browser, it says route not found.

How do I configure and invoke documentation

jeremyjpj0916 commented 5 years ago

Hello @satishmane ,

Have you created a Kong route with a path on your gateway yet too with auth protection? https://konggateway.com/my/proxy/route/path ?

Because once you have a proxy route established then you will be able to call:

https://konggateway.com/my/proxy/route/path /specz

To reach the specification documentation of your exposed spec. As a global plugin on Kong it makes less sense because every route you create on the gateway will expose the same spec, and if you have multiple services with different spec documents then you won't be able to expose them all properly, so my suggestion would be create plugin on route unless you only have on api service/spec behind your gateway(then global would work but you still need a Kong proxy route created for it to path off of.

satishmane commented 5 years ago

thanks for quick reply. Yes, after adding plug-in at route level, it is able to call documentation url. However it does not solve my problem. Basically I have swagger http://apidns:port/documentation. When I call this url from browser, it calls several api automatically to load swagger complete documentation page for all apis e.g. /documentation results into /swaggerui /swagger.json etc. Does this plug-in not handle internal calls to /swaggerui /swagger.json etc when /documentation is called from browser

jeremyjpj0916 commented 5 years ago

This plugin simply does a GET HTTP request on the URL mentioned in spec expose and returns that to client, if its a wsdl/wadl/openapi spec the content will load. As for loading a swagger ui page I am not entirely sure that works by default as its not how we use this plugin internally. Maybe a CORS issue?

hewg520 commented 2 years ago

Is there support for the function of swagger document aggregation? When I used the Kong-spec-expose plug-in officially provided by Kong, I found config spec_ URL variable only supports one API Spec URL?

jeremyjpj0916 commented 2 years ago

Your correct it only supports 1 spec per configured proxy essentially. In a micro-service world where you have proxies per micro-service and each micro-service exposes their own OAS spec this model makes sense. Whats your use case?

hewg520 commented 2 years ago

Thank you for your prompt reply。

My use case is that when I have hundreds or thousands of microservices, developers need to individually access (or remember) the url of swagger-ui corresponding to each microservice each time, which is really cumbersome. Similar to springcloud gateway integration knife4j, you can easily switch to the api spec of other microservices only in one swagger-UI page.just like this:

image

felpasl commented 2 years ago

I have the same but all my swagger file and UI are behind http://service:port/swagger/ I have hundreds of them I need expose this URL without authentication used by other routes or plugins in kong, but it's a relative path of my original service route.

in some way apply one plugin to all routes to expose the swagger 1:*, not 1:1