Errors with OpenAPI (not already existing atom)

Installed the new OpenAPI stuff earlier. Getting:
Request: GET /api/json/openapi
** (exit) an exception was raised:
** (ArgumentError) errors were found at the given arguments:

* 1st argument: not an already existing atom

:erlang.binary_to_existing_atom("grants", :utf8)
Request: GET /api/json/openapi
** (exit) an exception was raised:
** (ArgumentError) errors were found at the given arguments:

* 1st argument: not an already existing atom

:erlang.binary_to_existing_atom("grants", :utf8)
22 Replies
\ ឵឵឵
\ ឵឵឵OP3y ago
Also, great work! This has been on my list for a bit. Stoked to start using this.
ZachDaniel
ZachDaniel3y ago
😣that’s pretty strange What’s the line number? should be fixed, try main 😄 Also, FWIW, expect to find more than a few bumps on the road with the Open API stuff 😆 In the long term though I think there is lots of awesome potential there. I want to add support for modify_json_schema(schema) -> schema on Ash.Resource.Validation structs. We can even do conditional application that way: https://json-schema.org/understanding-json-schema/reference/conditionals.html#if-then-else``` i.e we have validate Validation1, where: [Validation2, Validation3] Which we can map directly to if/then/else LMK if main works for you BTW
\ ឵឵឵
\ ឵឵឵OP3y ago
Just saw this, gimme 10 and I'll grab the new stuff and check.
ZachDaniel
ZachDaniel3y ago
no rush
\ ឵឵឵
\ ឵឵឵OP3y ago
Yup, looks great 👍 That brings up one thing I wanted to check into... Is there a way to override docs? Just tried with @doc @moduledoc. First became interested in this for playground/GQL schema embedded docs.
ZachDaniel
ZachDaniel3y ago
resource do
description "description"
end

attributes do
attribute, ...., description: "description"
end
resource do
description "description"
end

attributes do
attribute, ...., description: "description"
end
\ ឵឵឵
\ ឵឵឵OP3y ago
Beauty This is still WIP for OpenAPI, right? I'm getting it through perfect in my GQL schema.
ZachDaniel
ZachDaniel3y ago
Honestly, I didn't do all of the initial work for the open api stuff. I checked the code before I merged it, but open api should definitely be seen as a work in progress, yes
\ ឵឵឵
\ ឵឵឵OP3y ago
Right on, wanted to make sure it wasn't a config issue on this end.
ZachDaniel
ZachDaniel3y ago
GitHub
ash_json_api/open_api.ex at main · ash-project/ash_json_api
A JSON:API extension for the Ash Framework. Contribute to ash-project/ash_json_api development by creating an account on GitHub.
ZachDaniel
ZachDaniel3y ago
so it looks like we honor the action description
ZachDaniel
ZachDaniel3y ago
GitHub
ash_json_api/open_api.ex at main · ash-project/ash_json_api
A JSON:API extension for the Ash Framework. Contribute to ash-project/ash_json_api development by creating an account on GitHub.
\ ឵឵឵
\ ឵឵឵OP3y ago
Yup, can confirm. Weirdly, it's the opposite way for GQL? I get my resource description on everything, but the actions descriptions aren't making it into the schema. 😂
ZachDaniel
ZachDaniel3y ago
Interesting So your resource description should appear in the type, if thats where you are looking i.e listFoos -> Foo[] clicking on Foo should have the resource description but yeah you're right, I don't see us using action descriptions in ash_graphql
\ ឵឵឵
\ ឵឵឵OP3y ago
I was grepping the output schema and checking playground to see if it gets picked up via intro.
ZachDaniel
ZachDaniel3y ago
GitHub
ash_graphql/resource.ex at main · ash-project/ash_graphql
An absinthe backed graphql API extension for the Ash Framework - ash_graphql/resource.ex at main · ash-project/ash_graphql
\ ឵឵឵
\ ឵឵឵OP3y ago
I get my resource description on both, though 😁
ZachDaniel
ZachDaniel3y ago
basically in that mutations and queries function to produce the mutation/query fields, we'd add a description to the Field{} structs produced from mutation.action.description
\ ឵឵឵
\ ឵឵឵OP3y ago
# ~L449
name: to_string(mutation.name),
+ description: mutation.action.description
# ~L449
name: to_string(mutation.name),
+ description: mutation.action.description
ZachDaniel
ZachDaniel3y ago
Yeah, something like that should do it 🙂 I forget if mutation.action is the actual action or just the atom name so you might need to do:
Ash.Resource.Info.action(resource, mutation.action).description
Ash.Resource.Info.action(resource, mutation.action).description
\ ឵឵឵
\ ឵឵឵OP3y ago
Alright, had a chance to take a quick look at this.
\ ឵឵឵
\ ឵឵឵OP3y ago
GitHub
improvement: pass description through to Absinthe in more cases b...
Check the TODO:s for a couple of additional places where adding descriptions would require supporting them in core. Operators maybe not relevant, but Ash.Resource.Calculation.Argument probably wort...

Did you find this page helpful?