Hi
I am using the ash + ash_json_api. How to get the embedded ash resources in the swagger schema documentation.
I am using
ash: v3.0.2
ash_json_api: v1.0.0
-Srikanth
Hi
I am using the ash + ash_json_api. How to get the embedded ash resources in the swagger schema documentation.
I am using
ash: v3.0.2
ash_json_api: v1.0.0
-Srikanth
It looks like this is a missing feature on our end. Please open a feature request on ash_json_api
. There are ways to modify the open api spec to add what you want in, but it is a bit annoying to do so, so you may want to wait for us to add it or help contribute it to core
use AshJsonApi.Router,
domains: [...],
open_api: "/open_api",
modify_open_api: {__MODULE__, :modify_open_api, []}
def modify_open_api(spec, _, _) do
%{
spec
| info: %{spec.info | title: "MyApp Title JSON API", version: Application.spec(:my_app, :vsn) |> to_string()}
}
end
Hi @zachdaniel
I can open a feature request on the github. Also I can contribute.
The main thing to consider before diving in is that embedded attributes are a bit more complex than simple typed maps, because they can theoretically involve create/update actions. So what we’d want to do is, given an embedded attribute, check its :create_action
, and :update_action
constraint (defaulting to the primary create/update if they exist), and then generate a schema for calling each of those actions. Then we’d want to uniq
those schemas to eliminate any potential duplicates. If there is only one, thats the schema, if there are multiple, we present them as options.
The above may not be exactly right but might be enough to get you on the right track. Please ask if you have any additional questions