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

[472] - Fix for Accept nullable parameter #498

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

jahir-husain
Copy link

Fix for issue #472

@jahir-husain jahir-husain marked this pull request as draft July 24, 2023 07:38
@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03% 🎉

Comparison is base (76ea712) 90.08% compared to head (f0051ff) 90.11%.

❗ Current head f0051ff differs from pull request most recent head 3c7f264. Consider uploading reports for the commit 3c7f264 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #498      +/-   ##
==========================================
+ Coverage   90.08%   90.11%   +0.03%     
==========================================
  Files          76       76              
  Lines        1584     1589       +5     
==========================================
+ Hits         1427     1432       +5     
  Misses        157      157              
Files Changed Coverage Δ
lib/json-schema/attribute.rb 100.00% <100.00%> (ø)
lib/json-schema/attributes/type.rb 100.00% <100.00%> (ø)
lib/json-schema/attributes/type_v4.rb 100.00% <100.00%> (ø)

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

@jahir-husain jahir-husain marked this pull request as ready for review July 24, 2023 08:22
@jahir-husain
Copy link
Author

@bastelfreak - Can you review this, Please.

@bastelfreak
Copy link
Member

@jahir-husain can you please rebase against our latest master branch and squash the commits down?

valid_classes = TYPE_CLASS_MAPPINGS.fetch(type) { return true }
valid_classes = [valid_classes, NilClass] if nullable
Copy link

@belinskidima belinskidima Sep 12, 2023

Choose a reason for hiding this comment

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

in case when type is boolean, you need to flatten the valid_classes

type = "boolean"
valid_classes = TYPE_CLASS_MAPPINGS.fetch(type) # => [TrueClass, FalseClass]
valid_classes = [valid_classes, NilClass] if nullable # =>  [[TrueClass, FalseClass], NilClass]
Array(valid_classes).any? { |c| data.is_a?(c) } # => #<TypeError: class or module required>

Copy link
Author

Choose a reason for hiding this comment

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

Checking this @belinskidima

@bastelfreak
Copy link
Member

@jahir-husain can you please take a look at the comment and rebase against our latest master (so we get rid of the merge commits).

@bastelfreak
Copy link
Member

@jahir-husain please rebase instead of doing a merge.

@kntmrkm
Copy link

kntmrkm commented Apr 17, 2024

any update?

@bastelfreak
Copy link
Member

@kntmrkm this PR needs a rebase. If you want you can checkout the code locally, rebase it against our Head and then submit a new PR.

@notEthan
Copy link
Contributor

nullable has never been a JSON Schema keyword. It used to be a keyword of OpenAPI's schema, though isn't anymore. I don't know that a JSON Schema validator should be validating keywords that aren't part of JSON Schema.

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.

5 participants