From 8afa4d6c323c09fc955e88576021ca86c3d12613 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 9 Mar 2016 00:28:55 +0200 Subject: [PATCH] Fix treating refereced schemas with simple types (string, integer) as nested --- lib/components/JsonSchema/json-schema.js | 15 +++++++++------ lib/components/ParamsList/params-list.js | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index ce42f923..02b7940c 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -108,15 +108,18 @@ export default class JsonSchema extends BaseComponent { propData.format = itemFormat; propData._isArray = true; propData.type = 'array ' + propData.items.type; - } - - if (propData.type === 'object') { + } else if (propData.type === 'object') { propData._displayType = propData.title || 'object'; - } - - if (!propData.type) { + } else if (!propData.type) { propData._displayType = '< * >'; propData._displayTypeHint = 'This field may contain data of any type'; + } else { + // here we are sure that property has simple type + // delete pointer for simple types to not show it as subschema + if (propData._pointer) { + propData._pointer = undefined; + propData._displayType = propData.title ? `${propData.title} (${propData.type})` : propData.type; + } } if (propData.format) propData._displayFormat = `<${propData.format}>`; diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index 1a053b5b..957d18b4 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -26,6 +26,7 @@ export default class ParamsList extends BaseComponent { paramsList = paramsList.map((paramData) => { let propPointer = paramData._pointer; + if (paramData.in === 'body') return paramData; return JsonSchema.injectPropData(paramData, paramData.name, propPointer); }); @@ -35,7 +36,7 @@ export default class ParamsList extends BaseComponent { let bodyParam = paramsMap.body[0]; bodyParam.pointer = bodyParam._pointer; this.data.bodyParam = bodyParam; - delete paramsMap.body; + paramsMap.body = undefined; } this.data.noParams = !(Object.keys(paramsMap).length || this.data.bodyParam);