srikanthkyatham
Ash json embedded schema in swagger
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
Most Liked
zachdaniel
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
zachdaniel
![]()
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 ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








