AGENT SKILL
spring-boot-api-design
Standards for OpenAPI, Versioning, and Global Error Handling. Use when designing Spring Boot APIs with OpenAPI specs, versioning, or global error handling. (triggers: **/*Controller.java, openapi, swagger, versioning, problemdetails)
- License 许可
- MIT
- 最近更新
- 2026-06-24
- Stars
- ★ 67
- Forks
- 24
01 前言 Front Matter
- name
- spring-boot-api-design
- description
- Standards for OpenAPI, Versioning, and Global Error Handling. Use when designing Spring Boot APIs with OpenAPI specs, versioning, or global error handling. (triggers: **/*Controller.java, openapi, swagger, versioning, problemdetails)
02 资源文件 12
- 许可证LICENSE.txt11.1 KB
- 资产文件theme-showcase.pdf121.4 KB
- 参考文档themes/arctic-frost.md544 B
- 参考文档themes/botanical-garden.md519 B
- 参考文档themes/desert-rose.md496 B
- 参考文档themes/forest-canopy.md506 B
- 参考文档themes/golden-hour.md528 B
- 参考文档themes/midnight-galaxy.md513 B
- 参考文档themes/modern-minimalist.md549 B
- 参考文档themes/ocean-depths.md555 B
- 参考文档themes/sunset-boulevard.md558 B
- 参考文档themes/tech-innovation.md547 B
03 SKILL.md 正文
Spring Boot API Design Standards
Priority: P0
Implementation Guidelines
OpenAPI (Swagger)
- SpringDoc: Use
springdoc-openapi-starter-webmvc-ui. - Annotations: Use
@Operationand@ApiResponse. Keep clean. - Schema: Define examples in
@Schemaon DTOs.
API Versioning
- Strategy: Prefer URI Versioning (
/api/v1/) for caching simplicity. - Deprecation: Use
@Deprecated+ OpenAPI flag.
Error Handling (RFC 7807)
- ProblemDetails: Enable
spring.mvc.problem-details.enabled=true. - Extension: Extend
ProblemDetailwith custom fields if needed. - Security: NEVER expose stack traces in API errors.
Anti-Patterns
- No Map<K,V> responses: Return typed DTO records instead.
- No Header Versioning: Use URI versioning; headers are hard to test/cache.
- No hidden APIs: Document all endpoints with Swagger/OpenAPI.