generator
generator copied to clipboard
Circular references in referenced OpenAPI broken: Error: Token "ChildObject" does not exist.
Describe the bug
I get the following error on running ag asyncapi.yaml @asyncapi/html-template
:
Something went wrong:
Error: Token "ChildObject" does not exist.
at dereference (c:\devsbb\eaio-ng\nodejs\16\node_modules\@asyncapi\generator\node_modules\@asyncapi\parser\lib\parser.js:160:11)
at handleCircularRefs (c:\devsbb\eaio-ng\nodejs\16\node_modules\@asyncapi\generator\node_modules\@asyncapi\parser\lib\parser.js:174:3)
at parse (c:\devsbb\eaio-ng\nodejs\16\node_modules\@asyncapi\generator\node_modules\@asyncapi\parser\lib\parser.js:109:35)
at Generator.generateFromString (c:\devsbb\eaio-ng\nodejs\16\node_modules\@asyncapi\generator\lib\generator.js:265:22)
at c:\devsbb\eaio-ng\nodejs\16\node_modules\@asyncapi\generator\cli.js:154:9
Observation 1: When the circular refrence in ChildObject
is removed, the generation works fine!
Observation 2: When both schemas (ChildObject, ParentObject) are defined inside asyncapi.yaml
everything works fine as well!
How to Reproduce
asyncapi.yaml:
asyncapi: 2.0.0
info:
title: Account Service
version: 1.0.0
description: "This service is in charge of processing user signups :rocket:"
channels:
user/parent:
subscribe:
message:
payload:
$ref: 'openapi.yaml#/components/schemas/ParentObject'
user/child:
subscribe:
message:
payload:
$ref: 'openapi.yaml#/components/schemas/ChildObject'
components:
schemas: {}
openapi.yaml:
openapi: 3.0.3
info:
title: Title
description: Title
version: 1.0.0
servers:
- url: 'https'
paths: { }
components:
schemas:
ParentObject:
type: object
properties:
child:
$ref: '#/components/schemas/ChildObject'
ChildObject:
type: object
properties:
sister:
$ref: '#/components/schemas/ChildObject'
Expected behavior
Expect to generate successfully.