/micronaut-standards:response-modelingfrom Micronaut Standards
OneLiteFeather's sealed-interface response-DTO pattern for Micronaut REST APIs — a per-resource sealed interface with a success record and an error record, both implementing a shared org-wide ErrorResponse marker interface, plus static createDTO(entity) factory methods for entity-to-DTO conversion. Use this whenever defining what a controller endpoint returns. This replaces returning a raw String or null on failure, and replaces a generic RFC-7807-style problem-detail format — for the request-DTO side, see the dto skill; for how the global exception handler uses the same ErrorResponse type, see exception-handling; for how these types get referenced in @ApiResponse schemas, see openapi.
Ships in Micronaut Standards. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Every resource's response type is a sealed interface with exactly two implementations: a success
record and an error record. This gives every endpoint a type-safe way to express "either the data, or a
specific error" instead of returning null, a raw String error message, or throwing for cases that are
really just "not found."
package net.onelitefeather.otis.domain.font;
@Serdeable
public sealed interface FontModelResponseDTO {
@Schema(name = "ResponseFontModelDTO", description = "Font model data")
@Serdeable
record FontModelDTO(
@Schema(description = "The id of the model", requiredMode = Schema.RequiredMode.REQUIRED) UUID id,
@Schema(description = "Display name for the UI", requiredMode = Schema.RequiredMode.REQUIRED) String uiName,
@Schema(description = "The path to the texture", requiredMode = Schema.RequiredMode.REQUIRED) String texturePath
) implements FontModelResponseDTO {
public static FontModelDTO createDTO(FontEntity entity) {
return new FontModelDTO(entity.getId(), entity.getUiName(), entity.getTexturePath());
}
}
@Schema(name = "ResponseFontModelErrorDTO", description = "Error message")
@Serdeable
record FontModelErrorDTO(
@Schema(description = "Error message") String errorMessage
) implements FontModelResponseDTO, ErrorResponse {
}
}
ErrorResponse markerEvery resource's error record additionally implements one shared, org-wide ErrorResponse interface,
so callers (and the global exception handler — see exception-handling) can work with "an error
response" as a single type regardless of which resource produced it:
package net.onelitefeather.otis.domain.error;
public interface ErrorResponse {
@Schema(description = "Error message")
String errorMessage();
@Schema(description = "Error message")
@Serdeable
record ErrorResponseDTO(
@Schema(description = "Error message") String errorMessage
) implements ErrorResponse {
}
}
ErrorResponseDTO is the default/generic error shape, used by the global exception handler (see
exception-handling) for unexpected failures. A resource-specific error record like FontModelErrorDTO
is used instead when the controller/service already knows exactly what went wrong (e.g. "font not
found") and wants that reflected in its own OpenAPI schema rather than the generic one.
createDTO(entity) (and, where a projection needs extra data, additional named factories like
createDTOWithChars(entity)) live as static methods on the success record — the mirror image of the
toXxxEntity() instance method on the request DTO (see dto). This keeps entity↔DTO conversion
entirely inside the domain/<feature>/ package, with the service layer (see service-layer) as the
caller on both sides, never the owner of the conversion logic itself.
A generic type/title/status/detail/instance problem-detail body was considered and rejected in
favor of this sealed-interface pattern: it gives each endpoint a precise, resource-specific OpenAPI
schema per status code (see openapi) instead of one generic error shape reused everywhere, and it lets
a controller react to a failure with instanceof/pattern matching on a concrete type instead of parsing
a generic detail string.
FontModelResponseDTO result = fontService.deleteFont(id);
if (result instanceof FontModelResponseDTO.FontModelErrorDTO) {
return HttpResponse.notFound(result);
}
return HttpResponse.ok(result);
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub onelitefeathernet/onelitefeather-claude-marketplace --plugin micronaut-standards14 skills in this plugin
/configurationOneLiteFeather's convention for typed application configuration in a Micronaut REST API — one @ConfigurationProperties class per functional area in a dedicated config/ package, instead of ad-hoc properties scattered across the application entry point. Use this whenever a Micronaut backend needs a new piece of externalized configuration (a feature flag, an external service URL, a limit/threshold) and you're deciding where the corresponding Java type should live./dependency-managementOneLiteFeather's Gradle/Micronaut dependency-management conventions for REST API backends — the Micronaut Application and AOT plugins, reading the Micronaut version from gradle.properties instead of hardcoding it, the mn.* platform catalog, the private OneLiteFeather Maven repo, and the optional CycloneDX SBOM plugin. Use this whenever setting up or editing a Micronaut backend's build.gradle.kts/settings.gradle.kts. For the general OneLiteFeather Gradle/BOM mechanics that apply beyond Micronaut (private repo credential split, Java toolchain pattern), see minestom-knowledge:gradle/boms instead. For observability, database-migration, Testcontainers, and security dependencies specifically, see the observability, liquibase, testcontainers, and security skills — this skill only lists that those dependencies exist and where to look, not their coordinates; the one exception is structured-logging dependencies (Logstash encoder, OpenTelemetry MDC appender), whose coordinates live directly in this skill since `logging` covers only their usage.Other plugins' skills for the same job