-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
feat: add Avro Schema input processor #1753
feat: add Avro Schema input processor #1753
Conversation
✅ Deploy Preview for modelina canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some more comments
hey @akkshitgupta how is it coming along? Are you stuck on anything? ✌️ |
since it is required to obtain the meta model directly from the Avro Schema bypassing the common model. I am trying to figure out how a schema is using common model in between to obtain the meta model. I read the different meta models but stuck at the implementation of it. |
What are you currently stuck on? Getting started with converting them or a specific example you cant convert? |
Getting started with it. I was reading the code base and connecting some of the dots for reverse engineering to find the way backward from meta model. but unfortunately could not use the meta models. perhaps failing to understand the flow for generating the meta model. PS: I selected this issue to work on so that I can understand the working of Common Model and Meta Model in a different way. I will much obliged to you if you can share some insights either here or on Slack(for clean history) |
@akkshitgupta looks like you got figured out some of it, let me know if you have anything blocking you 😄 |
Hey @jonaslagoni I forgot to ping you in this particular comment. can you please go through this once. I am trying to test the processor but stuck at the bindings. Also wanna confirm that whether we are going with the same |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks like you are on the right track! Just make sure that you are not reusing code that is ONLY relevant for JSON Schema inputs and focus on what is possible with Avro and do so with tests ✌️
If I where you I would take the example in the issue and add it as you star to guide towards, if the MetaModel that is being created does not match what you expect it means there is a bug somewhere ✌️ Also I would break down the example and add individual tests for each small inputs where possible to create better tests 😄
What those |
Hey @akkshitgupta, have you had a chance to take a look at the review comments? |
Apologies for the delay @jonaslagoni I am working on it. some tests broke yesterday figuring out what happened. |
Quality Gate failedFailed conditions |
Hey @jonaslagoni, I am stuck at the process of converting an array as I could not figure out the here the default keyword is used to represent an empty array. |
@akkshitgupta in AsyncAPI spec-json-schema repo we have this JSON Schema document that can validates Avro documents: https://github.com/asyncapi/spec-json-schemas/blob/master/common/avroSchema_v1.json I suggest we focus on that, because yea, the spec is not clear on what According to the JSON Schema: https://github.com/asyncapi/spec-json-schemas/blob/35ea79055d09bdd319ed816e4ec169a12f0bb7a5/common/avroSchema_v1.json#L225 it can contain
Default is just hmmm, yea I see what you mean, what is |
I have some doubts regarding
Note: I have some academic exams and I might be late in replying during this coming week. Apologies for that. |
The only reason why I linked the spec-json-schema files, was to show the structure of how an array is defined. But I guess we could validate the input as well 🤔 I would forget about it in this PR though. No worries, no rush ✌️ Good luck in the exams! |
Hey @jonaslagoni, I am getting an error whenever I run the integration test using test/processors/AvroSchemaInputProcessor.spec.ts. However, the unit tests are running fine and there is no typeerror. I tried to google the solution but could not find success. can you help me with this particular thing 😄 |
@akkshitgupta what happens when you try running |
@akkshitgupta for some reason I cannot see them at all 🤨 Do you mind posting them again or as a comment? 🤔 |
This comment was marked as duplicate.
This comment was marked as duplicate.
@akkshitgupta do you see the |
@jonaslagoni extremely sorry for the confusion 🙇🏻🙇🏻 I thought these comments are the part of unresolved conversation thats why it is showing pending 😓 |
src/helpers/AvroToMetaModel.ts
Outdated
avroSchemaModel: AvroSchema, | ||
name: string | ||
): FloatModel | undefined { | ||
if (avroSchemaModel.type !== 'float' && avroSchemaModel.type !== 'double') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got my mistake 😅 didn't think of that
i guess need to make a check in every function for the AvroSchema
object type to consider the value of type
as an Avro Schema itself.
if ((typeof avroSchemaModel.type !== 'string' && !Array.isArray(avroSchemaModel.type)) || (avroSchemaModel.type !== 'int' && avroSchemaModel.type !== 'long')) {
return undefined;
}
@jonaslagoni, Please correct me If I am heading heading wrong or if there is any alternative. 🙇🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is a bit hard, because we have two inputs that have a type
keyword. JSON Schema and Avro, each with overlapping types such as string
and boolean
.
So the answer to the question lies within "what is the difference between Avro and JSON Schema and how can you easily detect it" 😄
I don't have the perfect answer here unfortunately, other then look at the keywords that are different between them and match with those 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonaslagoni How about introducing a check explicitly in the shouldProcess()
function using an additional schema
property with a value of Avro
to differentiate an Avro Schema before processing the input?
have you checked these comments: #1753 (comment) and #1753 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonaslagoni How about introducing a check explicitly in the shouldProcess() function using an additional schema property with a value of Avro to differentiate an Avro Schema before processing the input?
Can you give an example of what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example:
{
"name": "Person",
"type": "int",
"schema": "avro"
}
@jonaslagoni here, we can add a check for the schema
property against the value avro
. This would be to verify that only avro schema is passed to the Avro processor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would never happen no, because schema
is not part of the Avro standard and never will be probably 🙂
It's okay if the solution is not bullet proof, as long as we document the edge cases.
docs/usage.md
Outdated
|
||
The Avro input processor expects the `type` property, as per [Avro Schema specs](https://avro.apache.org/docs/1.11.1/specification/#schema-declaration), in the input object in order to proceed successfully. | ||
|
||
> Note: Currently, we support `record` datatype for generating the `Object Model`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonaslagoni As of now, we do not support map
, fixed
, byte
datatypes. I don't get your point about enum
, it is being handled as an Enum Model
separately.
@akkshitgupta is it something you want to include in this PR, or want to merge this one and add issues to describe what is missing? |
hello @jonaslagoni I have not been active for the past few days for some reason and also have my end-of-semester exams in the coming week. It would be great to merge this PR with other PRs to mention related issues, if that makes sense 😅😅. However, I would make sure to complete this ASAP. Thanks a lot for your kind support in my journey 😄 |
@akkshitgupta do you mind listing all the current short comings of the implementation right now? |
Here are the pending tasks
|
@akkshitgupta I am gonna merge this into the |
Btw, you are free to join as a code owner for the Avro input processor if you want to 💪 |
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the perseverance @akkshitgupta, thanks for sticking with the PR and fighting through the difficulties 💪
/rtm |
@all-contributors please add @akkshitgupta for code, example, test, docs |
I've put up a pull request to add @akkshitgupta! 🎉 |
Thanks a lot @jonaslagoni for the opportunity. I would love to become a code owner. 🙏🏻
created a new issue covering all the tasks |
Go ahead and add the Avro input processor to the codeowners file and add yourself ✌️ Line 19 in e4a3e4e
|
🎉 This PR is included in version 4.0.0-next.36 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
Add Avro Schema support.
Related Issue
fixes #1741
Checklist
npm run lint
).npm run test
).