Generate comprehensive OpenAPI 3.0 documentation from source code using the /generate-openapi Cursor Command.
Analyzes API source code repositories and creates:
- Complete OpenAPI 3.0 JSON schemas
- Embedded markdown overviews in
info.description - Lists of analyzed source files
.cursor/commands/generate-openapi.md- Executable instructions
.cursor/rules/project-structure.mdc- Project organization.cursor/rules/openapi-standards.mdc- VTEX OpenAPI standards.cursor/rules/api-patterns.mdc- Code pattern recognition
config.json- Central configuration with public VTEX APIscodebases[]- Array of APIs to document (only those withnamefilled)templates- OpenAPI template and overview template pathsexamples[]- Reference documentationoutput.generate-openapi-output- Output path templates
- Cursor IDE with the repository open
- Configuration:
config.jsonis pre-configured with 49 VTEX APIs - Repository Access: The command will automatically clone repositories from GitHub
By default, the command processes all codebases in config.json that have a name value:
/generate-openapi
The command will:
- Read
config.json - For each codebase with a non-empty
name:- Clone from
https://github.com/vtex/{codebase_name}.gitintoapi-repos/ - Analyze API code files
- Generate OpenAPI schema with embedded overview
- Save outputs in timestamped directory
- Clone from
ℹ️ This processes all ~49 configured VTEX APIs. For faster execution, use selective generation below.
You can limit generation to specific APIs by passing codebase names as parameters.
Single API:
/generate-openapi vcs.sku-binding
Multiple APIs (comma-separated):
/generate-openapi b2b-bulk-import, audience-manager
Some APIs are documented from multiple source repositories. The command automatically handles this:
Example: VTEX Ads API
-
Uses both
newtail-retail-media-api(campaign management) andnewtail-retail-media-adserver-api(ad serving) -
Both repositories are cloned and analyzed together
-
Single unified OpenAPI schema is generated combining endpoints from both
-
Configuration in
config.json:{ "repo": [ { "organization": "vtex", "codebase_name": "newtail-retail-media-api" }, { "organization": "vtex", "codebase_name": "newtail-retail-media-adserver-api" } ], "documentation": "VTEX - Ads API.json" }
ℹ️ Codebase names must exactly match the
namefield inconfig.json. Only codebases with non-emptynamevalues can be generated.
Files are saved in: generated-docs/{yyyy-mm-dd}-{model_name}-Cursor/{codebase_name}/
Example for session API on 2025-10-07 using Claude-4-Sonnet:
generated-docs/2025-10-07-Claude-4-Sonnet-Cursor/session/
├── session-api-code-files.json # List of analyzed source files
└── session-openapi.json # OpenAPI 3.0 schema with embedded overview
- Automatic Cloning: The command clones repositories automatically if they don't exist
- Single Backslash Escaping: Markdown in
info.descriptionuses\n, not\\n - No Separate Markdown File: Overview is embedded in the JSON, not saved separately
- Empty Names Skipped: APIs in
config.jsonwith emptynamefields are automatically skipped (no source code available)