Given multiple routes matching a single api controller method, what is the best way to differentiate the apipie params that are relevant to individual routes?
In the example below, the :match_system is a param that only applies to the /systems route. Additionally, the :system_id and :activation_key_id params are mutually exclusive.
api :GET, "/systems/:system_id/subscriptions/available", "List available subscriptions"
api :GET, "/activation_keys/:activation_key_id/subscriptions/available", "List available subscriptions"
param :system_id, String, :desc => "UUID of the system"
param :activation_key_id, String, :desc => "activation key ID"
param :match_system, :bool, :desc => "Return subscriptions that match system"
param :match_installed, :bool, :desc => "Return subscriptions that match installed"
param :no_overlap, :bool, :desc => "Return subscriptions that don't overlap"
def available
if @system
…
elseif @activation_key
…
end
…
end
I wonder if, in this case, would help just to make two
actions (one for system and one for activation_keys).
The only way as by now is to document that different in the description
of the param. For more structured appraoch, meta-attributes for params
introduced in (https://github.com/Pajk/apipie-rails/pull/181) might help,
but still not the cleanest solution ever.
– Ivan
···
----- Original Message -----
>
> Given multiple routes matching a single api controller method, what is the
> best way to differentiate the apipie params that are relevant to individual
> routes?
>
> In the example below, the :match_system is a param that only applies to the
> /systems route. Additionally, the :system_id and :activation_key_id params
> are mutually exclusive.
>
>
> api :GET, "/systems/:system_id/subscriptions/available", "List available
> subscriptions"
> api :GET, "/activation_keys/:activation_key_id/subscriptions/available",
> "List available subscriptions"
> param :system_id, String, :desc => "UUID of the system"
> param :activation_key_id, String, :desc => "activation key ID"
> param :match_system, :bool, :desc => "Return subscriptions that match
> system"
> param :match_installed, :bool, :desc => "Return subscriptions that match
> installed"
> param :no_overlap, :bool, :desc => "Return subscriptions that don't
> overlap"
> def available
> if @system
> ...
> elseif @activation_key
> ...
> end
> ...
> end
>
> --
> You received this message because you are subscribed to the Google Groups
> "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to foreman-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
> From: "Ivan Necas" <inecas@redhat.com>
> To: foreman-dev@googlegroups.com
> Sent: Friday, January 10, 2014 3:19:59 AM
> Subject: Re: [foreman-dev] apipie - how best to declare multiple doc for a single method?
>
> I wonder if, in this case, would help just to make two
> actions (one for system and one for activation_keys).
two actions that do the same thing? nack
ideally you could specify differences on a per-route basis with apipie.
example:
api :GET, "/systems/:system_id/subscriptions/available", "List available subscriptions" do
params only associated with this route
end
api :GET, "/activation_keys/:activation_keys_id/subscriptions/available", "List available subscriptions" do
params only associated with this route
end
params that both routes use
···
----- Original Message -----
The only way as by now is to document that different in the description
of the param. For more structured appraoch, meta-attributes for params
introduced in (https://github.com/Pajk/apipie-rails/pull/181) might help,
but still not the cleanest solution ever.
– Ivan
----- Original Message -----
Given multiple routes matching a single api controller method, what is the
best way to differentiate the apipie params that are relevant to individual
routes?
In the example below, the :match_system is a param that only applies to the
/systems route. Additionally, the :system_id and :activation_key_id params
are mutually exclusive.
api :GET, “/systems/:system_id/subscriptions/available”, "List available
subscriptions"
api :GET, “/activation_keys/:activation_key_id/subscriptions/available”,
"List available subscriptions"
param :system_id, String, :desc => "UUID of the system"
param :activation_key_id, String, :desc => "activation key ID"
param :match_system, :bool, :desc => "Return subscriptions that match
system"
param :match_installed, :bool, :desc => "Return subscriptions that match
installed"
param :no_overlap, :bool, :desc => "Return subscriptions that don’t
overlap"
def available
if @system
…
elseif @activation_key
…
end
…
end
+1. I like this solution. Adam, I'll be looking forward to the patch for this. Thanks.
David
···
----- Original Message -----
> From: "Adam Price"
> To: foreman-dev@googlegroups.com
> Sent: Friday, January 10, 2014 10:46:59 AM
> Subject: Re: [foreman-dev] apipie - how best to declare multiple doc for a single method?
>
> ----- Original Message -----
> > From: "Ivan Necas"
> > To: foreman-dev@googlegroups.com
> > Sent: Friday, January 10, 2014 3:19:59 AM
> > Subject: Re: [foreman-dev] apipie - how best to declare multiple doc for a
> > single method?
> >
> > I wonder if, in this case, would help just to make two
> > actions (one for system and one for activation_keys).
>
> two actions that do the same thing? nack
>
>
> ideally you could specify differences on a per-route basis with apipie.
>
> example:
>
> api :GET, "/systems/:system_id/subscriptions/available", "List available
> subscriptions" do
> # params only associated with this route
> end
> api :GET, "/activation_keys/:activation_keys_id/subscriptions/available",
> "List available subscriptions" do
> # params only associated with this route
> end
> # params that both routes use
>
> >
> > The only way as by now is to document that different in the description
> > of the param. For more structured appraoch, meta-attributes for params
> > introduced in (https://github.com/Pajk/apipie-rails/pull/181) might help,
> > but still not the cleanest solution ever.
> >
> > -- Ivan
> >
> > ----- Original Message -----
> > >
> > > Given multiple routes matching a single api controller method, what is
> > > the
> > > best way to differentiate the apipie params that are relevant to
> > > individual
> > > routes?
> > >
> > > In the example below, the :match_system is a param that only applies to
> > > the
> > > /systems route. Additionally, the :system_id and :activation_key_id
> > > params
> > > are mutually exclusive.
> > >
> > >
> > > api :GET, "/systems/:system_id/subscriptions/available", "List
> > > available
> > > subscriptions"
> > > api :GET,
> > > "/activation_keys/:activation_key_id/subscriptions/available",
> > > "List available subscriptions"
> > > param :system_id, String, :desc => "UUID of the system"
> > > param :activation_key_id, String, :desc => "activation key ID"
> > > param :match_system, :bool, :desc => "Return subscriptions that match
> > > system"
> > > param :match_installed, :bool, :desc => "Return subscriptions that
> > > match
> > > installed"
> > > param :no_overlap, :bool, :desc => "Return subscriptions that don't
> > > overlap"
> > > def available
> > > if @system
> > > ...
> > > elseif @activation_key
> > > ...
> > > end
> > > ...
> > > end
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "foreman-dev" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an
> > > email to foreman-dev+unsubscribe@googlegroups.com.
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "foreman-dev" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to foreman-dev+unsubscribe@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
>
> --
> - adam price
>
> --
> You received this message because you are subscribed to the Google Groups
> "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to foreman-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
+1 I'm new to apipie, but I'd love to have this feature as well. Any
Progress on that front since the last post?
···
On Friday, January 10, 2014 10:53:32 AM UTC-5, David Davis wrote:
>
> +1. I like this solution. Adam, I'll be looking forward to the patch for
> this. Thanks.
>
> David
>
> ----- Original Message -----
> > From: "Adam Price" <adp...@redhat.com >
> > To: forem...@googlegroups.com
> > Sent: Friday, January 10, 2014 10:46:59 AM
> > Subject: Re: [foreman-dev] apipie - how best to declare multiple doc for
> a single method?
> >
> > ----- Original Message -----
> > > From: "Ivan Necas" <ine...@redhat.com >
> > > To: forem...@googlegroups.com
> > > Sent: Friday, January 10, 2014 3:19:59 AM
> > > Subject: Re: [foreman-dev] apipie - how best to declare multiple doc
> for a
> > > single method?
> > >
> > > I wonder if, in this case, would help just to make two
> > > actions (one for system and one for activation_keys).
> >
> > two actions that do the same thing? nack
> >
> >
> > ideally you could specify differences on a per-route basis with apipie.
> >
> > example:
> >
> > api :GET, "/systems/:system_id/subscriptions/available", "List available
> > subscriptions" do
> > # params only associated with this route
> > end
> > api :GET,
> "/activation_keys/:activation_keys_id/subscriptions/available",
> > "List available subscriptions" do
> > # params only associated with this route
> > end
> > # params that both routes use
> >
> > >
> > > The only way as by now is to document that different in the
> description
> > > of the param. For more structured appraoch, meta-attributes for params
> > > introduced in (https://github.com/Pajk/apipie-rails/pull/181) might
> help,
> > > but still not the cleanest solution ever.
> > >
> > > -- Ivan
> > >
> > > ----- Original Message -----
> > > >
> > > > Given multiple routes matching a single api controller method, what
> is
> > > > the
> > > > best way to differentiate the apipie params that are relevant to
> > > > individual
> > > > routes?
> > > >
> > > > In the example below, the :match_system is a param that only applies
> to
> > > > the
> > > > /systems route. Additionally, the :system_id and :activation_key_id
> > > > params
> > > > are mutually exclusive.
> > > >
> > > >
> > > > api :GET, "/systems/:system_id/subscriptions/available", "List
> > > > available
> > > > subscriptions"
> > > > api :GET,
> > > > "/activation_keys/:activation_key_id/subscriptions/available",
> > > > "List available subscriptions"
> > > > param :system_id, String, :desc => "UUID of the system"
> > > > param :activation_key_id, String, :desc => "activation key ID"
> > > > param :match_system, :bool, :desc => "Return subscriptions that
> match
> > > > system"
> > > > param :match_installed, :bool, :desc => "Return subscriptions that
> > > > match
> > > > installed"
> > > > param :no_overlap, :bool, :desc => "Return subscriptions that
> don't
> > > > overlap"
> > > > def available
> > > > if @system
> > > > ...
> > > > elseif @activation_key
> > > > ...
> > > > end
> > > > ...
> > > > end
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > > "foreman-dev" group.
> > > > To unsubscribe from this group and stop receiving emails from it,
> send an
> > > > email to foreman-dev...@googlegroups.com .
> > > > For more options, visit https://groups.google.com/groups/opt_out.
> > > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "foreman-dev" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an
> > > email to foreman-dev...@googlegroups.com .
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> >
> > --
> > - adam price
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "foreman-dev" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to foreman-dev...@googlegroups.com .
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
>