getMethodParams param semantic fix

This commit is contained in:
Roman Hotsiy 2015-12-12 17:29:50 +02:00
parent d2d856067b
commit 8d91427206
2 changed files with 16 additions and 12 deletions

View File

@ -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;
}

View File

@ -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);