Openapi generator
Generate and sync OpenAPI (REST) and AsyncAPI (WebSocket) documentation for projects. This skill should be used when the user asks to generate API docs, create OpenAPI specs, update/sync existing API documentation, or write asyncapi specs. Currently supports Rust web frameworks (Axum, Actix-web, Rocket, Poem). Triggers on keywords like "openapi", "swagger", "api docs", "API documentation", "asyncapi".From its SKILL.md
npx -y skills add chareice/claude-skills --skill openapi-generatorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.8 KB, as published. Nobody here has run it
OpenAPI / AsyncAPI Generator
Generate split-file OpenAPI 3.0.3 specs for REST endpoints and AsyncAPI 3.0.0 specs for WebSocket message formats by scanning project source code.
Mode Detection
Determine the mode based on user request and project state:
- Generate mode: No
openapi/directory exists in the project, or user explicitly asks to create/generate docs - Sync mode: An
openapi/directory already exists, and user asks to update/sync/refresh docs
Generate Mode
Step 1: Identify Framework
Read Cargo.toml to detect the web framework. Refer to references/rust-framework-patterns.md for the dependency-to-framework mapping.
If poem-openapi is detected, warn the user that Poem has built-in OpenAPI generation and ask whether to proceed with manual spec creation.
Step 2: Scan Routes
Locate route definitions based on framework patterns documented in references/rust-framework-patterns.md.
For each route, extract:
- HTTP method (GET, POST, PUT, DELETE, PATCH)
- URL path (including path parameters like
/:idor/<id>) - Handler function name and location
Build a route inventory as a working list before proceeding.
Step 3: Scan Types
For each handler function found in Step 2, trace the request and response types:
- Read the handler function signature
- Identify extractor types (
Query<T>,Json<T>,Path<T>, etc.) - Follow each
Tto its struct/enum definition - Read the struct fields, noting
serdeattributes (rename,skip_serializing_if,default,flatten,tag) - Map Rust types to OpenAPI types using the mapping table in
references/rust-framework-patterns.md
Skip internal types (State<T>, Extension<T>, middleware extractors).
Step 4: Detect Response Pattern
Check whether the project uses a unified response wrapper:
- Search for generic response structs like
ApiResponse<T>,Response<T>,AppResult<T> - If found, extract it as a common schema in
components/schemas/common/ - If not found, document each endpoint's response type individually
Step 5: Detect WebSocket Endpoints
Search for WebSocket-related patterns:
- Axum:
WebSocketUpgradeextractor,ws.on_upgrade() - Actix-web:
actix_web_actors::ws,StreamHandler<ws::Message> - Rocket:
ws::WebSockettype
For each WebSocket endpoint:
- Find the message types used with
serde_json::from_str/serde_json::to_string - Trace to the enum/struct definitions
- Note the serde tag representation (internally tagged, adjacently tagged, untagged, externally tagged)
Step 6: Create Directory Structure
Copy the template from this skill's assets/openapi-template/ to the project's openapi/ directory, then customize:
- Update
openapi.yamlwith project title and description (read fromCargo.toml[package]section) - Create domain folders based on route path prefixes
- If the project has a unified error response, update
components/schemas/common/ErrorResponse.yamlto match
Step 7: Generate Schema Files
For each unique request/response type:
- Create a YAML file in
openapi/domains/{domain}/schemas/{TypeName}.yaml - Map struct fields to OpenAPI properties
- Set
requiredarray based on which fields are notOption<T> - Handle nested types by creating separate schema files and using
$ref - For enums, use
enumfor simple variants oroneOffor complex variants
Step 8: Generate Path Files
For each route:
- Create a YAML file in
openapi/domains/{domain}/paths/{endpoint-name}.yaml - Include: summary, description, tags, parameters, request body (if POST/PUT/PATCH), responses
- Reference schema files via
$ref - Add at least one response example with realistic data
- Follow conventions in
references/openapi-conventions.md
Step 9: Generate AsyncAPI (if WebSocket found)
If WebSocket endpoints were found in Step 5:
- Create
openapi/asyncapi.yamlwith channel and operation definitions - Create message schema files in
openapi/domains/{domain}/schemas/(shared with OpenAPI schemas) - Map serde-tagged enums to
oneOfwithdiscriminatoras documented inreferences/rust-framework-patterns.md - Define both
send(client-to-server) andreceive(server-to-client) operations
Step 10: Register in Entry Files
Update openapi/openapi.yaml:
- Add all schema
$refentries undercomponents.schemas - Add all path
$refentries underpaths - Add security schemes if authentication is detected
If asyncapi.yaml was created, register all message schemas in its components section.
Step 11: Validate
- Verify all
$refpaths resolve to existing files - Check that every route found in Step 2 has a corresponding path file
- Confirm response examples match schema structure
- If Redocly is available in the project (
@redocly/cliin dependencies), runpnpm redocly lint openapi/openapi.yaml
Sync Mode
Step 1: Load Existing Spec
Read the existing openapi/openapi.yaml to build a list of currently documented endpoints and schemas.
Step 2: Scan Current Code
Follow Generate Mode Steps 1-5 to build the current route and type inventory from source code.
Step 3: Diff
Compare documented vs actual endpoints:
| Status | Condition |
|---|---|
| New | Route exists in code but not in spec |
| Removed | Route exists in spec but not in code |
| Modified | Route exists in both but types differ (new/removed fields, type changes) |
| Unchanged | Route and types match |
Step 4: Report
Present the diff to the user in a clear table format before making changes. Include:
- New endpoints to add
- Removed endpoints to delete
- Modified endpoints with specific field-level changes
- Unchanged endpoints (count only)
Step 5: Apply
After user confirmation:
- For new endpoints: follow Generate Mode Steps 7-10
- For removed endpoints: delete the path and orphaned schema files, remove entries from
openapi.yaml - For modified endpoints: update the affected schema and path files in place
References
references/rust-framework-patterns.md— Framework detection, route scanning patterns, type mapping, WebSocket identification, serde tag handlingreferences/openapi-conventions.md— Directory structure, file templates, naming conventions, AsyncAPI format, bundling tools, validation checklist
Assets
assets/openapi-template/— Minimal starter template foropenapi/directory initialization