Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

ApiListingCache share same cache for different docRoots #204

Open
gaeljw opened this issue May 27, 2019 · 0 comments
Open

ApiListingCache share same cache for different docRoots #204

gaeljw opened this issue May 27, 2019 · 0 comments

Comments

@gaeljw
Copy link

gaeljw commented May 27, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant