https://kotlinlang.org logo
#http4k
Title
# http4k
v

Volkan Nezir

06/13/2019, 1:53 PM
Hi - does anyone know how to set the basePath value in either OpenApi2 or OpenApi3? Without this the links in our swagger documentation are unable to be executed. We are currently using http4k v. 3.154.0. thanks.
d

dave

06/13/2019, 2:37 PM
The basepath should be automatically picked up by how the handler is bound. Check out the full example test and let us know if you still have problems working it out: https://github.com/http4k/http4k/blob/master/http4k-contract/src/test/kotlin/org/http4k/contract/ContractRendererContract.kt
There is no way to set it manually because it is set automatically.
v

Volkan Nezir

06/13/2019, 4:02 PM
@dave the problem is I don’t actually want to change the url as such, I only want it to be changed in the documentation i.e. the link that gets executed when a user tries to test an endpoint. The problem is we have proxies in front of our service that requests are routed to so our urls are prefixed with this information e.g.
Copy code
/routing1/routing2/my/actual/endpoint
so contract route is
Copy code
/my/actual/endpoint
but the swagger generated link needs to be the full url with routing prefix. I can’t think of a way around this other than handcrafting the swagger.json at this point.
d

dave

06/13/2019, 4:06 PM
Does that mean your endpoints are available on 2 different URLs depending on the host you use?
v

Volkan Nezir

06/13/2019, 6:58 PM
No the routing, or what I am referring to as the “base path” (possibly incorrectly), will be the same regardless of host, except when running locally where there is no proxy, but I am less concerned about that at this stage
d

dave

06/13/2019, 7:07 PM
Am a little confused then. The entire basepath (other than hostname) should be present in the OpenApi docs if its bound at the correct place in the http4k app. In this case I'd expect you to be mounting the whole contract at "/routing1/routing2"
And then each contract route at "my/actual/endpoint". The routes should compose
2 Views