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

param: Consider default_value: nil as valid config #894

Merged

Conversation

davidwessman
Copy link
Contributor

When using param as:

param(:name, String, required: false, default_value: nil)

there would be a warning that default_value is missing.
This fix changes from checking options[key].blank? to options.key?(key).

When using `param` as:
```ruby
param(:name, String, required: false, default_value: nil)
```

there would be a warning that `default_value` is missing.
This fix changes from checking `options[key].blank?` to `options.key?(key)`.
@@ -71,7 +71,7 @@ def for_required
end

def for_default
return {} if @param_description.options[:default_value].blank?
Copy link
Contributor Author

@davidwessman davidwessman Jul 31, 2023

Choose a reason for hiding this comment

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

Should we combine this with the allow_nil and allow_blank to only allow

  • default: nil when allow_nil: true and
  • default: "" when allow_blank: true?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, I don't think they should be combined.

Copy link
Contributor

@PanosCodes PanosCodes left a comment

Choose a reason for hiding this comment

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

LGTM
I'm not really sure about combining it with allow_nil & allow_blank🤷‍♂️

Copy link
Collaborator

@mathieujobin mathieujobin left a comment

Choose a reason for hiding this comment

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

Thanks for the fix

@mathieujobin mathieujobin merged commit 7cc859e into Apipie:master Aug 9, 2023
16 checks passed
@davidwessman
Copy link
Contributor Author

@mathieujobin Could we get a release of this? 🙂

@davidwessman davidwessman deleted the param-support-default-value-nil branch October 11, 2023 09:24
@mathieujobin
Copy link
Collaborator

mathieujobin commented Oct 11, 2023

sure, sorry for the delay on this. will be in v1.2.3 shortly

@davidwessman
Copy link
Contributor Author

sure, sorry for the delay on this. will be in v1.2.3 shortly

No worries, just a small fix.

Thank you 👏🏻

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