- Official Extension
-
-
Maintainer: ApostropheCMS (opens in new tab) - Last updated 7 months ago
- v1.0.0
-
-
- Open Source
README (opens in new tab)
Automatically generate professional API documentation and client SDKs for your ApostropheCMS project. Discover all routesโincluding Pro module endpointsโand create comprehensive OpenAPI 3.1 specs with zero configuration.
Table of Contents
- Why ApostropheCMS OpenAPI Generator?
- Requirements
- Installation
- Quick Start
- How It Works
- Commands & Usage
- Client SDK Generation
- Authentication
- Configuration
- Development Workflow
- Contributing
- Community & Support
Why ApostropheCMS OpenAPI Generator?
- ๐ฏ Your Complete API: Documents YOUR content types, custom pieces, and routesโnot just core CMS
- ๐ Zero Configuration: Works instantly with any ApostropheCMS 4+ project
- ๐ Total Discovery: Automatically finds all routes, schemas, and Pro module endpoints
- ๐ฑ Production-Ready SDKs: Generate enterprise-grade clients in TypeScript, Python, PHP, and 20+ other languages
- โก Live Documentation: Interactive testing environment for your specific API endpoints
- ๐ ๏ธ DevOps Ready: Built for modern development workflows and CI/CD pipelines
- ๐ง Extensible: Custom field mappers and route filtering for project-specific needs
Requirements
- ApostropheCMS 4.0 or higher
- Node.js 22+
- For SDK generation:
- Java 8+ (required for npx or global usage)
- Optional: global installation of
@openapitools/openapi-generator-clifor faster repeat runs (usesnpxby default) - Optional: Docker (if you prefer not to install Java). The generator will use the official
openapitools/openapi-generator-cliimage, which is pulled automatically the first time you run it.
Installation
Quick Start
- Add to your ApostropheCMS project:
Configure the module in your
app.jsfile:
- Generate your OpenAPI spec:
- View interactive documentation:
- Generate a client SDK:
- Use your generated SDK:
How It Works
The generator uses a three-step process:
- Route Discovery: Scans ApostropheCMS's route registry to find all registered endpoints
- Schema Discovery: Examines module schemas to understand your content types
- Intelligent Merging: Combines discoveries with a comprehensive base specification
What Gets Discovered
Routes:
- All core ApostropheCMS API endpoints
- ApostropheCMS Pro module endpoints
- Your custom piece type endpoints
- Custom routes added via ApostropheCMS route methods (e.g.
restApiRoutes(self))
Schemas:
- Built-in piece types (User, Image, File, etc.)
- Your custom piece types
- Extended modules with additional fields
- Widget schemas and field definitions
Base Specification
The generator includes a comprehensive base specification with:
- Core API documentation
- Complete field type definitions for all ApostropheCMS fields
- Standard error responses and authentication schemes
- Security configurations for all endpoints
- Organized tag groups and parameter definitions
Your discovered content extends this base rather than replacing it.
Output Structure
Generated specs include:
- Complete route coverage: Every endpoint in your project
- Semantic operation IDs:
listArticles,getUser,createImage - Logical grouping: Operations grouped by resource type
- Rich schemas: Full property definitions with validation
- Standard responses: Consistent error handling and success responses
Commands & Usage
| Command | Description | Key Options |
|---|---|---|
generate |
Generate OpenAPI specification | --output=FILE, --dry-run, --routes-only, --schemas-only, --verbose |
validate |
Validate OpenAPI specification | --spec=FILE |
docs |
Serve interactive documentation | --open |
generateSDK |
Generate client SDKs | <language>, --output=DIR, --props=PROPS, --config=FILE |
Basic Generation
Development & Testing
File Validation
Once you have an OpenAPI file on disk, you can use the validate task to confirm that it is still a valid OpenAPI 3.1 specification.
This command does not regenerate or modify your spec โ it only runs validation against an existing file, which is useful when:
- You manually edited the generated spec (e.g., added custom descriptions or examples).
- You renamed/moved the spec file and want to be sure itโs still valid before publishing it to Postman, Redoc, or other tooling.
- You want a quick check in CI to fail the build if someone introduces an invalid change.
Documentation
Client SDK Generation
Generate type-safe client libraries in multiple languages for easy API integration.
Supported Languages
The generator supports 20+ languages, with these three built into the CLI for common use cases:
- TypeScript: Universal for modern web frontends and Node.js backends
- Python: Dominant in data science, automation, and content migration workflowsโessential for ETL processes and AI-powered content applications
- PHP: The web's most widely-used server-side language, powering 77% of websitesโcritical for existing LAMP stack integrations and legacy system migrations
SDK Requirements
The generateSDK task automatically uses npx, so in most cases you don't need to install anything extra.
All you need is Java 8+ available on your system.
The generator tries multiple approaches in order of convenience:
NPX (default)
- Runs
npx @openapitools/openapi-generator-cliautomatically - Downloads the generator each time you use it
- Works out of the box with Java 8+ installed
Global install (optional) โ faster repeat runs
Docker (optional) โ no Java required
- Uses the official
openapitools/openapi-generator-cliDocker image - Great if you prefer not to install Java locally
- Requires Docker installed and running
Check your Java installation (needed for npx or global):
If not installed, get OpenJDK 8+ from your package manager or OpenJDK.
Quick SDK Generation
Advanced SDK Options
Use any OpenAPI Generator language:
What's Included in Generated SDKs
Every generated SDK comes with comprehensive documentation and features:
Rich Documentation:
- Complete API documentation in the
docs/folder - Comprehensive README with examples for every endpoint
- Language-appropriate type safety (full TypeScript definitions, Python type hints, strongly-typed clients for Go/Rust/Java)
- Authentication helpers and error handling examples
Client Features by Language:
TypeScript / JavaScript:
- Modern
async/awaitwith Axios HTTP client - Full TypeScript definitions with IntelliSense support
- Works in both Node.js and browser environments
- Tree-shakable imports for optimal bundle size
Python:
- Standard Python package with pip compatibility
- Type hints for better IDE support (where applicable)
- Perfect for data migration scripts and ETL processes
- Excellent for AI/ML applications working with your content
PHP:
- Composer-friendly package structure
- Basic type annotations and IDE autocomplete
- Great for WordPress โ ApostropheCMS migration scripts
- Server-rendered applications and legacy system integration
Using Your Generated SDK
- Copy to your project:
- Install and build:
- Use in your application:
TypeScript/JavaScript Example: TypeScript/JavaScript Example:
Python Example:
PHP Example:
Authentication
The generated SDKs support all ApostropheCMS authentication methods:
API Keys
Bearer Tokens
Session-based Authentication
For browser-based applications, you can use standard session cookies alongside the API:
Authentication Priority:
- API key (query string): pass
apiKeyintoConfiguration({ apiKey: 'โฆ' }) - Bearer token: pass
accessTokenintoConfiguration({ accessToken: 'โฆ' }) - Session/cookie: enable
withCredentialsand run in an environment that includes the session cookie
Security
All generated endpoints include appropriate security schemes:
This provides multiple authentication options while maintaining compatibility with the ApostropheCMS authentication systems.
Configuration
The generator works without configuration, but you can customize its behavior:
Route Exclusion
Use openapiRoutes.exclude to filter out individual routes or entire resources:
Filtering Logic:
- Partial matches:
'debug'excludes/api/v1/user/debug-stats - Specific routes:
'article/publish'excludes onlyPOST /api/v1/article/{id}/publish - Entire resources:
'internal'excludes all internal endpoints
Custom Field Mappers
Define how custom field types should appear in the OpenAPI schema:
Development Workflow
1. During Development
2. Frontend Integration
3. CI/CD Integration
4. API Testing & Validation
Contributing
We welcome contributions to improve the generator:
- Fork the repository and create a feature branch
- Make your changes and add tests
- Run tests to ensure everything works
- Submit a pull request with a clear description
Please ensure all changes:
- Follow existing code patterns
- Include appropriate tests
- Update documentation if needed
- Work with the latest ApostropheCMS version
Community & Support
- Discord Community - Get help from other developers
- GitHub Issues - Report bugs or request features
- Documentation - Comprehensive guides and API reference
- Professional Support - Enterprise support and consulting
๐ Ready for Enterprise Features?
Need advanced API capabilities for your development workflow? This free OpenAPI generator works great with ApostropheCMS Pro extensions to document enterprise-grade endpoints:
๐ ApostropheCMS Pro Features
- ๐ค SEO Assistant - AI-powered content optimization with dedicated API endpoints
- ๐ Document Versions - Complete revision management and rollback APIs
- ๐ Advanced Permissions - Granular access control with user group management
- ๐ Automatic Translation - Instant multilingual content generation with AI-powered translations
Create an account on Apostrophe Workspaces and upgrade to ApostropheCMS Pro or contact our team to learn more about ApostropheCMS Pro licensing and unlock enterprise-grade API endpoints that will enhance your documentation and development capabilities.
Made with โค๏ธ by the ApostropheCMS team. Found this useful? Give us a star on GitHub! โญ