mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-11 21:35:47 +03:00
JsonSchema: display object without properties as a simple type
This commit is contained in:
parent
da5224e3e2
commit
9860e31049
|
@ -63,13 +63,6 @@ export default class JsonSchema extends BaseComponent {
|
||||||
this.componentSchema.required.forEach(prop => this.requiredMap[prop] = true);
|
this.componentSchema.required.forEach(prop => this.requiredMap[prop] = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!schema.properties) {
|
|
||||||
this.isTrivial = true;
|
|
||||||
this._displayType = schema.type;
|
|
||||||
this._displayTypeHint = 'This field may contain data of any type';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let discriminatorFieldIdx = -1;
|
let discriminatorFieldIdx = -1;
|
||||||
let props = Object.keys(schema.properties).map((prop, idx) => {
|
let props = Object.keys(schema.properties).map((prop, idx) => {
|
||||||
let propData = schema.properties[prop];
|
let propData = schema.properties[prop];
|
||||||
|
@ -108,13 +101,13 @@ export default class JsonSchema extends BaseComponent {
|
||||||
propData.format = itemFormat;
|
propData.format = itemFormat;
|
||||||
propData._isArray = true;
|
propData._isArray = true;
|
||||||
propData.type = 'array ' + propData.items.type;
|
propData.type = 'array ' + propData.items.type;
|
||||||
} else if (propData.type === 'object') {
|
} else if (propData.type === 'object' && propData.properties) {
|
||||||
propData._displayType = propData.title || 'object';
|
propData._displayType = propData.title || 'object';
|
||||||
} else if (!propData.type) {
|
} else if (!propData.type) {
|
||||||
propData._displayType = '< * >';
|
propData._displayType = '< * >';
|
||||||
propData._displayTypeHint = 'This field may contain data of any type';
|
propData._displayTypeHint = 'This field may contain data of any type';
|
||||||
} else {
|
} else {
|
||||||
// here we are sure that property has simple type
|
// here we are sure that property has simple type (integer, string, object withou properties)
|
||||||
// delete pointer for simple types to not show it as subschema
|
// delete pointer for simple types to not show it as subschema
|
||||||
if (propData._pointer) {
|
if (propData._pointer) {
|
||||||
propData._pointer = undefined;
|
propData._pointer = undefined;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user