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

Additional type checks in models and Json/YAML reader #2030

Merged
merged 5 commits into from
Oct 24, 2024

Conversation

MikeEdgar
Copy link
Member

No description provided.

@MikeEdgar MikeEdgar added this to the 4.0.0 milestone Oct 23, 2024
@MikeEdgar
Copy link
Member Author

@Azquelt - fyi

@Azquelt
Copy link
Contributor

Azquelt commented Oct 23, 2024

This is definitely better.

It does still have one change in behaviour for Schema.

If I read in a schema like this:

{
    "type": "object",
    "properties": ["id", "name"]
}

The properties field is dropped when reading because it's not a map, which wasn't the case in alpha6.

Using the Schema.set(String, Object), I can set properties to whatever I want, it only gets dropped during reading.

This does slightly affect our ability to pass through a schema object we don't understand untouched. I've written some tests to demonstrate the change in behaviour here: Azquelt@0e17e6b - with these changes testSchemas_InvalidTypes is the only one that doesn't pass.

@MikeEdgar
Copy link
Member Author

The properties field is dropped when reading because it's not a map, which wasn't the case in alpha6.

Using the Schema.set(String, Object), I can set properties to whatever I want, it only gets dropped during reading.

This does slightly affect our ability to pass through a schema object we don't understand untouched. I've written some tests to demonstrate the change in behaviour here: Azquelt@0e17e6b - with these changes testSchemas_InvalidTypes is the only one that doesn't pass.

I've added an additional fallback for Schema where it will read any type for the property. The last push also includes your commit cherry-picked to this PR (if that's ok 😃)

Copy link

sonarcloud bot commented Oct 23, 2024

Copy link
Contributor

@Azquelt Azquelt left a comment

Choose a reason for hiding this comment

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

These changes look good to me. There were a few other small changes in behaviour which needed tweaks in OpenLiberty (noted on #2021), but now I have all my tests passing.

@MikeEdgar MikeEdgar requested a review from a team October 23, 2024 21:41
@MikeEdgar
Copy link
Member Author

@phillip-kruger some additional fixes for 4.0. Please take a look when you can.

@MikeEdgar MikeEdgar merged commit 47cc990 into smallrye:main Oct 24, 2024
4 checks passed
@MikeEdgar MikeEdgar deleted the invalid-json-types branch October 24, 2024 09:15
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.

3 participants