mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +03:00
Renamed JsonPointer.dirName to baseName
This commit is contained in:
parent
cc5c324bc1
commit
cf7391e5d9
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user