How can show calculate as fields object in Swaggerui

Hi sorry, i made my calculate public and i can see in the example of Success Responses but inside fields object it just shows the attributes! and user has to change it by his hand and add the calculate name . if i change this manually in the fields object text aria it works! Is there a way to show calculate as fields inside this text aria as default? or i should change the AshJsonApiRouter? Thank you in advance
No description
Solution:
But it does look like that open api schema is wrong. Issue/PR welcome 🙂
Jump to solution
7 Replies
Rebecca Le
Rebecca Le•2mo ago
you would probably have to customize default_fields for the resource https://hexdocs.pm/ash_json_api/dsl-ashjsonapi-resource.html#json_api-default_fields - this defaults to all public fields (not calculations or aggregates)
Shahryar
ShahryarOP•2mo ago
If you mean this
json_api do
type "user"

default_fields [:id, :email, :confirmed_at, :permission_values]
end
json_api do
type "user"

default_fields [:id, :email, :confirmed_at, :permission_values]
end
still the permission_values which is calculation dose not exist in the fields object Because the front developers read the api, it is very hard to tell them read the Responses example so i need to put it as default inside fields object
Rebecca Le
Rebecca Le•2mo ago
oh interesting, yes that's what I meant
sevenseacat
sevenseacat•2mo ago
https://github.com/ash-project/ash_json_api/blob/v1.4.40/lib/ash_json_api/json_schema/open_api.ex#L1931-L1947 we might want to update both the example fields here to use the value from default_fields instead
GitHub
ash_json_api/lib/ash_json_api/json_schema/open_api.ex at v1.4.40 ·...
The JSON:API extension for the Ash Framework. Contribute to ash-project/ash_json_api development by creating an account on GitHub.
Shahryar
ShahryarOP•2mo ago
Or consider calculation if dose not define default fields 🤔
ZachDaniel
ZachDaniel•2mo ago
The "default default fields" is all public attributes and that won't change
Solution
ZachDaniel
ZachDaniel•2mo ago
But it does look like that open api schema is wrong. Issue/PR welcome 🙂

Did you find this page helpful?