openapi-generator
Skill: openapi-generator
Purpose
Generate a complete OpenAPI contract that becomes the single API source of truth for:
- backend implementation
- frontend integration
- reviewer validation
- debugger fixes
OpenAPI Version Rule
Always generate:
openapi: 3.0.3
No other version unless explicitly required.
Input Assumption
Input is a structured module plan containing:
- module name
- features
- entities
- business rules
- API list
- DB notes
- backend/frontend task expectations
The skill must convert that planning output into:
- tags
- paths
- request schemas
- response schemas
- wrapper schemas
- pagination schemas
- error schemas
Single Source of Truth Rule
openapi.yaml is the API source of truth.
Downstream systems must follow it exactly.
The skill must not:
- invent major business behavior not implied by planner
- create random unrelated endpoints
- drift from module intent
Path Rules
Use RESTful naming:
- plural resources
- stable path params
- clear hierarchy
Examples:
/api/users/api/users/{id}
Use path params such as:
{id}{slug}
Method Rules
GET-> read/listPOST-> createPUT-> full updatePATCH-> partial/status updateDELETE-> soft delete semantics unless clearly stated otherwise
Tag Rules
Use consistent module-based tagging.
Preferred pattern:
<module_name>-admin<module_name>-storefront
Tags should reflect actual business access separation.
Request Schema Rules
Request schema naming:
CreateXRequestUpdateXRequest
Requests should:
- reflect planner business rules
- define required fields
- be reusable when practical
- avoid excessive inline schema duplication
Response Schema Rules
Response naming:
XResponse
Responses should:
- represent business response payloads
- avoid persistence/internal leakage
- stay reusable
Standard Success Wrapper Rule
All successful responses must use this shape:
{
"code": 0,
"message": "success",
"data": {}
}
This is mandatory.
The skill must model this wrapper clearly and consistently.
Pagination Rule
Paginated list endpoints must use:
{
"code": 0,
"message": "success",
"data": {
"content": [],
"page": 1,
"size": 10,
"total": 100
}
}
Important:
- the pagination object is the value of
data - never generate raw top-level paginated success responses without wrapper
Field Rules
Common field patterns:
id-> integer/int64created_at-> string/date-timeupdated_at-> string/date-timestatus-> enum where planner implies itprice-> number/decimal-like schema representation
Do not expose deleted_at unless explicitly required.
Business Rule Mapping
Map planner business rules into OpenAPI:
- required -> required array
- enum/status -> enum values
- unique -> description note
- auth restriction -> security requirements or endpoint description
- soft delete -> delete semantics and normal list exclusion assumptions
Error Response Rules
At minimum define consistent error responses for:
- 400
- 401
- 403
- 404
Keep them structured and reusable.
Security Rules
Where auth is relevant:
- define bearer auth scheme
- apply security requirements on protected endpoints
- distinguish public/storefront/admin behavior clearly
Merge Rules
If an existing openapi.yaml exists:
- merge new paths
- merge new schemas
- preserve unrelated modules
- do not silently remove existing content
Validation Checklist
Before finalizing:
- no missing schema refs
- no duplicate schema names
- all paths have responses
- wrapper contract is consistent
- pagination is correctly nested inside
data - YAML is valid
- contract is merge-safe
Forbidden Patterns
- missing request schema
- response payloads without wrapper
- raw top-level paginated success response
- random inline schema duplication everywhere
- mixing unrelated module tags carelessly
Final Goal
The final OpenAPI document must be:
- valid
- reusable
- merge-safe
- contract-first
- ready for backend and frontend generation
