strimzi-kafka-bridge icon indicating copy to clipboard operation
strimzi-kafka-bridge copied to clipboard

basePath value of the openapi spec at /openapi should reflect the actual path

Open elakito opened this issue 4 years ago • 2 comments

Currently, the openapi 2.0 spec returned at /openapi is statically set to /. When the Kafka-Bridge instance is behind a gateway and the gateway is taking requests at path e.g., /app/kafka-bridge and reverse-proxing to the bridge instance at path /, it would be more convenient if the returned openapi spec has basePath being set to /app/kafka-bridge instead of /, when the x-forwarded-prefix header of the request is available to derive the actual request path.

In this case, the client can, for example, issue a topics request at /app/kafka-bridge/topics instead of at /topics, knowing the correct basePath for this particular bridge instance.

This ticket is resulted from this preceding discussion https://github.com/strimzi/strimzi-kafka-bridge/issues/375#issuecomment-643159596

elakito avatar Jun 18 '20 13:06 elakito

@elakito I have just noticed that basePath is something only supported by OpenAPI 2.0. With OpenAPI 3.0, the new servers section is used. Our plan is about getting rid of OpenAPI 2.0 specification soon, providing the 3.0 specification on the /openapi endpoint so I was wondering how much it makes really sense to do the change in the https://github.com/strimzi/strimzi-kafka-bridge/pull/433

ppatierno avatar Jul 09 '20 10:07 ppatierno

@ppatierno if we are getting rid of openapiv2 any time soon, we won't need the v2 specific change. If we switch to return openapi(v3) at /openapi, we could either use a similar approach to overwrite the server's url between '/' or '/prefix-path' or simply use a variable notation '{basePath}' for that property and set its default value to '/' so that the consumer can decide on its value. For the latter case, we would just need a change in the spec file.

elakito avatar Jul 09 '20 21:07 elakito