diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index c4dd89e9..f3036d4a 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -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]); } } diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index 96337138..bd5851cd 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -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;