Swirrl / drafter

A clojure service and a client to it for exposing data management operations to PMD
Other
0 stars 0 forks source link

Wrong version of the swagger UI being served in production #660

Closed lkitching closed 1 year ago

lkitching commented 1 year ago

The drafter resources contain a modified version of the swagger UI which installs a request interceptor required by the auth0 authentication integration. The swagger UI is configured in drafter.swagger to locate swagger UI resources from the default location on the classpath. This is swagger-ui by default.

The ring-swagger-ui UI dependency puts most of the required resources on the classpath in this location. Both drafter, and the ring-swagger-ui dependency define a swagger-ui/index.html resource. The intention is the drafter version of the resource is the one that is resolved.

In production drafter is run via the drafter-start.sh script. This puts drafter.jar on the classpath after the lib depedencies, so it is likely this is causing the ring-swagger-ui version of index.html to be served instead of the drafter version. This does not contain the required request interceptor and breaks the auth0 integration.

We need to ensure the drafter version of the swagger index.html is loaded in all environments. It may be sufficient to change the java command in drafter-start.sh to put drafter.jar on the classpath first. Another option could be to builld an uberjar where the drafter version of index.html is always chosen via a conflict handler for the swagger-ui/index.html resource path.

scottlowe commented 1 year ago

I tried changing the classpath order in drafter-start.sh. I didn't necessariliy expect it to work, but worth a try. It didn't! 😄

Decided to explicitly set the swagger-ui resource root instead.