metosin / compojure-api-examples

Compojure API example
32 stars 19 forks source link

contextPath is missing from generated paths #3

Closed jsyrjala closed 10 years ago

jsyrjala commented 10 years ago
  1. Generate war lein ring uberwar
  2. Deploy war to tomcat or some other server sudo cp target/examples.jar /var/lib/tomcat/webapps/examples.war
  3. Access pizza api http://localhost:18080/examples/api/pizzas=> works as expected
  4. Access ui http://localhost:18080/examples/ => redirects to http://localhost:18080/index.html. Should redirect to http://localhost:18080/examples/index.html
  5. Access http://localhost:18080/examples/index.html (this is the correct URL), there is error Can't read swagger JSON from http://localhost:18080/api/api-docs

When war is deployed as a root war (that is, contextPath is '/') everything works.

Some component (swagger-ui?) should include contextPath to generated URLs.

jsyrjala commented 10 years ago

I took a look at code, some related locations:

https://github.com/metosin/compojure-api/blob/master/src/compojure/api/swagger.clj#L141 https://github.com/metosin/compojure-api/blob/master/src/compojure/api/swagger.clj#L124 https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/core.clj#L209 https://github.com/ring-clojure/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L63

ikitommi commented 10 years ago

Hi.

thanks for investigating. As you seem to have both the skills and interest to solve this, feel free to do a PR or send me a code snippet which fixed this :) This could help to check the required extra param for base paths under the legacy app server:

(GET* "/echo" req (ok (dissoc req :body)))

btw: https://groups.google.com/forum/#!topic/ring-clojure/AK4xdFOm0Qo

ikitommi commented 10 years ago

updates examples, there is now the new echo-endpoints to demo stuff.

ikitommi commented 10 years ago

works.