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

Avro union not displayed correctly in the bindings bloc #67

Closed
M3lkior opened this issue Aug 16, 2021 · 6 comments
Closed

Avro union not displayed correctly in the bindings bloc #67

M3lkior opened this issue Aug 16, 2021 · 6 comments
Labels

Comments

@M3lkior
Copy link
Collaborator

M3lkior commented Aug 16, 2021

I use the avro-parser (usage of avsc files) in the AsyncAPI specification for my kafka messages payload and key

When i use a record definition with union fields (like "type": ["null", { "type": "string", "avro.java.string": "String" }] or "type": ["null", { "type": "int" }], the definition is not correctly displayed :

image

Expected result

The display should be like the payload part (actually working like a charm with avro files):

image

the record type is not handle

Actual result

image

Steps to reproduce

  • The avro schema definition :
{
  "namespace": "sample",
  "type": "record",
  "name": "SampleRecord",
  "version": 1,
  "fields": [
    {"name": "NoUnionField", "type": { "type": "string",  "avro.java.string": "String" }, "doc": "Any doc"},
    {"name": "UnionField", "type": ["null", { "type": "string",  "avro.java.string": "String" }], "doc": "any doc"}
  ]
}

  • the spec file with avro reference :
asyncapi: '2.1.0'
id: 'urn:adeo:dev:euw1:sample'
info:
  version: ''
  description: 

channels:
  test:
    subscribe:
      summary: Get updated products
      message:
        $ref: "#/components/messages/example-value"

components:
  messages:
    example-value:
      schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
      payload:
        $ref: "SampleRecord.avsc" 
      bindings:
        kafka:
          key: 
            $ref: "SampleRecord.avsc" 


Troubleshooting

@magicmatatjahu
Copy link
Member

@M3lkior Hi! Sorry for late response, I was off in the previous week (to be more precise, I had holidays). I tested locally your schema and as I see (also you mentioned it in your comment), the payload for message renders correctly, but problem is with bindings.kafka.key. The problem is not related with component but with avro parser - you can look on code here https://github.com/asyncapi/avro-schema-parser/blob/master/index.js As you can see, parser transforms only the payload for the message, and doesn't look for schemas in the bindings.

We have such an issues to handle validation for the bindings - asyncapi/parser-js#315 and as I see we should also handle transforming schemas in the bindings.

I will move this issue to the avro parser repository. Do you have any questions?

@magicmatatjahu magicmatatjahu transferred this issue from asyncapi/asyncapi-react Aug 23, 2021
@magicmatatjahu
Copy link
Member

The problem is that we don't support the transforming of schemas in other places (like bindings) than message.payload -> https://github.com/asyncapi/avro-schema-parser/blob/master/index.js#L4

@M3lkior
Copy link
Collaborator Author

M3lkior commented Aug 23, 2021

hi @magicmatatjahu ; thanks for the reply ! it is clear and precise ! i hope this issue will be resolved soon :)

@M3lkior
Copy link
Collaborator Author

M3lkior commented Sep 3, 2021

i will take this issue and do a PR proposal :)

M3lkior added a commit to M3lkior/avro-schema-parser that referenced this issue Sep 9, 2021
@M3lkior
Copy link
Collaborator Author

M3lkior commented Sep 9, 2021

hi @magicmatatjahu @fmvilas @derberg ; i submit a first proposal of the avro bindings bloc support, but only for the protocol key part.
Any feedback on this ?

M3lkior added a commit to M3lkior/avro-schema-parser that referenced this issue Sep 9, 2021
M3lkior added a commit to M3lkior/avro-schema-parser that referenced this issue Sep 9, 2021
M3lkior added a commit to M3lkior/bindings that referenced this issue Sep 13, 2021
fmvilas added a commit to asyncapi/bindings that referenced this issue Sep 15, 2021
* feat(kafka): add AVRO type in message key binding

Refer to asyncapi/avro-schema-parser#67

* Update kafka/README.md

Co-authored-by: Fran Méndez <[email protected]>

Co-authored-by: Fran Méndez <[email protected]>
@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

3 participants