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

Bump zio-schema to 1.0.1 and remove snapshot resolver #2730

Merged
merged 7 commits into from
Mar 26, 2024

Conversation

guersam
Copy link
Contributor

@guersam guersam commented Mar 15, 2024

Fix #2726

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2024

Codecov Report

Attention: Patch coverage is 4.76190% with 20 lines in your changes are missing coverage. Please review.

Project coverage is 64.38%. Comparing base (ec7f24a) to head (5ddfd97).
Report is 1 commits behind head on main.

Files Patch % Lines
...n/scala/zio/http/endpoint/openapi/JsonSchema.scala 4.76% 20 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2730      +/-   ##
==========================================
- Coverage   64.56%   64.38%   -0.18%     
==========================================
  Files         148      148              
  Lines        8649     8668      +19     
  Branches     1573     1589      +16     
==========================================
- Hits         5584     5581       -3     
- Misses       3065     3087      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

if (fullDecode)
AnyOfSchema(Chunk(leftSchema.root, rightSchema.root))
else
OneOfSchema(Chunk(leftSchema.root, rightSchema.root))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if I understood Schema.Fallback.fullDecode correctly here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is wrong. I took a look how it is handled in schema and fullDecode will return a left and a right.
If not set, it will return either a left or right. But in both cases, we can't say if left contais right in their schema or the other way around. And one of says they don't, but any of they say may. Since I don't see a reason to enforce a possible "one of" by checking the schema structure of the two schemas, I think we should just always use any of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@987Nabil Thanks for clarifying. I assumed Schema.Fallback was equivalent to Schema.Either when fullDecode is off, using oneOf.

Just double-checking: is anyOf(left, right) sufficient, or should we consider adding a variant for fullDecode, like oneOf(left, right, allOf(left, right))?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good question. Thinking about it the idea of oneOf(left, right, allOf(left, right)) is more precise. And I don't see a reason not to do it.

@guersam
Copy link
Contributor Author

guersam commented Mar 25, 2024

Forgot to ping after update: @987Nabil

),
)
case Schema.Fallback(left, right, _, _) =>
AnyOfSchema(Chunk(fromZSchema(left, refType), fromZSchema(right, refType)))
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure this should be any of. Since the flag for full decode is false here, we expect exactly one value.
That would fit more to one of. It is true, that we don't know, if left contains right or the other way around.
But this would also make this API unusable.
Imagine we have a case class User(name: String) and case class Admin(name: String, roles:List[String], if you hand over a json with name and roles, which one will be deserialized (additional fields are allowed by default)? We have here no discriminator. Only structure. If we use one of and one contains the other, at least the error is visible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll change this.

Off the topic, but one thing I'm worried of is the spec doesn't guarantee that the order of elements in oneOf or anyOf matters, so we can't be 100% sure that it exactly expresses the purpose of Fallback.

@987Nabil 987Nabil merged commit 709b459 into zio:main Mar 26, 2024
14 checks passed
@yisraelU
Copy link
Contributor

yisraelU commented Apr 1, 2024

@987Nabil can a new RC be published, current RC5 is broken because of this

@987Nabil
Copy link
Contributor

987Nabil commented Apr 1, 2024

There is more that needs to be fixed. But I'll do it soonish

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.0.0-RC5 References -SNAPSHOT Deps
4 participants