spring-rest-api-creator
БесплатноБез исполняемых скриптовНе проверенCreates Spring REST APIs following best practices.
от sivaprasadreddy★ 46 звёзд на GitHubОб этом скилле
Spring REST APIs Creator
Instructions
The following are key principles to follow while creating Spring REST APIs:
- Make sure to create the recommended package structure for Spring Boot projects
- Use converters to bind
@PathVariableand@RequestParamto Value Objects - Use Jackson for
@RequestBodybinding to Request Objects with Value Object properties - Use
@JsonUnwrappedto map flattened JSON to nested objects - Validate with
@Validannotation - Return appropriate HTTP status codes
- Delegate to services for business logic execution
Converter for PathVariable/RequestParam Binding
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
@Component
public class StringToEventCodeConverter implements Converter<String, EventCode> {
@Override
public EventCode convert(String source) {
return new EventCode(source);
}
}
This allows Spring MVC to automatically convert path variables like /{eventCode} from String to EventCode:
@GetMapping("/{eventCode}")
ResponseEntity<EventVM> findEventByCode(@PathVariable EventCode eventCode) {
// eventCode is already an EventCode object, not a String
}
Binding primitives to Request Bodies with Value Objects
Use @JsonValue and @JsonCreator annotations to bind primitives to Request Bodies with Value Objects.
EventCode Value Object:
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import jakarta.validation.constraints.NotBlank;
public record EventCode(
@JsonValue
@NotBlank(message = "Event code cannot be null or empty")
String code
) {
@JsonCreator
public EventCode {
if (code == null || code.trim().isEmpty()) {
throw new IllegalArgumentException("Event code cannot be null");
}
}
public static EventCode of(String code) {
return new EventCode(code);
}
}
CreateEventRequest Request Payload:
record CreateEventRequest(
@Valid EventCode code
// ... other properties
) {
}
Now Spring MVC will automatically bind the code property from the JSON payload to EventCode object.
{
"code": "ABSHDJFSD",
"property-1": "value-1",
"property-n": "value-n"
}
Binding flattened JSON to Nested Objects
Use @JsonUnwrapped and @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) annotations to map flattened JSON to nested objects.
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.constraints.Size;
public record EventDetails(
@NotBlank(message = "Title is required")
@Size(min = 3, max = 200, message = "Title must be between 3 and 200 characters")
String title,
@NotBlank(message = "Description is required")
@Size(max = 10000, message = "Description cannot exceed 10000 characters")
String description,
@Size(max = 500, message = "Image URL cannot exceed 500 characters")
@Pattern(regexp = "^https?://.*", message = "Image URL must be a valid HTTP/HTTPS URL")
String imageUrl) {
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public EventDetails(
@JsonProperty("title") String title,
@JsonProperty("description") String description,
@JsonProperty("imageUrl") String imageUrl
) {
this.title = AssertUtil.requireNotNull(title, "title cannot be null");
this.description = AssertUtil.requireNotNull(description, "description cannot be null");
this.imageUrl = imageUrl;
}
public static EventDetails of(String title, String description, String imageUrl) {
return new EventDetails(title, description, imageUrl);
}
}
CreateEventRequest Request Payload:
record CreateEventRequest(
@Valid EventCode code,
@JsonUnwrapped @Valid EventDetails details
// ... other properties
) {
}
Now Spring MVC will automatically bind the title, description and imageUrl property values
from the JSON payload to EventDetails object.
{
"code": "ABSHDJFSD",
"title": "Spring Boot Workshop",
"description": "Learn Spring Boot best practices",
"imageUrl": "https://example.com/image.jpg",
"property-1": "value-1",
"property-n": "value-n"
}
Global Exception Handler
Create a centralized exception handler that returns ProblemDetail responses.
Create a class GlobalExceptionHandler by following the following key principles:
- Use
@RestControllerAdvice - Extend
ResponseEntityExceptionHandler - Return
ProblemDetailfor RFC 7807 compliance - Map different exceptions to appropriate HTTP status codes
- Include validation errors in response
- Hide internal details in pro
Установить spring-rest-api-creator в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл spring-rest-api-creator?
Creates Spring REST APIs following best practices.
Как установить скилл spring-rest-api-creator?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл spring-rest-api-creator запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic