Fix treating refereced schemas with simple types (string, integer) as nested

This commit is contained in:
Roman Hotsiy 2016-03-09 00:28:55 +02:00
parent 3f698caabe
commit 0a8440f44b
2 changed files with 11 additions and 7 deletions

View File

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

View File

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