mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 13:44:54 +03:00
add nullable lable for OAS 3.1 JSON schema
This commit is contained in:
parent
2f85d42360
commit
e03c4e86d0
|
@ -76,6 +76,12 @@ export class SchemaModel {
|
|||
|
||||
this.pointer = schemaOrRef.$ref || pointer || '';
|
||||
this.rawSchema = parser.deref(schemaOrRef);
|
||||
|
||||
if (Array.isArray(this.rawSchema.type)) {
|
||||
this.rawSchema.oneOf = this.rawSchema.type.map( type => ({type}));
|
||||
delete this.rawSchema.type;
|
||||
}
|
||||
|
||||
this.schema = parser.mergeAllOf(this.rawSchema, this.pointer, isChild);
|
||||
|
||||
this.init(parser, isChild);
|
||||
|
@ -138,7 +144,8 @@ export class SchemaModel {
|
|||
}
|
||||
|
||||
if (schema.oneOf !== undefined) {
|
||||
this.initOneOf(schema.oneOf, parser);
|
||||
this.nullable = this.nullable || schema.oneOf.some(s => s.type === 'null');
|
||||
this.initOneOf(schema.oneOf.filter(s => s.type !== 'null'), parser);
|
||||
this.oneOfType = 'One of';
|
||||
if (schema.anyOf !== undefined) {
|
||||
console.warn(
|
||||
|
@ -149,7 +156,8 @@ export class SchemaModel {
|
|||
}
|
||||
|
||||
if (schema.anyOf !== undefined) {
|
||||
this.initOneOf(schema.anyOf, parser);
|
||||
this.nullable = this.nullable || schema.anyOf.some(s => s.type === 'null');
|
||||
this.initOneOf(schema.anyOf.filter(s => s.type !== 'null'), parser);
|
||||
this.oneOfType = 'Any of';
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user