一键导入
api-design
REST API design patterns. URL naming, HTTP status codes, pagination, RFC 7807 error responses, versioning, and OpenAPI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
REST API design patterns. URL naming, HTTP status codes, pagination, RFC 7807 error responses, versioning, and OpenAPI.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Planning Mode skill for guided execution of large tasks. Provides structured task decomposition, user confirmation, per-task verification, retry logic, and quality summary.
Git 工作流 — 版本控制、提交规范、分支管理、.gitignore 治理
Structured bug diagnosis and repair workflow using the 5-Whys root cause analysis method. Ensures fixes include tests, documentation, and knowledge capture.
Generates structured documents including architecture diagrams (Mermaid), usage manuals, progress reports, and API documentation from code analysis.
Extracts reusable patterns and lessons from execution history and project experience. Generates structured knowledge entries for the knowledge base.
Evaluates project progress by analyzing workspace structure, code completeness, and comparing against planned milestones. Outputs structured progress reports.
| name | api-design |
| description | REST API design patterns. URL naming, HTTP status codes, pagination, RFC 7807 error responses, versioning, and OpenAPI. |
| trigger | when designing or implementing REST APIs, controllers, or endpoints |
| tags | ["api","rest","openapi","http","pagination"] |
| version | 2.0 |
| scope | platform |
| category | foundation |
/order-items/orders, /users/orders/{orderId}/itemsPOST /orders not POST /create-order| Method | Success | Use |
|---|---|---|
| GET | 200 OK | Retrieve resource(s) |
| POST | 201 Created + Location header | Create resource |
| PUT | 200 OK or 204 No Content | Full replace |
| PATCH | 200 OK | Partial update |
| DELETE | 204 No Content | Delete resource |
| Code | When |
|---|---|
| 400 | Malformed request syntax |
| 401 | Missing/invalid authentication |
| 403 | Authenticated but not authorized |
| 404 | Resource not found |
| 409 | Conflict (duplicate, state transition) |
| 422 | Valid syntax but semantic validation failed |
| 429 | Rate limit exceeded |
| 500 | Unexpected server error |
GET /orders?cursor=eyJpZCI6MTAwfQ&limit=20
{
"data": [...],
"pagination": {
"nextCursor": "eyJpZCI6MTIwfQ",
"hasMore": true,
"limit": 20
}
}
{
"type": "https://forge.example.com/errors/order-not-found",
"title": "ORDER_NOT_FOUND",
"status": 404,
"detail": "Order abc-123 not found",
"instance": "/orders/abc-123",
"correlationId": "req-xyz-789",
"timestamp": "2025-01-15T10:30:00Z"
}
/v1/orders, /v2/ordersWhen evolving APIs, compare old vs new OpenAPI specs to detect breaking changes.
| Change | Impact |
|---|---|
| Remove endpoint | Consumers get 404 |
| Remove required response field | Consumers missing expected data |
| Add required request field | Existing requests become invalid |
| Change field type (string → number) | Deserialization failures |
| Narrow enum values | Consumers sending removed values get errors |
| Change URL path | All consumers break |
| Change | Impact |
|---|---|
| Add optional request field | Backward-compatible |
| Add response field | Consumers ignore unknown fields |
| Add new endpoint | No impact on existing consumers |
| Widen enum values | Consumers may ignore new values |
| Add optional query parameter | Existing requests still work |
# Use openapi-diff or oasdiff to compare specs
oasdiff breaking old-api.yaml new-api.yaml
oasdiff changelog old-api.yaml new-api.yaml --format markdown
In code review, verify:
Sunset: <date>)When migrating systems between technology stacks (e.g., .NET → Java, Python → Kotlin), map source APIs to target APIs systematically.
| Source (.NET) | Target (Spring Boot) | Notes |
|---------------|---------------------|-------|
| `[HttpGet("api/orders/{id}")]` | `@GetMapping("/api/orders/{id}")` | Direct 1:1 |
| `[Authorize(Roles = "Admin")]` | `@PreAuthorize("hasRole('ADMIN')")` | Auth attribute mapping |
| `IActionResult` → `Ok(data)` | `ResponseEntity.ok(data)` | Return type mapping |
| `[FromQuery] string filter` | `@RequestParam filter: String` | Parameter binding |
| `[FromBody] CreateOrderDto` | `@RequestBody request: CreateOrderRequest` | Body binding |
| `[ProducesResponseType(404)]` | Swagger `@ApiResponse(responseCode = "404")` | Doc annotation |
| Concept | ASP.NET Core | Spring Boot | FastAPI | Go (gin) |
|---|---|---|---|---|
| Route definition | [Route("api/[controller]")] | @RequestMapping("/api/orders") | @app.get("/api/orders") | r.GET("/api/orders", handler) |
| Path parameter | {id} | {id} | {id} | :id |
| Query parameter | [FromQuery] | @RequestParam | Query() | c.Query("key") |
| Request body | [FromBody] | @RequestBody | Pydantic model param | c.ShouldBindJSON(&req) |
| Auth middleware | [Authorize] | @PreAuthorize | Depends(get_current_user) | authMiddleware() |
| Response type | IActionResult | ResponseEntity<T> | Response model | c.JSON(200, data) |
| Validation | [Required], FluentValidation | @Valid, @Validated | Pydantic validators | binding:"required" |
| DI | builder.Services.AddScoped<>() | Constructor injection | Depends() | Manual / wire |