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

[BUG] Inconsistent reporting of "Adheres to" between records of same structure, based on the order of declaration. #256

Open
2 tasks done
ghuser opened this issue Mar 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ghuser
Copy link

ghuser commented Mar 4, 2024

Describe the bug.

In the following asyncapi document

asyncapi: 2.6.0
info:
  title: AsyncAPI
  version: 1.0.0
  description: AsyncAPI
channels:
  example:
    publish:
      message:
        $ref: '#/components/messages/example_message'
components:
  messages:
    example_message:
      name: example_event
      schemaFormat: application/vnd.apache.avro;version=1.9.0
      payload:
        type: record
        name: ParentRecord
        fields:
          - name: r1
            type:
              type: record
              name: Record1
              fields:
                - name: child1
                  type:
                    - 'null'
                    - type: record
                      name: CommonChildRecord
                      fields:
                        - name: field
                          type:
                            type: string
                            minLength: 1
                            maxLength: 256
          - name: r2
            type:
              type: record
              name: Record2
              fields:
                - name: child2
                  type:
                    - 'null'
                    - CommonChildRecord
          - name: r3
            type:
              type: record
              name: Record3
              fields:
                - name: child3
                  type: CommonChildRecord
          - name: r4
            type:
              - 'null'
              - type: record
                name: Record4
                fields:
                  - name: child4
                    type: CommonChildRecord

the preview reports what is presented in Screenshot1

As you can see r2 is of type Record2 which equal (structure-wise) to Record1 (used by r1).
However, the report for r2 is "Adheres to: Any or null" while the report for r1 is: "Adheres to Object or null".

This inconsistent reporting seems to be related with having a nested field (in this case of type CommonChildRecord) marked as nullable. But the issue for some reason does not affect the first record.

Now if I make the nested field not nullable, there is no issue, even if the parent is nullable. (rendering of cases of r3 and r4 reports: "Adheres to Object or null")

The above issue also affects the payload in the examples section: see below:

Expected behavior

For r2 the adheres to should be Object containing a a field of type String

Screenshots

Screenshot1:

image

How to Reproduce

  1. Visit https://studio.asyncapi.com/
  2. Paste the above payload
  3. See in the preview that r2/child2 is presented with "Adheres to Any" while r1/child1 is shown correctly.

🥦 Browser

Google Chrome

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

@ghuser ghuser added the bug Something isn't working label Mar 4, 2024
@ghuser
Copy link
Author

ghuser commented Oct 17, 2024

Any news on this issue?

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

No branches or pull requests

1 participant