About api-platform-serialization
A Symfony skill for configuring API Platform serialization across operations. It guides field groups, relation rendering, computed fields, and safeguards such as depth limits and hiding secrets.
Key features
- 01Operation-specific serialization groups
- 02IRI or embedded relations
- 03Computed and role-dependent fields
- 04Property-level normalizer options
- 05Cycle and secret-field safeguards
Use cases
- 01Expose different fields for list and read operations
- 02Control whether related resources are embedded
- 03Format dates without a custom normalizer
- 04Add computed fields while keeping entities clean
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dev-toolings/ superpowers-symfony --skill api-platform-serializationAfter installing, type/api-platform-serializationin Claude Code to confirm it loaded.
Bundled filesreference.md
Details
From the project READMEApi Platform Serialization (Symfony)
Use when
- Operations must expose different fields (list, read, create, update).
- A related resource must render as an IRI or be embedded.
- A response needs computed or role-dependent fields.
- A property needs normalizer options such as a date format.
Default workflow
- Name groups
entity:operationand setnormalizationContextanddenormalizationContextper operation. - Tag properties with
#[Groups]from the SerializerAttributenamespace, not the oldAnnotationone. - Control relations with
#[ApiProperty(readableLink: false, writableLink: false)]to force IRIs. - Apply per-property options with
#[Context]instead of writing a normalizer. - Add computed fields in a custom normalizer, and dynamic groups in a decorator of
api_platform.serializer.context_builder. - Prevent cycles with
#[MaxDepth]andenable_max_depth, and hide secrets with#[Ignore].
Guardrails
- Use separate read and write groups: for example
passwordonly in the create group,idonly in read groups. - A related resource is embedded only when it shares a group with the parent; otherwise it renders as an IRI.
#[MaxDepth]has no effect unlessenable_max_depthis true in the context.- Keep entities clean: computed fields belong in normalizers.
Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.
Output contract
- The groups and contexts per operation, as a field matrix.
- Normalizers or context builders added, and how they are registered.
- Tests or OpenAPI output showing the resulting fields.
References
reference.md
Comments
Markdown supported