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

Recursive schema is not rendering #351

Closed
kchaber opened this issue May 24, 2021 · 7 comments
Closed

Recursive schema is not rendering #351

kchaber opened this issue May 24, 2021 · 7 comments

Comments

@kchaber
Copy link

kchaber commented May 24, 2021

Description

Schema which contains some recursive items does not render and the console logs present some StackOverflow exceptions.

Expected result

Schema with recursive items should render correctly.

Steps to reproduce

To reproduce this issue you can use the following schema where RecursiveItem schema contains list of subItems of type RecursiveItem.

asyncapi: '2.0.0'
info:
  title: Recursive API
  version: '1.0.0'

channels:
  recursive-items:
    subscribe:
      message:
        $ref: '#/components/messages/RecursiveItem'

components:
  messages:
    RecursiveItem:
      payload:
        $ref: "#/components/schemas/RecursiveItem"

  schemas:
    RecursiveItem:
      type: object
      properties:
        name:
          type: string
        subItems:
          type: array
          items:
            $ref: '#/components/schemas/RecursiveItem'

Tested on both versions: 0.23.1 and 1.0.0-next-3

@github-actions
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.

Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@magicmatatjahu
Copy link
Member

@kchaber Hello! Thanks for reporting the issue! We know about this bug, for more info check asyncapi/parser-js#293 If we will support the recursive schemas in every place in spec (at the moment we only support in properties) then supporting in component will be very easy.

@derberg
Copy link
Member

derberg commented May 24, 2021

@magicmatatjahu what do you mean we support it in properties only? arrays too. This file works well with HTML template before migration to react

@magicmatatjahu
Copy link
Member

Yes, but as I described in this issue asyncapi/parser-js#293 (with example) circular refs in items aren't handled properly, so supporting in component is disabled. In most cases this will result in a wrong rendered schema.

@derberg
Copy link
Member

derberg commented May 24, 2021

not sure what you mean by most cases because so far it was discovered only with your only case and not even with real schema but a dummy schema for testing only 😄

I'm not saying the bug is not there, it is there and your example shows it pretty nice, I totally agree with you.

On the other hand though, next react component was supposed to not introduce any regression so your approach here is not the best in my opinion.

Technically what's the problem to support current parser functionality? I mean why not enabling it now and support most cases 😄 later it is just a matter of upgrading to latest parser and more cases will be supported, right?

@magicmatatjahu
Copy link
Member

@kchaber Issue is fixed in 1.0.0-next.5. We also published new playground which has included fixing. https://asyncapi.github.io/asyncapi-react/ Let us know if someone is broken :) Your schema is rendered as below:

image

@kchaber
Copy link
Author

kchaber commented May 27, 2021

Thanks a lot! Looks ok now 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants