-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #38315 - Delay documentation of host status types #10494
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
Fixes #38315 - Delay documentation of host status types #10494
Conversation
6d0040f to
97f785f
Compare
|
I likevthe idea but do you intend to submit it to apipie or keep it in here? |
I think it's better to live here, since it's quite custom. Not sure how could I generalize this to submit to Apipie-rails. |
ekohl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered wrapping the block in a specific class so you could distinguish between a regular callable and a callable that's an enum. But I can see your argument that it's rather specific and going to be messy so I won't object to merging it here.
| api :GET, "/hosts/:id/status/:type", N_("Get status of host") | ||
| param :id, :identifier_dottable, :required => true | ||
| param :type, [HostStatus::Global] + HostStatus.status_registry.to_a.map { |s| s.humanized_name }, :required => true, :desc => N_( | ||
| param :type, :delayed_enum, of: -> { [HostStatus::Global.status_name.underscore] + HostStatus.status_registry.to_a.map { |s| s.humanized_name } }, required: true, desc: N_( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The desc is now autogenerated so can we drop this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, dropped. I think the only benefit of such description is that it should be translated.
| api :DELETE, "/hosts/:id/status/:type", N_("Clear sub-status of host") | ||
| param :id, :identifier_dottable, :required => true | ||
| param :type, HostStatus.status_registry.to_a.map { |s| s.humanized_name }, :required => true, :desc => N_( | ||
| param :type, :delayed_enum, of: -> { HostStatus.status_registry.to_a.map { |s| s.humanized_name } }, required: true, desc: N_( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: can we drop the description and rely on the generated one?
config/initializers/apipie.rb
Outdated
| end | ||
| end | ||
|
|
||
| class DelayedEnumValidator < Apipie::Validator::BaseValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bike shedding: CallableEnumValidator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
97f785f to
9eb6ef2
Compare
ofedoren
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ekohl, updated!
config/initializers/apipie.rb
Outdated
| end | ||
| end | ||
|
|
||
| class DelayedEnumValidator < Apipie::Validator::BaseValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
| api :GET, "/hosts/:id/status/:type", N_("Get status of host") | ||
| param :id, :identifier_dottable, :required => true | ||
| param :type, [HostStatus::Global] + HostStatus.status_registry.to_a.map { |s| s.humanized_name }, :required => true, :desc => N_( | ||
| param :type, :delayed_enum, of: -> { [HostStatus::Global.status_name.underscore] + HostStatus.status_registry.to_a.map { |s| s.humanized_name } }, required: true, desc: N_( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so, dropped. I think the only benefit of such description is that it should be translated.
ekohl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my phone now so can't verify it but code reads well
@ekohl, you might be interested in this, since it's basically an alternative to Apipie/apipie-rails#946. I don't even know myself how we didn't try this earlier :/ The new validator probably could be re-used in Katello or wherever similar places we have.
Before:

After:
