Documentation generator for the Carta Issuer API OpenAPI specification.
This project provides tools to generate comprehensive, human-readable documentation from the Carta Issuer API OpenAPI 3.0 specification. The documentation includes:
- Detailed schema descriptions with examples
- Property tables with types, descriptions, and validation constraints
- Enum value listings
- Cross-referenced links between related schemas
- Automatic categorization of objects vs. types
Run the Python documentation generator:
python generate_docs.pyThis runs a two-stage pipeline:
- Stage 1: Compose schemas from
carta-issuer-api.openapi.json→build/composed-schemas/ - Stage 2: Generate markdown from composed schemas →
docs/objects/anddocs/types/ - Update the index in
docs/README.md
You can also run stages independently:
python generate_docs.py --stage1 # Run only composition
python generate_docs.py --stage2 # Run only markdown generationAfter generation, browse the documentation starting at docs/README.md.
Main documentation generator - Uses a two-stage architecture to convert OpenAPI schemas to markdown.
Architecture:
Stage 1: Schema Composition (schema_composer.py)
- Reads
carta-issuer-api.openapi.json - Extracts and enriches schemas with metadata
- Classifies schemas as "objects" (with endpoints) or "types"
- Builds cross-reference graph
- Writes composed schemas to
build/composed-schemas/
Stage 2: Markdown Generation (markdown_generator.py)
- Reads composed schemas from
build/composed-schemas/ - Generates markdown documentation
- Writes to
docs/objects/anddocs/types/ - Creates index in
docs/README.md
Features:
- ✅ Enum value rendering (30 enum schemas)
- ✅ Example data display (64 schemas with examples)
- ✅ Validation constraints (pattern, format, min/max)
- ✅ Title fallback for missing descriptions
- ✅ Automatic cross-linking between schemas
- ✅ Intermediate schema output for debugging
- ✅ Independent stage execution
Output Structure:
build/
└── composed-schemas/ # Stage 1 output (intermediate)
├── _index.json # Schema index
├── corporation.json # Composed schema with metadata
└── ...
docs/
├── README.md # Auto-generated index
├── objects/ # Primary API resources (with endpoints)
│ ├── corporation.md
│ ├── option_grant.md
│ └── ...
└── types/ # Supporting types
├── date.md
├── decimal.md
└── ...
Located in ocf_examples/generate-docs/, this is a reference implementation of the two-stage pattern for OCF schemas (provided as an example, not used for Carta API spec).
cd ocf_examples/generate-docs
npx tsx index-two-stage.ts/
├── carta-issuer-api.openapi.json # OpenAPI 3.0 specification
├── generate_docs.py # Main orchestrator (two-stage pipeline)
├── schema_composer.py # Stage 1: Schema composition
├── markdown_generator.py # Stage 2: Markdown generation
├── schemas/ # Individual schema definitions (reference)
│ ├── GET/ # Response schemas
│ └── POST/ # Request body schemas
├── build/ # Generated intermediate files
│ └── composed-schemas/ # Stage 1 output (enriched schemas)
├── docs/ # Generated documentation
│ ├── README.md # Auto-generated index
│ ├── objects/ # Primary API objects
│ └── types/ # Supporting types
└── ocf_examples/ # Reference implementation (two-stage pattern)
└── generate-docs/ # TypeScript two-stage generator
The Carta Issuer API provides endpoints for:
- Corporations - Manage corporation information
- Compensation Benchmarks - Access compensation benchmark data
- Securities - Manage certificates, option grants, convertible notes, RSUs, RSAs
- Draft Securities - Work with draft securities before finalization
- Capitalization Table - Retrieve cap table data
- Securities Templates - Manage templates for creating securities
- Issuers - Manage issuer information
- Interests - Manage interests for an issuer
Authentication: OAuth 2.0 (scopes listed in each endpoint)
- Python 3.7+ (for
generate_docs.py) - Node.js 18+ (for TypeScript tools, optional)
-
Make changes to the generator:
# Edit schema_composer.py for Stage 1 changes # Edit markdown_generator.py for Stage 2 changes # Edit generate_docs.py for orchestration changes
-
Test your changes:
# Clean existing outputs rm -rf build docs/objects docs/types # Regenerate (both stages) python generate_docs.py # Or test stages independently python generate_docs.py --stage1 # Test composition only python generate_docs.py --stage2 # Test markdown only # Inspect intermediate output cat build/composed-schemas/_index.json # Check schema index cat build/composed-schemas/decimal.json # Check composed schema # Verify final output cat docs/types/stakeholder_entity_type.md # Check enum rendering cat docs/types/decimal.md # Check constraints cat docs/objects/option_grant.md # Check examples
-
Verify generated documentation:
- Check that all links work correctly
- Verify enum values are displayed
- Confirm examples are properly formatted
- Ensure constraints are shown (pattern, format, min/max)
Two-Stage Architecture:
The generator is split into two independent stages for modularity and debuggability:
Stage 1: schema_composer.py
- Reads OpenAPI spec and produces enriched schema objects
- Key classes:
SchemaComposer- Main composition orchestratorComposedSchema- Data class for enriched schemas
- Outputs: JSON files in
build/composed-schemas/
Stage 2: markdown_generator.py
- Reads composed schemas and generates markdown
- Key classes:
MarkdownGenerator- Markdown generation orchestrator
- Outputs: Markdown files in
docs/objects/anddocs/types/
When making changes:
- Maintain separation between stages - Stage 2 should only depend on Stage 1 output
- Preserve the
ComposedSchemadata structure contract - Keep cross-reference links working (relative paths)
- Maintain required field marking, property sorting, constraint display
- Test both stages independently after changes
When making changes, test against these schema patterns:
# Enum schemas
python -c "import json; spec = json.load(open('carta-issuer-api.openapi.json'));
print([k for k,v in spec['components']['schemas'].items() if 'enum' in v][:3])"
# Schemas with examples
python -c "import json; spec = json.load(open('carta-issuer-api.openapi.json'));
print([k for k,v in spec['components']['schemas'].items() if 'example' in v][:3])"
# Properties with constraints
python -c "import json; spec = json.load(open('carta-issuer-api.openapi.json'));
[print(f'{k}.{p}') for k,v in spec['components']['schemas'].items()
if 'properties' in v for p,pv in v['properties'].items()
if 'pattern' in pv or 'format' in pv][:5]"If you update carta-issuer-api.openapi.json:
-
Validate the OpenAPI spec:
# Use Swagger Editor or similar tool # https://editor.swagger.io/
-
Regenerate documentation:
python generate_docs.py
-
Review the diff in
docs/to ensure changes are correct
- Ensure documentation generates without errors
- Verify sample output files look correct
- Update
CLAUDE.mdif you change the architecture - Include before/after examples in your PR description
CLAUDE.md- Detailed architecture guide for AI assistantsdocs/README.md- Auto-generated schema index
Contact Carta - Developer Ecosystem Team (developers@carta.com)
For API-related questions, contact: developers@carta.com