diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 885646ce..9aa5ae42 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -27,8 +27,8 @@ export class Method { this.data = {}; var methodInfo = this.schemaMgr.byPointer(this.pointer); - this.data.method = JsonPointer.dirName(this.pointer); - this.data.path = JsonPointer.dirName(this.pointer, 2); + this.data.method = JsonPointer.baseName(this.pointer); + this.data.path = JsonPointer.baseName(this.pointer, 2); this.data.methodInfo = methodInfo; //TODO: check and apply hooks to modify data } diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 560711fe..145736e1 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -33,7 +33,6 @@ export class MethodsList { this.data = {}; var pathInfo = this.schemaMgr.byPointer(this.pointer); - this.data.path = JsonPointer.dirName(this.pointer); this.data.methods = Object.keys(pathInfo).filter((k) => swaggerMethods.has(k)); //TODO: check and apply hooks to modify data } diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index 12d8a204..dfb3d2a6 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -8,11 +8,14 @@ export class JsonPointer extends JsonPointerLib { /** * returns last JsonPointer token + * if level > 1 returns levels last (second last/third last) * @example * // returns subpath - * new JsonPointerHelper.dirName('/path/0/subpath') + * JsonPointerHelper.baseName('/path/0/subpath') + * // returns foo + * JsonPointerHelper.baseName('/path/foo/subpath', 2) */ - static dirName(pointer, level=1) { + static baseName(pointer, level=1) { var tokens = JsonPointer.parse(pointer); return tokens[tokens.length - (level)]; }