mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +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 defaults = schema.default || {};
|
||||
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 =
|
||||
schema.required === undefined ? false : schema.required.indexOf(fieldName) > -1;
|
||||
|
||||
|
@ -217,8 +226,8 @@ function buildFields(
|
|||
name: fieldName,
|
||||
required,
|
||||
schema: {
|
||||
...props[fieldName],
|
||||
default: props[fieldName].default || defaults[fieldName],
|
||||
...field,
|
||||
default: field.default || defaults[fieldName],
|
||||
},
|
||||
},
|
||||
$ref + '/properties/' + fieldName,
|
||||
|
|
Loading…
Reference in New Issue
Block a user