mapper-customization

Customize Spiderly-generated Mapster mappers via partial class overrides.

61|24|Updated Sep 14, 2024
One-click install
npx skills add https://github.com/filiptrivan/spiderly --skill mapper-customization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mapper-customization
Source: https://github.com/filiptrivan/spiderly/tree/main/claude-plugins/skills/mapper-customization
Command: npx skills add https://github.com/filiptrivan/spiderly --skill mapper-customization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Customize Spiderly-generated Mapster mappers by overriding the default mappings to add computed fields, customize projections, or switch between DTO and entity shapes.

Core Features & Use Cases

  • Override generated mappings by defining a user-created partial Mapper class annotated with [SpiderlyDataMapper], which prevents overwriting custom logic during regeneration.
  • Add inline mappings or adjust projections using [ProjectToDTO] attributes and the generated TypeAdapterConfig methods.
  • Maintain a clean separation between generated baseline mappings and user customizations to enable upgrade-safe workflows.

Quick Start

Create a partial Mapper class annotated with [SpiderlyDataMapper] and override any generated mapping method to customize DTO mappings.

Frequently Asked Questions about mapper-customization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I customize Mapster mappings without losing changes when regenerating code?

To customize Mapster mappings safely, define a partial Mapper class annotated with [SpiderlyDataMapper] and override the generated mapping methods. This prevents the code generator from overwriting your custom DTO projections and computed fields during regeneration.

How do I add computed fields to a DTO projection using Mapster?

You can add computed fields to a DTO projection by overriding the generated TypeAdapterConfig methods in a partial class. This allows you to inject custom logic for entity-to-DTO mappings while maintaining the baseline generated mappings.

What is the [SpiderlyDataMapper] attribute used for in Mapster configurations?

The [SpiderlyDataMapper] attribute marks user-created partial Mapper classes to separate custom mapping logic from generated baseline code. It ensures the generator recognizes and preserves your overridden methods during code regeneration.

Can I use inline mappings with generated Mapster TypeAdapterConfig patterns?

Yes, you can apply inline mappings by adjusting projections using [ProjectToDTO] attributes alongside generated TypeAdapterConfig methods. This supports tailored DTO-to-entity and entity-to-DTO behavior across multiple entities.

Does overriding Spiderly-generated mappers support multiple entities and projects?

Yes, overriding Spiderly-generated mappers supports customization across multiple entities and projects. You can tailor mappings wherever computed fields, custom projections, or specific DTO and entity shapes are required.