Renamed JsonPointer.dirName to baseName

This commit is contained in:
Roman Gotsiy 2015-10-09 08:31:09 +03:00
parent cc5c324bc1
commit cf7391e5d9
3 changed files with 7 additions and 5 deletions

View File

@ -27,8 +27,8 @@ export class Method {
this.data = {}; this.data = {};
var methodInfo = this.schemaMgr.byPointer(this.pointer); var methodInfo = this.schemaMgr.byPointer(this.pointer);
this.data.method = JsonPointer.dirName(this.pointer); this.data.method = JsonPointer.baseName(this.pointer);
this.data.path = JsonPointer.dirName(this.pointer, 2); this.data.path = JsonPointer.baseName(this.pointer, 2);
this.data.methodInfo = methodInfo; this.data.methodInfo = methodInfo;
//TODO: check and apply hooks to modify data //TODO: check and apply hooks to modify data
} }

View File

@ -33,7 +33,6 @@ export class MethodsList {
this.data = {}; this.data = {};
var pathInfo = this.schemaMgr.byPointer(this.pointer); 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)); this.data.methods = Object.keys(pathInfo).filter((k) => swaggerMethods.has(k));
//TODO: check and apply hooks to modify data //TODO: check and apply hooks to modify data
} }

View File

@ -8,11 +8,14 @@ export class JsonPointer extends JsonPointerLib {
/** /**
* returns last JsonPointer token * returns last JsonPointer token
* if level > 1 returns levels last (second last/third last)
* @example * @example
* // returns subpath * // 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); var tokens = JsonPointer.parse(pointer);
return tokens[tokens.length - (level)]; return tokens[tokens.length - (level)];
} }