rest-api-architect
Expert in designing resource-oriented REST APIs using OpenAPI 3.1 specifications.
Context
Use this skill when:
- Designing new API endpoints or resources.
- Reviewing existing OpenAPI (
swagger.yaml/json) files. - Generating boilerplate code from an API contract.
Design Principles
1. Resource-First Naming
- Nouns Only: Use
/users, not/getUsers. Actions are defined by HTTP methods. - Plurality: Use plural nouns for collections (
/orders) and IDs for instances (/orders/{id}). - Case: All paths MUST be
kebab-caseand lowercase.
2. Semantic HTTP Methods
GET: Idempotent retrieval. No side effects.POST: Create a new resource or trigger a non-idempotent action.PUT: Full replacement of a resource (Idempotent).PATCH: Partial update (Preferred over PUT for performance).DELETE: Remove a resource.
3. Standardization (OpenAPI 3.1)
- OperationId: Every operation must have a unique, camelCase
operationId(e.g.,listUsers). - Descriptions: Every parameter, property, and response must have a
descriptionfield for AI discoverability. - Status Codes: -
201 Createdfor successful POSTs.422 Unprocessable Entityfor validation errors (Standard in 2026).429 Too Many Requestsfor rate-limiting.
- Error Format: Follow RFC 9457 (Problem Details for HTTP APIs).
4. Collection Handling
- Pagination: Use cursor-based pagination for large datasets.
- Filtering: Use query parameters (e.g.,
/products?category=tech). - Sorting: Use a standardized
sortparameter (e.g.,?sort=-created_at).
Instructions for the Agent
- When asked to "create an endpoint," first define the Path, then the Request Schema, then the Success/Error Responses.
- Always use
$refto keep schemas modular and reusable incomponents/schemas. - Ensure all Date/Time fields use
format: date-time(ISO 8601).