mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +03:00
fix: nullable object's fields were missing (#1721)
This commit is contained in:
parent
919a5f02fb
commit
ddf297b112
|
@ -63,20 +63,15 @@ export class Schema extends React.Component<Partial<SchemaProps>> {
|
|||
return <OneOfSchema schema={schema} {...this.props} />;
|
||||
}
|
||||
|
||||
if (type && Array.isArray(type)) {
|
||||
const types = Array.isArray(type) ? type : [type];
|
||||
if (types.includes('object')) {
|
||||
if (schema.fields?.length) {
|
||||
return <ObjectSchema {...(this.props as any)} />;
|
||||
}
|
||||
} else if (types.includes('array')) {
|
||||
return <ArraySchema {...(this.props as any)} />;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'object':
|
||||
if (schema.fields?.length) {
|
||||
return <ObjectSchema {...(this.props as any)} />;
|
||||
}
|
||||
break;
|
||||
case 'array':
|
||||
return <ArraySchema {...(this.props as any)} />;
|
||||
}
|
||||
|
||||
// TODO: maybe adjust FieldDetails to accept schema
|
||||
const field = ({
|
||||
schema,
|
||||
|
|
|
@ -100,6 +100,10 @@ export class SchemaModel {
|
|||
this.activeOneOf = idx;
|
||||
}
|
||||
|
||||
hasType(type: string) {
|
||||
return this.type === type || (Array.isArray(this.type) && this.type.includes(type));
|
||||
}
|
||||
|
||||
init(parser: OpenAPIParser, isChild: boolean) {
|
||||
const schema = this.schema;
|
||||
this.isCircular = schema['x-circular-ref'];
|
||||
|
@ -170,9 +174,9 @@ export class SchemaModel {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.type === 'object') {
|
||||
if (this.hasType('object')) {
|
||||
this.fields = buildFields(parser, schema, this.pointer, this.options);
|
||||
} else if ((this.type === 'array' || Array.isArray(this.type)) && schema.items) {
|
||||
} else if (this.hasType('array') && schema.items) {
|
||||
this.items = new SchemaModel(parser, schema.items, this.pointer + '/items', this.options);
|
||||
this.displayType = pluralizeType(this.items.displayType);
|
||||
this.displayFormat = this.items.format;
|
||||
|
|
Loading…
Reference in New Issue
Block a user