You are an API documentation specialist. Generate OpenAPI 3.1 specifications and interactive documentation.
Generates OpenAPI 3.1 specifications and interactive API documentation from code.
/plugin marketplace add Data-Wise/craft/plugin install data-wise-craft@Data-Wise/craftdocs/You are an API documentation specialist. Generate OpenAPI 3.1 specifications and interactive documentation.
Generate and maintain API documentation:
Analyze project and suggest API documentation approach:
š API DOCUMENTATION GENERATOR
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Detected:
⢠Framework: FastAPI
⢠Existing spec: None
⢠Endpoints: 15 detected
Options:
1. [generate] Generate OpenAPI spec from code
2. [interactive] Set up Swagger UI
3. [sdk] Generate client SDKs
4. [validate] Validate existing spec
5. [update] Update spec from code changes
Or specify: /craft:docs:api <option> [--output path]
/craft:docs:api # Analyze and suggest
/craft:docs:api generate # Generate spec from code
/craft:docs:api --interactive # Set up Swagger UI
/craft:docs:api --output openapi.yaml # Custom output path
/craft:docs:api validate # Validate existing spec
/craft:docs:api sdk python # Generate Python SDK
# Check for API frameworks
grep -r "FastAPI\|Flask\|Express\|Gin\|plumber" --include="*.py" --include="*.js" --include="*.go" --include="*.R" .
cat pyproject.toml 2>/dev/null | grep -E "fastapi|flask|django"
cat package.json 2>/dev/null | grep -E "express|fastify|hono"
Supported Frameworks:
| Framework | Language | Auto-detect |
|---|---|---|
| FastAPI | Python | ā Built-in OpenAPI |
| Flask | Python | Via flask-smorest |
| Express | Node.js | Via swagger-jsdoc |
| Hono | Node.js | Via @hono/swagger |
| Gin | Go | Via swaggo |
| plumber | R | Via annotations |
For FastAPI (auto-generation):
# FastAPI generates OpenAPI automatically
# Export with:
import json
from app import app
print(json.dumps(app.openapi(), indent=2))
For other frameworks - use api-documenter agent:
openapi: 3.1.0
info:
title: Project API
description: |
API documentation generated by craft.
## Authentication
[Describe auth methods]
## Rate Limiting
[Describe limits]
version: 1.0.0
contact:
name: API Support
email: support@example.com
servers:
- url: https://api.example.com/v1
description: Production
- url: http://localhost:8000
description: Development
paths:
/endpoint:
get:
summary: Description
...
š SWAGGER UI SETUP
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Options for interactive documentation:
1. Swagger UI (classic, most compatible)
2. Redoc (clean, modern design)
3. Stoplight Elements (full-featured)
4. RapiDoc (customizable)
Select option (1-4) or skip:
For Swagger UI:
# Static hosting
npx @stoplight/prism-cli mock openapi.yaml
# Or add to project
npm install swagger-ui-dist
š OPENAPI VALIDATION
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Running Spectral linting...
Results:
ā
Valid OpenAPI 3.1 structure
ā
All paths have operationId
ā ļø Missing description on GET /users
ā ļø No example for UserResponse schema
ā Security scheme 'bearerAuth' referenced but not defined
Errors: 1
Warnings: 2
Info: 0
Fix issues? (y/n)
ā
API DOCUMENTATION GENERATED
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Files created:
š openapi.yaml (450 lines)
š docs/api/index.md (reference)
Specification:
⢠OpenAPI version: 3.1.0
⢠Endpoints: 15
⢠Schemas: 8
⢠Security schemes: 2
Optional setup:
⢠Swagger UI: npx @stoplight/prism-cli mock openapi.yaml
⢠Redoc: npx @redocly/cli preview-docs openapi.yaml
Next steps:
1. Review: cat openapi.yaml
2. Test: npx @stoplight/prism-cli mock openapi.yaml
3. Commit: git add openapi.yaml && git commit -m "docs: add OpenAPI specification"
When sdk option selected:
š§ SDK GENERATION
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
Select target language(s):
[x] Python (openapi-generator)
[ ] TypeScript (openapi-typescript)
[ ] Go (oapi-codegen)
[ ] Ruby (openapi-generator)
[ ] Java (openapi-generator)
Output directory: ./generated/
Generate? (y/n)
# Generated commands
openapi-generator-cli generate \
-i openapi.yaml \
-g python \
-o ./generated/python-client \
--additional-properties=packageName=api_client
Uses agents:
api-documenter - OpenAPI generation and enhancementUses skills:
openapi-spec-generation - Spec patterns and validationWorks with:
/craft:docs:generate - Part of full documentation/craft:docs:validate - Validate generated spec/craft:code:deps-audit - Check API dependencies