mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +03:00
Fixed parameters list issues
This commit is contained in:
parent
b30bf98402
commit
01990f265a
|
@ -15,9 +15,10 @@ export class ParamsList extends BaseComponent {
|
|||
|
||||
prepareModel() {
|
||||
this.data = {};
|
||||
let params = this.componentSchema;
|
||||
let pathParams = this.getPathParams();
|
||||
if (pathParams) params.concat(pathParams);
|
||||
let params = this.componentSchema || [];
|
||||
let pathParams = this.getPathParams() || [];
|
||||
params = params.concat(pathParams);
|
||||
params = this.resolveRefs(params);
|
||||
this.sortParams(params);
|
||||
|
||||
// temporary hanlde body param
|
||||
|
@ -45,6 +46,16 @@ export class ParamsList extends BaseComponent {
|
|||
return [];
|
||||
}
|
||||
|
||||
resolveRefs(params) {
|
||||
return params.map(param => {
|
||||
if (param.$ref) {
|
||||
return this.schemaMgr.byPointer(param.$ref);
|
||||
} else {
|
||||
return param;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
sortParams(params) {
|
||||
const sortOrder = {
|
||||
'path' : 0,
|
||||
|
@ -54,6 +65,6 @@ export class ParamsList extends BaseComponent {
|
|||
'body': 50
|
||||
};
|
||||
|
||||
params.sort((a, b) => sortOrder[a] - sortOrder[b]);
|
||||
params.sort((a, b) => sortOrder[a.in] - sortOrder[b.in]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,11 @@ export class JsonPointer extends JsonPointerLib {
|
|||
if (ptr.charAt(0) === '#') {
|
||||
ptr = ptr.substring(1);
|
||||
}
|
||||
return JsonPointerLib.parse(ptr);
|
||||
return JsonPointerLib._origParse(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
JsonPointerLib._origParse = JsonPointerLib.parse;
|
||||
JsonPointerLib.parse = JsonPointer.parse;
|
||||
|
||||
export default JsonPointer;
|
||||
|
|
Loading…
Reference in New Issue
Block a user