mirror of
https://github.com/Redocly/redoc.git
synced 2025-07-09 15:52:28 +03:00
fix: schema fields builder stuck
This commit is contained in:
parent
0e38089204
commit
f0885ea785
|
@ -53,7 +53,7 @@ export class SchemaModel {
|
||||||
|
|
||||||
constraints: string[];
|
constraints: string[];
|
||||||
|
|
||||||
fields?: FieldModel[];
|
private _fields?: FieldModel[];
|
||||||
items?: SchemaModel;
|
items?: SchemaModel;
|
||||||
|
|
||||||
oneOf?: SchemaModel[];
|
oneOf?: SchemaModel[];
|
||||||
|
@ -76,7 +76,7 @@ export class SchemaModel {
|
||||||
* When true forces dereferencing in allOfs even if circular
|
* When true forces dereferencing in allOfs even if circular
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
parser: OpenAPIParser,
|
private parser: OpenAPIParser,
|
||||||
schemaOrRef: Referenced<OpenAPISchema>,
|
schemaOrRef: Referenced<OpenAPISchema>,
|
||||||
pointer: string,
|
pointer: string,
|
||||||
private options: RedocNormalizedOptions,
|
private options: RedocNormalizedOptions,
|
||||||
|
@ -112,6 +112,23 @@ export class SchemaModel {
|
||||||
return this.type === type || (isArray(this.type) && this.type.includes(type));
|
return this.type === type || (isArray(this.type) && this.type.includes(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get fields(): FieldModel[] | undefined {
|
||||||
|
if (this.isCircular) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._fields && this.hasType('object')) {
|
||||||
|
this._fields = buildFields(
|
||||||
|
this.parser,
|
||||||
|
this.schema,
|
||||||
|
this.pointer,
|
||||||
|
this.options,
|
||||||
|
this.refsStack,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return this._fields;
|
||||||
|
}
|
||||||
|
|
||||||
init(parser: OpenAPIParser, isChild: boolean) {
|
init(parser: OpenAPIParser, isChild: boolean) {
|
||||||
const schema = this.schema;
|
const schema = this.schema;
|
||||||
this.isCircular = !!schema['x-circular-ref'];
|
this.isCircular = !!schema['x-circular-ref'];
|
||||||
|
@ -190,11 +207,9 @@ export class SchemaModel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasType('object')) {
|
if (this.hasType('array')) {
|
||||||
this.fields = buildFields(parser, schema, this.pointer, this.options, this.refsStack);
|
|
||||||
} else if (this.hasType('array')) {
|
|
||||||
if (isArray(schema.items) || isArray(schema.prefixItems)) {
|
if (isArray(schema.items) || isArray(schema.prefixItems)) {
|
||||||
this.fields = buildFields(parser, schema, this.pointer, this.options, this.refsStack);
|
this._fields = buildFields(parser, schema, this.pointer, this.options, this.refsStack);
|
||||||
} else if (schema.items) {
|
} else if (schema.items) {
|
||||||
this.items = new SchemaModel(
|
this.items = new SchemaModel(
|
||||||
parser,
|
parser,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user