Skip to content

[472] - Fix for Accept nullable parameter#498

Open
jahir-husain wants to merge 11 commits into
voxpupuli:masterfrom
jahir-husain:master
Open

[472] - Fix for Accept nullable parameter#498
jahir-husain wants to merge 11 commits into
voxpupuli:masterfrom
jahir-husain:master

Conversation

@jahir-husain

Copy link
Copy Markdown

Fix for issue #472

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

codecov Bot commented Jul 24, 2023

Copy link
Copy Markdown

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
Copy Markdown
Author

@bastelfreak - Can you review this, Please.

@bastelfreak

Copy link
Copy Markdown
Member

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

def self.data_valid_for_type?(data, type)
def self.data_valid_for_type?(data, type, nullable: false)
valid_classes = TYPE_CLASS_MAPPINGS.fetch(type) { return true }
valid_classes = [valid_classes, NilClass] if nullable

@belinskidima belinskidima Sep 12, 2023

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@kntmrkm

kntmrkm commented Apr 17, 2024

Copy link
Copy Markdown

any update?

@bastelfreak

Copy link
Copy Markdown
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
Copy Markdown
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