api-platform-dto-resources — скилл для Claude Code
Скилл api-platform-dto-resources для Claude Code отделяет API-контракт от Doctrine-сущности в API Platform через Object Mapper. Маппинг учитывает различия полей и отдельные формы для create, update и list.
MIT ★ 234 обновлён 2026-10-05
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a claude-codeЧто делает api-platform-dto-resources
Скилл автоматизирует создание DTO-ресурсов в API Platform v5, v4.4, v4.3 с Symfony Object Mapper. Вместо того чтобы возвращать сущность напрямую, вы определяете #[ApiResource] класс как DTO и связываете его с entity через #[Map(source: ...)] и #[Map(target: ...)]. Для преобразованных полей (переименования, форматирования, вычисляемые значения) применяется #[Map(transform: ...)].
Скилл охватывает три пути: использование встроенного Object Mapper с stateOptions, создание отдельных input и output классов для разных операций, и написание кастомного ProcessorInterface для сложной логики. Важное ограничение — Object Mapper требует Symfony 7.3+ и не работает на API Platform 3.4 (там нужен ручной маппинг в provider и processor).
Скилл помогает избежать потерь от удаления DataTransformerInterface и даёт знать о том, что на API Platform 5.0 ObjectMapperProcessor переехал в ObjectMapperInputProcessor и ObjectMapperOutputProcessor. Выходной контракт включает классы ресурсов с привязками, выбор пути маппинга и тесты каждой операции.
Какие задачи решает
- Отделить API-контракт от сущности Doctrine
- Переименовать поля сущности в API без дублирования кода
- Создать разные формы ввода и вывода для одной операции
- Мигрировать со снятого DataTransformerInterface на Object Mapper
- Вычислить и вывести поля, которых нет в entity
Примеры запросов агенту
- Создай DTO для Entity с переименованием полей через #[Map]
- Настрой input и output классы для create и update операций
- Напиши кастомный processor для трансформации сложных данных
Как установить api-platform-dto-resources
1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a claude-code2Вручную: положить файлы
~/.claude/skills/api-platform-dto-resources/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/api-platform-dto-resources/
1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a codex2Вручную: положить файлы
.agents/skills/api-platform-dto-resources/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a cursor2Вручную: положить файлы
.cursor/skills/api-platform-dto-resources/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install dev-toolings/superpowers-symfony content/skills/api-platform-dto-resources2Вручную: положить файлы
.github/skills/api-platform-dto-resources/SKILL.md1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a gemini-cli2Командой платформы
gemini skills install https://github.com/dev-toolings/superpowers-symfony --path content/skills/api-platform-dto-resourcesВручную: положить файлы
.devin/skills/api-platform-dto-resources/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы об api-platform-dto-resources
Как установить api-platform-dto-resources в Claude Code?
Выполни npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a claude-code, затем открой ~/.claude/skills/api-platform-dto-resources/SKILL.md.
Что делает этот скилл?
Автоматизирует маппинг сущностей на DTO в API Platform через Symfony Object Mapper, позволяя отделить API-контракт от Doctrine-entity и создавать разные формы для ввода и вывода данных.
На каких версиях API Platform это работает?
Object Mapper поддерживается на API Platform v5, v4.4, v4.3, но требует Symfony 7.3+. На API Platform 3.4 и Symfony 6.4 LTS нужно маппировать вручную в provider и processor.
Исходный текст
SKILL.md · MIT
--- name: api-platform-dto-resources description: Map entities to API DTOs in API Platform (v5, 4.4, 4.3) with the Symfony Object Mapper (#[Map], stateOptions) for decoupled input/output contracts capabilities: [read, search, edit, shell] tags: [api-platform] # projected by `bun run build` — do not edit by hand allowed-tools: - Read - Glob - Grep - Write - Edit - Bash --- # Api Platform Dto Resources (Symfony) ## Use when - The `#[ApiResource]` class must be the API contract, decoupled from the Doctrine entity. - Entity and API fields differ in name or format (rename, formatted price, computed value). - Create, update, or list operations need their own input or output shape. - Migrating code that relied on `DataTransformerInterface`, which no longer exists. ## Default workflow 1. Require `symfony/object-mapper` and set `stateOptions: new Options(entityClass: ...)` on the DTO resource. 2. Bind the DTO and the entity with `#[Map(source: ...)]` and `#[Map(target: ...)]`, and use `#[Map(transform: ...)]` for computed fields. 3. For distinct shapes, create input and output classes and wire them with `input:` and `output:` on each operation. 4. When mapping needs real logic, write a custom `ProcessorInterface` that calls `ObjectMapperInterface::map()`. 5. Test each operation: payload in, response shape out. ## Guardrails - The automatic Object Mapper provider and processor only apply when `stateOptions` has an `entityClass` and both the DTO and the entity carry `#[Map]`. - `DataTransformerInterface` is gone: use Object Mapper or a provider and processor. - No Object Mapper on 3.4 or on Symfony 6.4 LTS (it needs Symfony 7.3+): map manually in a `ProviderInterface` and a `ProcessorInterface`. - `ObjectMapperProcessor` is removed in 5.0: the automatic path uses `ObjectMapperInputProcessor` and `ObjectMapperOutputProcessor` (4.3+). - Never return the entity itself from a DTO resource: only mapped fields reach the client. ## Progressive disclosure - Use this file for execution posture and risk controls. - Open references when deep implementation details are needed. ## Output contract - The resource, input, and output classes with their `#[Map]` bindings. - The mapping path chosen (Object Mapper or custom processor) and why. - Tests showing the request and response shape of each operation. ## References - `reference.md`
© dev-toolings · MIT · dev-toolings/superpowers-symfony