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

ruby: Fix boolean convertion on json to model attribute. #2092

Merged
merged 2 commits into from
Feb 10, 2016

Conversation

sugi
Copy link
Contributor

@sugi sugi commented Feb 10, 2016

Current code will converts boolean true of json to false
because ruby's boolean is not matched with any regex.

Here is single line patch to convert string explicitly before regex check.

sugi@tempest:~% irb
irb(main):001:0> true =~ /true/
nil
irb(main):002:0> "true" =~ /true/
0
irb(main):003:0> 
sugi@tempest:~% ruby1.8 -e 'p true =~ /true/'
false
sugi@tempest:~% ruby1.9.1 -e 'p true =~ /true/' 
nil
sugi@tempest:~% ruby1.9.3 -e 'p true =~ /true/'
nil
sugi@tempest:~% ruby2.0 -e 'p true =~ /true/'
nil
sugi@tempest:~% ruby2.1 -e 'p true =~ /true/' 
nil
sugi@tempest:~% ruby2.2 -e 'p true =~ /true/' 
nil

Current code will converts boolean true of json to false
because ruby's boolean is not matched with any regex.
@wing328
Copy link
Contributor

wing328 commented Feb 10, 2016

@sugi thanks for the PR and tested with 6 different versions of Ruby to ensure the fix works across different versions of Ruby 🍻

Do you mind updating the sample code for Ruby Petstore as mention in the contributing guidelines?

Ref: https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md

@sugi
Copy link
Contributor Author

sugi commented Feb 10, 2016

Oh, thank you for your comment.

I'll check the document and update this PR in your manner.
Please wait a moment.

@sugi
Copy link
Contributor Author

sugi commented Feb 10, 2016

OK.
I updated petstore sample and added tests.

I believe that it satisfy your contribute guidelines.
Please notice me if not so.

@wing328
Copy link
Contributor

wing328 commented Feb 10, 2016

@sugi thanks. Looks good to me and you also updated the test cases as well.

wing328 added a commit that referenced this pull request Feb 10, 2016
ruby: Fix boolean convertion on json to model attribute.
@wing328 wing328 merged commit b576bc3 into swagger-api:master Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants