asyncapi / asyncapi-react

React component for rendering documentation from your specification in real-time in the browser. It also provides a WebComponent and bundle for Angular and Vue
https://asyncapi.github.io/asyncapi-react/
Apache License 2.0
174 stars 107 forks source link

[BUG] Problem with type names in Avro unions #1032

Closed YuriiKondratov closed 2 weeks ago

YuriiKondratov commented 1 month ago

Description

When I generate HTML from asyncapi specification referencing Avro schema with unions, I get unexpected "Adheres to undefined.... Or to undefined...." construct.

To reproduce bug create file "OuterRecord.avsc" with schema:

{
  "type" : "record",
  "name" : "OuterRecord",
  "doc" : "OuterRecord docstring",
  "fields" : [ {
    "name" : "innerRecord",
    "type" : [ {
      "type" : "record",
      "name" : "InnerRecord1",
      "doc" : "InnerRecord1 docstring",
      "fields" : [ {
        "name" : "innerRecord1Field",
        "type" : "string",
        "doc" : "innerRecord1Field docstring"
      } ]
    }, {
      "type" : "record",
      "name" : "InnerRecord2",
      "doc" : "InnerRecord2 docstring",
      "fields" : [ {
        "name" : "innerRecord2Field",
        "type" : "string",
        "doc" : "innerRecord2Field docstring"
      } ]
    } ],
    "doc" : "innerRecord docstring"
  } ]
}

and file "asyncapi.yaml" with specification:

asyncapi: 3.0.0
info:
  title: Bug Illustrating API
  version: 1.0.0
  description: The API illustrates Asyncapi generator bug
servers:
  kafkaServer:
    host: test.mykafkacluster.org:8092
    description: Kafka Server
    protocol: kafka
operations:
  onExampleEvent:
    action: receive
    channel:
      $ref: '#/channels/exampleEvent'
channels:
  exampleEvent:
    description: Example channel
    address: example_addr
    messages:
      exampleMessage:
        $ref: '#/components/messages/exampleMessage'
components:
  messages:
    exampleMessage:
      payload:
        schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
        schema:
          $ref: './OuterRecord.avsc'

then generate HTML using

npm install -g @asyncapi/cli
asyncapi generate fromTemplate asyncapi.yaml @asyncapi/html-template@2.3.9

Expected result

In section Messages.Payload.innerRecord I expect to see "Adheres to InnerRecord1 .... Or to InnerRecord2 ...."

Actual result

I get "Adheres to undefined.... Or to undefined...."

image

github-actions[bot] commented 1 month ago

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.

asyncapi-bot commented 2 weeks ago

:tada: This issue has been resolved in version 2.2.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: