Skip to content

feat: parse struct as map and render as json - #420

Merged
zachdaniel merged 1 commit into
ash-project:mainfrom
BordalloG:render_typed_structures
Aug 3, 2026
Merged

feat: parse struct as map and render as json#420
zachdaniel merged 1 commit into
ash-project:mainfrom
BordalloG:render_typed_structures

Conversation

@BordalloG

Copy link
Copy Markdown
Contributor

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Implementation for the issue #416

  • Created a new module Preferences that use Ash.TypedStruct.
  • Added a new attribute preferences to the User Resource.
  • Generated the migrations/snapshots.
  • Seeded the user with the default data for the preferences typed structure
  • Added a new overload to render_attribute that transform the typed structure into a map and recursively call it to use the implementation of a map, hence rendering it like a json.
Capture d’écran, le 2026-08-03 à 12 12 29

I did not add any tests because render_attribute is private, and I did not find any obvious place where I should add it. Let me know if that is ok, or you would prefer a test case somewhere.

@zachdaniel
zachdaniel merged commit 57ff6b4 into ash-project:main Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants