fix: The number of items in the array in the array is incorrect #1762

This commit is contained in:
Andriy Zaleskyy 2021-10-05 18:24:46 +03:00
parent bccd21394e
commit d3d16464bb
2 changed files with 6 additions and 7 deletions

View File

@ -13,15 +13,10 @@ const PaddedSchema = styled.div`
export class ArraySchema extends React.PureComponent<SchemaProps> {
render() {
const itemsSchema = this.props.schema.items!;
const itemsSchema = this.props.schema.items;
const schema = this.props.schema;
const itemConstraintSchema = (
min: number | undefined = undefined,
max: number | undefined = undefined,
) => ({ type: 'array', minItems: min, maxItems: max });
const minMaxItems = humanizeConstraints(itemConstraintSchema(itemsSchema?.schema?.minItems, itemsSchema?.schema?.maxItems));
const minMaxItems = humanizeConstraints(schema);
if (schema.displayType && !itemsSchema && !minMaxItems.length) {
return (<div>

View File

@ -63,6 +63,8 @@ export class SchemaModel {
const: any;
contentEncoding?: string;
contentMediaType?: string;
minItems?: number;
maxItems?: number;
/**
* @param isChild if schema discriminator Child
@ -128,6 +130,8 @@ export class SchemaModel {
this.const = schema.const || '';
this.contentEncoding = schema.contentEncoding;
this.contentMediaType = schema.contentMediaType;
this.minItems = schema.minItems;
this.maxItems = schema.maxItems;
if (!!schema.nullable || schema['x-nullable']) {
if (Array.isArray(this.type) && !this.type.some((value) => value === null || value === 'null')) {