mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-27 16:14:08 +03:00
getMethodParams param semantic fix
This commit is contained in:
parent
d2d856067b
commit
8d91427206
|
@ -35,7 +35,7 @@ export default class Method extends BaseComponent {
|
|||
}
|
||||
|
||||
findBodyParam() {
|
||||
let pathParams = this.schemaMgr.getMethodParams(JsonPointer.join(this.pointer, 'parameters'), true);
|
||||
let pathParams = this.schemaMgr.getMethodParams(this.pointer, true);
|
||||
let bodyParam = pathParams.find(param => param.in === 'body');
|
||||
return bodyParam;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,9 @@ export default class SchemaManager {
|
|||
resolveRefs(obj) {
|
||||
Object.keys(obj).forEach(key => {
|
||||
if (obj[key].$ref) {
|
||||
obj[key] = this.byPointer(obj[key].$ref);
|
||||
let resolved = this.byPointer(obj[key].$ref);
|
||||
resolved._pointer = obj[key].$ref;
|
||||
obj[key] = resolved;
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
|
@ -76,18 +78,20 @@ export default class SchemaManager {
|
|||
});
|
||||
}
|
||||
|
||||
//get path params
|
||||
let ptr = JsonPointer.dirName(methodPtr, 2) + '/parameters';
|
||||
let pathParams = this.byPointer(ptr);
|
||||
if (Array.isArray(pathParams)) {
|
||||
pathParams = injectPointers(pathParams, ptr);
|
||||
} else if (pathParams && pathParams.$ref) {
|
||||
pathParams = injectPointers(this.byPointer(pathParams.$ref), pathParams.$ref);
|
||||
} else {
|
||||
pathParams = [];
|
||||
// accept pointer directly to parameters as well
|
||||
if (JsonPointer.baseName(methodPtr) === 'parameters') {
|
||||
methodPtr = JsonPointer.dirName(methodPtr);
|
||||
}
|
||||
|
||||
let methodParams = injectPointers(this.byPointer(methodPtr), methodPtr) || [];
|
||||
//get path params
|
||||
let pathParamsPtr = JsonPointer.join(JsonPointer.dirName(methodPtr), ['parameters']);
|
||||
let pathParams = this.byPointer(pathParamsPtr) || [];
|
||||
|
||||
let methodParamsPtr = JsonPointer.join(methodPtr, ['parameters']);
|
||||
let methodParams = this.byPointer(methodParamsPtr) || [];
|
||||
pathParams = injectPointers(pathParams, pathParamsPtr);
|
||||
methodParams = injectPointers(methodParams, methodParamsPtr);
|
||||
|
||||
if (resolveRefs) {
|
||||
methodParams = this.resolveRefs(methodParams);
|
||||
pathParams = this.resolveRefs(pathParams);
|
||||
|
|
Loading…
Reference in New Issue
Block a user