ApiListingCache share same cache for different docRoots
gaeljw opened this issue · 0 comments
gaeljw commented
Hello,
Imagine you have 2 endpoints:
/public/swagger.json
-> should return the swagger definition for resource under/public
/private/swagger.json
-> should return the swagger definition for resource under/private
If you use ApiHelpController.getResource("/public")
in one endpoint and ApiHelpController.getResource("/private")
in the other, it won't work because there is a cache that keeps the Swagger definition and this cache is shared whatever the docRoot you use (/public
or /private
in this case).
The responsible code is the following in ApiListingCache
:
def listing(docRoot: String, host: String): Option[Swagger] = {
cache.orElse {
...
cache = Some(swagger)
cache
}
cache.get.setHost(host)
cache
}
IMHO, we should have a different cache per docRoot
value.