From jsonapi4j
Builds JSON:API-compliant backends with the jsonapi4j framework: resources, relationships, operations, compound documents, validation, security, config, and RestAssured testing. Use in codebases with pro.api4 imports or @JsonApiResource annotations.
How this skill is triggered — by the user, by Claude, or both
Slash command
/jsonapi4j:jsonapi4jThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
jsonapi4j (`pro.api4`, by Aliaksei Taliuk) is a persistence-agnostic Java framework for building
jsonapi4j (pro.api4, by Aliaksei Taliuk) is a persistence-agnostic Java framework for building
JSON:API-compliant REST APIs. No JPA/ORM required — it works over any data
source (JdbcTemplate, a REST client, in-memory, …). It ships three integrations: Spring Boot,
Quarkus, and plain Jakarta Servlet. Docs: https://api4.pro/.
This skill is the consumer's guide — how to build with the framework. Keep SKILL.md lean; open the
matching reference/<file>.md when you go deep on a topic (paths below). When you confirm a new pattern
or quirk, add it to the relevant reference file.
Versioned behavior: edge behaviors are version-specific (current line is 1.8.x). Treat the
"known behaviors" notes as "verify against the version on your classpath and the framework's own
tests," not gospel. The canonical, runnable reference is the framework's examples/ sample apps
(Spring Boot / Quarkus / Servlet over a shared domain).
Every resource (and every relationship) is split into small single-purpose classes, auto-discovered as
beans (Spring @Component / Quarkus CDI / registered in the Servlet context):
Resource<DTO> — maps a backend DTO to a JSON:API resource: resolveResourceId +
resolveAttributes. Annotated @JsonApiResource(resourceType = "users").Relationship<REF> — maps to a resource identifier ({type, id} + optional identifier meta/links).
It has no attributes. Annotated
@JsonApiRelationship(relationshipName = "citizenships", parentResource = UserResource.class).
Use ToOneRelationship<REF> / ToManyRelationship<REF>.*Operations — the data access. Annotated @JsonApiResourceOperation(resource = ...) or
@JsonApiRelationshipOperation(relationship = ...). Implement the composite
ResourceOperations<DTO> / ToOneRelationshipOperations<PARENT, CHILD> /
ToManyRelationshipOperations<PARENT, CHILD> — each method defaults to throwing
OperationNotFoundException, so you override only what your resource actually supports, plus the
matching validateXxx hooks.@Component
@JsonApiResource(resourceType = "users")
public class UserResource implements Resource<UserDbEntity> {
public String resolveResourceId(UserDbEntity u) { return u.getId(); }
public UserAttributes resolveAttributes(UserDbEntity u) {
return new UserAttributes(u.getFullName(), u.getEmail());
}
}
(See the real thing: examples/jsonapi4j-sampleapp-domain/.../domain/user/UserResource.java.)
Resource<DTO> + an *Attributes class holding only this
resource's own data.ResourceOperations<DTO>: readById, readPage (+ validateReadById / validateReadMultiple);
throw ResourceNotFoundException on a miss. Choose a pagination strategy for readPage.ToOne/ToManyRelationship<Ref> — prefer lightweight refs over heavy DTOs (any
type works; only id/type/meta are read, so it's your call);
*Operations with readOne/readMany (+ readOneForResource/readManyForResource and/or batch
ops to avoid N+1 on includes).jsonapi4j.cd.mapping.<type> entry
(+ batchSizeMapping) and support filter[id] on its readPage.?include= cases (fixed port / CD profile).reference/resources-and-operations.md — Resource contract, the composite operations, pagination
modes and PaginationAwareResponse factories (incl. null vs empty()), the one-mapper-per-resource
data-layer rule.reference/relationships.md — to-one/to-many, lightweight refs vs full DTOs,
readOneForResource/readManyForResource and batch ops (N+1 avoidance), edge data in identifier meta.reference/compound-documents.md — ?include=, cd.mapping self-HTTP resolution, multi-hop,
synthetic-primary caveat, header/param propagation.reference/performance.md — filter[id] batching, in-house resolution, parallel ExecutorService,
hop/size caps, the compound-docs cache + Cache-Control.reference/validation-and-security.md — validateXxx hooks, the fluent JsonApiRequestValidator,
exceptions (400/404/custom), the two independent security layers + the AC plugin.reference/configuration.md — the jsonapi4j.* property reference.reference/testing.md — RestAssured black-box patterns; random vs fixed port for ?include=
tests; test profiles; Testcontainers/Flyway/auth stubs.reference/separation-of-concerns.md — attribute ownership; migrating a denormalized field out to
an ?included relationship safely.reference/known-behaviors.md — version-specific quirks (related-URL 404s, to-one linkage
rendering, null refs, cursor meta key, enum attributes, etc.).npx claudepluginhub moonworm/jsonapi4j --plugin jsonapi4jCreates or modifies REST endpoints, controllers, DTOs, and error handling in Java Spring services with conventions for response envelopes, pagination, Problem Details, and package layout.
Generates REST APIs with CRUD endpoints, pagination, filtering, auth, tests for Express, FastAPI, Spring Boot, Gin from OpenAPI specs or schemas.
Implements Spring Boot 4 REST API patterns for controllers, validation with Bean Validation 3.1, ProblemDetail exceptions (RFC 9457), API versioning, WebFlux endpoints, Jackson 3 serialization, CORS, and @HttpExchange clients.