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

fix: array schema is not being parsed correctly #156

Closed
wants to merge 3 commits into from

Conversation

jaydeepk
Copy link
Contributor

@jaydeepk jaydeepk commented Jul 3, 2023

Description
Fixes array schema parsing with the following caveats:

  • If 'items' is defined as an array of schemas, it will continue to be parsed as an Arraylist (like before).
    Once we have some clarity on whether we should be using 'prefixIems', or returning a list of schemas, we can implement it.

In the meantime, with this fix, if 'items' is a json schema, then it will get parsed to a 'Schema' object, instead of the LinkedHashmap which we get right now.
We are a bit blocked due to this, and this fix will allow us to proceed with using this library in our project to validate messages with array schemas

Related issue(s)
#154

…a object instead of a LinkedHashMap.

If it is an array of schemas, then it will be returned as an arraylist ( like before)
Copy link

@github-actions github-actions bot left a 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.

@jaydeepk jaydeepk changed the title fix: Array schema is not being parsed correctly fix: array schema is not being parsed correctly Jul 3, 2023
if (nodeType == JsonNodeType.OBJECT) {
return readAsSchema(node, objectCodec);
}
// TODO: Implement handling of scenario when items is an array of schemas. Maybe return a List<Schema>?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let's try to return list of schemas, in case of array

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test case where items is an Schema

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @Pakisan, I'll have a look and make the changes that you have suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Pakisan, I have modified the code to return a list of schemas if 'items' is defined as an array of schemas in the spec. I have updated the tests to cover this scenario (MessageWithArrayPayloadTest class).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pakisan, I can't seem to find '1.0.0-EAP-3-SNAPSHOT' branch. Under active branches, I can only see the 'develop' branch. Could you please advise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pakisan, I can't seem to find '1.0.0-EAP-3-SNAPSHOT' branch. Under active branches, I can only see the 'develop' branch. Could you please advise.

Sorry, my bad. I pushed branch moment ago

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Pakisan, I have now raised a PR on the '1.0.0-EAP-3-SNAPSHOT' branch.
I have also added the implementation of array schema parsing to v3.

@Pakisan
Copy link
Member

Pakisan commented Oct 11, 2023

@jaydeepk please switch to 1.0.0-EAP-3-SNAPSHOT branch. It contains bunch of changes

@Pakisan
Copy link
Member

Pakisan commented Oct 14, 2023

Merged - #159

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

Successfully merging this pull request may close these issues.

2 participants