AF
Ash Framework•5mo ago
Ahrou

AshJsonAPI generic action arguments in a GET route

I have this simple generic action and route
base_route "/operational-settings", Core.OperationalSetting do
route(:get, "/:configuration_key", :get)
end

action :get, :struct do
constraints instance_of: Type.OperationalSettingValue

argument :configuration_key, :string, allow_nil?: false
argument :campaign_id, :string, allow_nil?: true

run fn input, context ->
get_setting(input.arguments, context.actor)
end
end
base_route "/operational-settings", Core.OperationalSetting do
route(:get, "/:configuration_key", :get)
end

action :get, :struct do
constraints instance_of: Type.OperationalSettingValue

argument :configuration_key, :string, allow_nil?: false
argument :campaign_id, :string, allow_nil?: true

run fn input, context ->
get_setting(input.arguments, context.actor)
end
end
As it is defined we can see the argument in the request body in the open_api spec, but it does not get picked up in a GET request. Changing the route to a POST works, so i am wondering if in a GET request arguments are not supported? I also tried setting the query param campaign_id but still nothing.
Solution:
there is a query_params option IIRC that determines which action inputs are lifted to query params though
Jump to solution
6 Replies
ZachDaniel
ZachDaniel•5mo ago
🤔 it may be an oversight
Solution
ZachDaniel
ZachDaniel•5mo ago
there is a query_params option IIRC that determines which action inputs are lifted to query params though
ZachDaniel
ZachDaniel•5mo ago
try specifying that option
Ahrou
AhrouOP•5mo ago
yes that works thank you 🙌 so it should be the default behaviour? should i open a github issue?
ZachDaniel
ZachDaniel•5mo ago
Yes please. For get routes, we should assume they are query params if they aren't in the route.
Ahrou
AhrouOP•5mo ago
GitHub
GET routes for Generic Actions do not assume the arguments as query...
Describe the bug When defining a GET route for a generic action, if we define optional arguments they are not accepted as query params. In the open_api spec they are shown as part of the request bo...

Did you find this page helpful?