var ErrAPIServiceNotFound = errors.New("resource not found")
type CacheableDownloader interface { UpdateHandler(http.Handler) Get() (*spec.Swagger, string, error) }
func NewCacheableDownloader(apiServiceName string, downloader *Downloader, handler http.Handler) CacheableDownloader
NewCacheableDownloader creates a downloader that also returns the etag, making it useful to use as a cached dependency.
Downloader is the OpenAPI downloader type. It will try to download spec from /openapi/v2 or /swagger.json endpoint.
type Downloader struct { }
func NewDownloader() Downloader
NewDownloader creates a new OpenAPI Downloader.
func (s *Downloader) Download(handler http.Handler, etag string) (returnSpec *spec.Swagger, newEtag string, httpStatus int, err error)
Download downloads openAPI spec from /openapi/v2 endpoint of the given handler. httpStatus is only valid if err == nil
SpecAggregator calls out to http handlers of APIServices and merges specs. It keeps state of the last known specs including the http etag.
type SpecAggregator interface { AddUpdateAPIService(apiService *v1.APIService, handler http.Handler) error // UpdateAPIServiceSpec updates the APIService. It returns ErrAPIServiceNotFound if the APIService doesn't exist. UpdateAPIServiceSpec(apiServiceName string) error RemoveAPIService(apiServiceName string) }
func BuildAndRegisterAggregator(downloader *Downloader, delegationTarget server.DelegationTarget, webServices []*restful.WebService, config *common.Config, pathHandler common.PathHandler) (SpecAggregator, error)
BuildAndRegisterAggregator registered OpenAPI aggregator handler. This function is not thread safe as it only being called on startup.