mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-23 00:56:33 +03:00
fix: add extra null-check + warning
This commit is contained in:
parent
a78f9ab688
commit
8757fa510a
|
@ -208,6 +208,15 @@ function buildFields(
|
||||||
const additionalProps = schema.additionalProperties;
|
const additionalProps = schema.additionalProperties;
|
||||||
const defaults = schema.default || {};
|
const defaults = schema.default || {};
|
||||||
const fields = Object.keys(props || []).map(fieldName => {
|
const fields = Object.keys(props || []).map(fieldName => {
|
||||||
|
let field = props[fieldName];
|
||||||
|
|
||||||
|
if (!field) {
|
||||||
|
console.warn(
|
||||||
|
`Field "${fieldName}" is invalid, skipping.\n Field must be an object but got ${typeof field} at "${$ref}"`,
|
||||||
|
);
|
||||||
|
field = {};
|
||||||
|
}
|
||||||
|
|
||||||
const required =
|
const required =
|
||||||
schema.required === undefined ? false : schema.required.indexOf(fieldName) > -1;
|
schema.required === undefined ? false : schema.required.indexOf(fieldName) > -1;
|
||||||
|
|
||||||
|
@ -217,8 +226,8 @@ function buildFields(
|
||||||
name: fieldName,
|
name: fieldName,
|
||||||
required,
|
required,
|
||||||
schema: {
|
schema: {
|
||||||
...props[fieldName],
|
...field,
|
||||||
default: props[fieldName].default || defaults[fieldName],
|
default: field.default || defaults[fieldName],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
$ref + '/properties/' + fieldName,
|
$ref + '/properties/' + fieldName,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user