I've built a web UI for an app that allows sorting a resource using the query: [sort_input: "-inserted_at"] syntax for a read action. sort_input accepts any public field, including aggregates and calculations, and this works great.
I've exposed the same action in an API generated with AshJsonApi and the list of possible options it says it accepts is shorter - it lists all public attributes, but not aggregates or calculations.
Other values still work if provided to the API, but this list of options is used in things like Swagger UI documentation to populate a select box, so other valid values couldn't be entered.
Plus, the documentation should really cover all possible values if it says it does!
On a somewhat-unrelated note, is it possible to customize this list/the filter list to not allow filtering/sorting by some public attributes? In this example, previous_names is an array, which doesn't make too much sense to filter/sort on. (Attempting to filter on previous_names generates an error when attempted from SwaggerUI, anyhow.)
Expected behavior
The enum in the generated OpenAPI documentation should list all public attributes in ascending/descending forms, including aggregates and calculations.
Runtime
Elixir version 1.17.0-otp-27
Erlang version 27.0
OS macOS Sonoma
Ash version 3.0.13
AshJsonApi version main branch at commit 7e25b92b8bf78b22b2736ff1093eb6de698a4313
There is not a way to do it at the json_api level, but all fields have a sortable? and filterable? option that can be set to false at the resource level.
Describe the bug
I've built a web UI for an app that allows sorting a resource using the
query: [sort_input: "-inserted_at"]
syntax for a read action.sort_input
accepts any public field, including aggregates and calculations, and this works great.I've exposed the same action in an API generated with AshJsonApi and the list of possible options it says it accepts is shorter - it lists all public attributes, but not aggregates or calculations.
Other values still work if provided to the API, but this list of options is used in things like Swagger UI documentation to populate a select box, so other valid values couldn't be entered.
Plus, the documentation should really cover all possible values if it says it does!
On a somewhat-unrelated note, is it possible to customize this list/the filter list to not allow filtering/sorting by some public attributes? In this example,
previous_names
is an array, which doesn't make too much sense to filter/sort on. (Attempting to filter onprevious_names
generates an error when attempted from SwaggerUI, anyhow.)Expected behavior
The
enum
in the generated OpenAPI documentation should list all public attributes in ascending/descending forms, including aggregates and calculations.Runtime
main
branch at commit 7e25b92b8bf78b22b2736ff1093eb6de698a4313