Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing union of string to @doc crash openapi emitter with circular reference in json #169

Closed
timotheeguerin opened this issue Jan 14, 2022 · 1 comment · Fixed by #198
Closed
Assignees
Labels
bug Something isn't working

Comments

@timotheeguerin
Copy link
Member

timotheeguerin commented Jan 14, 2022

model Foo {
  @doc("foo" | "bar")
  test: string;
}

This happened when using wanting to use quotes but forgetting to escape and it happens to produce a valid Cadl syntax.

Error:

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'Object'
    |     property 'options' -> object with constructor 'Array'
    |     index 0 -> object with constructor 'Object'
    --- property 'parent' closes the circle
    at JSON.stringify (<anonymous>)
    at Object.emitOpenAPI (file:///C:/dev/azsdk/cadl-azure/packages/cadl-autorest/dist/src/openapi.js:172:100)
    at $onBuild (file:///C:/dev/azsdk/cadl-azure/packages/cadl-autorest/dist/src/openapi.js:13:19)
    at async createProgram (file:///C:/dev/azsdk/cadl-azure/core/packages/compiler/dist/core/program.js:60:13)
    at async compile (file:///C:/dev/azsdk/cadl-azure/core/packages/compiler/dist/core/program.js:479:12)
    at async Object.handler (file:///C:/dev/azsdk/cadl-azure/core/packages/compiler/dist/core/cli.js:67:25)

The problem with @doc specifically might just be to verify the value passed is a string and nothing else.

@timotheeguerin timotheeguerin added the bug Something isn't working label Jan 14, 2022
@markcowl
Copy link
Contributor

markcowl commented Jan 21, 2022

  • Should throw if first parameter is not a string
  • estimate < 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants