Skip to content

feat: unify fields[] type naming via [JsonApiResource] (opt-in) - #209

Merged
Erlend Ellefsen (erlendellefsen) merged 2 commits into
mainfrom
feat/unify-fields-type-naming
Aug 25, 2026
Merged

feat: unify fields[] type naming via [JsonApiResource] (opt-in)#209
Erlend Ellefsen (erlendellefsen) merged 2 commits into
mainfrom
feat/unify-fields-type-naming

Conversation

@erlendellefsen

Copy link
Copy Markdown
Collaborator

Summary

  • Included resources' type (and relationship linkage pointing at them) used the camelCased CLR class name, while the primary resource used the controller-supplied string. fields[type] could not target both with one name for a type like [JsonApiResource("people")] on class Author.
  • New opt-in JsonApiOptions.UseResourceAttributeTypeNames: when true, an included resource's type comes from its [JsonApiResource] attribute if present, falling back to the camelCased class name otherwise.
  • Wire-affecting, so off by default, matching the pattern of StrictQueryValidation / PreserveQueryInPaginationLinks.

Test plan

  • just check test test-contract: 677 .NET tests, TypeGen tests, and the full Deno contract suite all pass.
  • just typegen --check: no drift.
  • New unit tests in InclusionMapperTests cover the flag on, off, and falling back for a type without the attribute.

Included resources' "type" (and relationship linkage pointing at them)
used the camelCased CLR class name, while the primary resource used the
controller-supplied string, so fields[type] could not target both with
one name for types like [JsonApiResource("people")] on class Author.

New opt-in flag JsonApiOptions.UseResourceAttributeTypeNames makes
included resources use their [JsonApiResource] type name when present,
falling back to the camelCased class name otherwise. Wire-affecting,
so off by default.
@erlendellefsen
Erlend Ellefsen (erlendellefsen) merged commit 969cb06 into main Aug 25, 2026
14 checks passed
@erlendellefsen
Erlend Ellefsen (erlendellefsen) deleted the feat/unify-fields-type-naming branch August 25, 2026 13:17
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.

1 participant