mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-10 19:06:34 +03:00
chore: fix circular crash
Co-authored-by: Alex Varchuk <olexandr.varchuk@gmail.com>
This commit is contained in:
parent
cfd810fdf9
commit
87c79916df
|
@ -555,5 +555,45 @@ describe('Models', () => {
|
|||
packSize: <integer>
|
||||
`);
|
||||
});
|
||||
|
||||
test('should detect and recursion with nested oneOf', () => {
|
||||
const spec = parseYaml(outdent`
|
||||
openapi: 3.0.0
|
||||
components:
|
||||
schemas:
|
||||
Tag:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
description: Tag name
|
||||
type: string
|
||||
minLength: 1
|
||||
items:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/Tag"
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
pet:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/Tag'
|
||||
`) as any;
|
||||
|
||||
parser = new OpenAPIParser(spec, undefined, opts);
|
||||
const schema = new SchemaModel(
|
||||
parser,
|
||||
spec.components.schemas.User,
|
||||
'#/components/schemas/User',
|
||||
opts,
|
||||
);
|
||||
|
||||
expect(printSchema(schema, circularDetailsPrinter)).toMatchInlineSnapshot(`
|
||||
pet: oneOf
|
||||
Tag ->
|
||||
name: <string> (Tag name)
|
||||
items: oneOf
|
||||
Tag -> <object> !circular
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -254,10 +254,10 @@ export class SchemaModel {
|
|||
title,
|
||||
allOf: [{ ...this.schema, oneOf: undefined, anyOf: undefined }],
|
||||
} as OpenAPISchema,
|
||||
this.pointer + '/oneOf/' + idx,
|
||||
variant.$ref || this.pointer + '/oneOf/' + idx,
|
||||
this.options,
|
||||
false,
|
||||
this.refsStack,
|
||||
refsStack,
|
||||
);
|
||||
|
||||
return schema;
|
||||
|
|
Loading…
Reference in New Issue
Block a user