From e8e27ffa8267c80dbc3f6f007f68aa04d932e65c Mon Sep 17 00:00:00 2001 From: agmikhailov <49522235+agmikhailov@users.noreply.github.com> Date: Tue, 25 May 2021 19:30:25 +0700 Subject: [PATCH] Fix go-swagger throws error on Windows if application path contains parentheses #145 Signed-off-by: Aleksey Mikhaylov --- schema_loader.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/schema_loader.go b/schema_loader.go index 0059b99..b81175a 100644 --- a/schema_loader.go +++ b/schema_loader.go @@ -168,7 +168,14 @@ func (r *schemaLoader) load(refURL *url.URL) (interface{}, url.URL, bool, error) normalized := normalizeBase(pth) debugLog("loading doc from: %s", normalized) - data, fromCache := r.cache.Get(normalized) + unescaped, err := url.PathUnescape(normalized) + if err != nil { + return nil, url.URL{}, false, err + } + + u := url.URL{Path: unescaped} + + data, fromCache := r.cache.Get(u.RequestURI()) if fromCache { return data, toFetch, fromCache, nil }