From bdf60794f3430a26dac6284fc4f7760e0c6cbfc4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 23 Nov 2017 16:08:39 +0200 Subject: [PATCH] fix: crash when $ref is url encoded reported by @mikunn --- package.json | 2 +- src/services/OpenAPIParser.ts | 1 + yarn.lock | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 4770afab97..3c6a8e2038 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "json-schema-ref-parser": "^3.3.1", "mobx": "^3.3.0", "mobx-react": "^4.3.3", - "openapi-sampler": "^1.0.0-beta.1", + "openapi-sampler": "1.0.0-beta.8", "prismjs": "^1.8.1", "prop-types": "^15.6.0", "react-dropdown": "^1.3.0", diff --git a/src/services/OpenAPIParser.ts b/src/services/OpenAPIParser.ts index ec2429095b..af9896ea0d 100644 --- a/src/services/OpenAPIParser.ts +++ b/src/services/OpenAPIParser.ts @@ -89,6 +89,7 @@ export class OpenAPIParser { let res; if (this.spec === undefined) return; if (ref.charAt(0) !== '#') ref = '#' + ref; + ref = decodeURI(ref); try { res = JsonPointer.get(this.spec, decodeURIComponent(ref)); } catch (e) { diff --git a/yarn.lock b/yarn.lock index 8e3452fc85..5d9c41dd7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4670,9 +4670,9 @@ ono@^4.0.2: dependencies: format-util "^1.0.3" -openapi-sampler@^1.0.0-beta.1: - version "1.0.0-beta.7" - resolved "https://registry.yarnpkg.com/openapi-sampler/-/openapi-sampler-1.0.0-beta.7.tgz#4932a3994067af86f95cb912ee56d01123e27d88" +openapi-sampler@1.0.0-beta.8: + version "1.0.0-beta.8" + resolved "https://registry.yarnpkg.com/openapi-sampler/-/openapi-sampler-1.0.0-beta.8.tgz#bf43ff47737fc4e1f988d0e2082d49788f41dead" dependencies: json-pointer "^0.6.0"