fix: nullable label

This commit is contained in:
Alex Varchuk 2021-07-30 12:51:29 +03:00
parent b44d7fae64
commit d7190a52f8

View File

@ -125,9 +125,11 @@ export class SchemaModel {
this.contentEncoding = schema.contentEncoding; this.contentEncoding = schema.contentEncoding;
this.contentMediaType = schema.contentMediaType; this.contentMediaType = schema.contentMediaType;
if (!!schema.nullable) { if (!!schema.nullable || schema['x-nullable']) {
if (Array.isArray(this.type) && !this.type.includes('null')) { if (Array.isArray(this.type) && !this.type.some((value) => value === null || value === 'null')) {
this.type = [...this.type, 'null']; this.type = [...this.type, 'null'];
} else if (!Array.isArray(this.type) && (this.type !== null || this.type !== 'null')) {
this.type = [this.type, 'null'];
} }
} }