Spring REST API Design

Standardizes RESTful API design in Spring Boot with controllers, DTOs, and pagination patterns.

Updated May 12, 2026
One-click install
npx skills add https://github.com/ZzZueszZ/claude-kit --skill spring-rest-api-design-zzzueszz
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: Spring REST API Design
Source: https://github.com/ZzZueszZ/claude-kit/tree/main/.claude/skills/spring-rest-api
Command: npx skills add https://github.com/ZzZueszZ/claude-kit --skill spring-rest-api-design-zzzueszz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Inconsistent REST API design across a Spring Boot codebase leads to confusing endpoints, wrong HTTP status codes, leaked entities, and ad-hoc response formats that are hard for clients to consume. ## Core Features & Use Cases - RESTful URL Conventions: Enforces plural nouns, kebab-case, lowercase paths, and /api/v1/ versioning with correct HTTP method mappings. - Controller & DTO Patterns: Provides templates for thin controllers using ResponseEntity, Java Record request/response DTOs with Bean Validation, and MapStruct-based entity mapping. - Standard Responses & Pagination: Defines an ApiResponse<T> wrapper, correct status code usage (201, 204, 409, etc.), and a PageResponse pattern for paginated endpoints. - Use Case: When building a new /api/v1/users resource, apply the skill to generate a controller with proper status codes, validated request DTOs, a wrapped response, and paginated list endpoints. ## Quick Start Ask the AI to design a RESTful CRUD API for a new entity following the Spring REST API conventions, including DTOs, validation, and pagination.

Frequently Asked Questions about Spring REST API Design

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

FAQPage Schema
How do I design RESTful API URLs in Spring Boot?▼

Use plural lowercase nouns with kebab-case for multi-word resources and prefix paths with a version like /api/v1/. Map HTTP methods to operations: GET for reads, POST for creation, PUT/PATCH for updates, and DELETE for removal, never putting verbs in URLs.

How to structure request and response DTOs in Spring Boot?▼

Separate request and response DTOs using Java Records, placing Bean Validation annotations like @NotBlank and @Email on request DTOs. Never expose JPA entities directly from controllers; map between entities and DTOs with MapStruct or a dedicated mapper component.

What HTTP status codes should a Spring REST API return?▼

Return 200 for successful GET/PUT/PATCH, 201 with a Location header for POST creation, and 204 for DELETE. Use 400 for validation errors, 404 for missing resources, 409 for conflicts like duplicate emails, and never return 200 for errors.

MapStruct vs manual mapper for entity to DTO conversion?▼

MapStruct is preferred because it generates type-safe mapping code at compile time via a @Mapper interface with componentModel spring. A manual @Component mapper works as an alternative, but mapping logic should never live inside controllers or services.

How do I add pagination to a Spring Boot list endpoint?▼

Accept page, size, and sort query parameters, build a Pageable with PageRequest.of, and return a PageResponse record wrapping the Spring Data Page. The wrapper exposes content, page, size, totalElements, totalPages, and first/last flags.

Why should controllers not contain business logic in Spring?▼

Controllers should only handle HTTP concerns such as request binding, validation via @Valid, and building ResponseEntity responses. Business logic belongs in the service layer, keeping controllers thin, testable, and decoupled from domain rules.