A powerful tool that automatically generates Software Development Kits (SDKs) for multiple programming languages from OpenAPI 3.0 specifications.
- Multi-language Support: Generate SDKs for 8 programming languages
- OpenAPI 3.0 Compatible: Built on industry-standard OpenAPI specifications
- Template-based Generation: Customizable templates for each language
- Type Safety: Generates strongly-typed code with proper interfaces
- CLI Interface: Simple command-line tool for easy integration
- Java 17 or higher
- Gradle 7.0 or higher
To get the latest OpenAPI specification for Chargebee, you can download it from the Chargebee OpenAPI repository
To generate SDKs for Chargebee's official client libraries, you'll need to clone the respective repositories first, as the generator updates existing code structure rather than creating everything from scratch:
# Clone all Chargebee client library repositories
git clone https://github.com/chargebee/chargebee-php.git
git clone https://github.com/chargebee/chargebee-node.git
git clone https://github.com/chargebee/chargebee-python.git
git clone https://github.com/chargebee/chargebee-ruby.git
git clone https://github.com/chargebee/chargebee-java.git
git clone https://github.com/chargebee/chargebee-dotnet.git
git clone https://github.com/chargebee/chargebee-go.git
Note: The SDK generator updates existing repository structures rather than creating complete projects from scratch. Make sure to clone the target repositories before running the generation commands.
git clone https://github.com/chargebee/sdk-generator.git
cd sdk-generator
./gradlew build
./gradlew run --args="-i spec.json -l JAVA -o ./output"
# Generate a Java SDK
./gradlew run --args="-i chargebee_sdk_spec.json -l JAVA -o ../chargebee-java/src/main/java/com/chargebee"
# Generate Nodejs typings
./gradlew run --args="-i chargebee_sdk_spec.json -l TYPESCRIPT_TYPINGS_V3 -o ../chargebee-node/types/"
# Generate Python SDK
./gradlew run --args="-i chargebee_sdk_spec.json -l PYTHON_V3 -o ../chargebee-python/chargebee"
# Checkout or update all required SDK repositories to ../chargebee-sdks
# Also downloads the latest OpenAPI spec
docker compose run --rm sdk-generator setup
# Generate the SDK
docker compose run --rm sdk-generator generate <lang1> <lang2>
Option | Description | Required |
---|---|---|
-i, --input |
Path to OpenAPI specification file | β |
-l, --language |
Target language for SDK generation | β |
-o, --output |
Output directory path | β |
JAVA - Java SDK
TYPESCRIPT_TYPINGS_V3 - TypeScript type definitions (v3)
NODE_V3 - Node.js SDK (v3)
PYTHON_V3 - Python SDK (v3)
PHP_V4 - PHP SDK (v4)
RUBY - Ruby SDK
DOTNET - .NET SDK
GO - Go SDK
NODE - Node.js SDK (legacy)
PYTHON - Python SDK (legacy)
PHP - PHP SDK (legacy)
src/
βββ main/
β βββ java/com/chargebee/
β β βββ openapi/ # OpenAPI parsing and processing
β β βββ sdk/ # Language-specific generators
β β βββ Main.java # CLI entry point
β βββ resources/
β βββ templates/ # Language-specific templates
β βββ java/
β βββ php/
β βββ python/
β βββ ...
βββ test/ # Unit tests
The generator uses Handlebars templates located in src/main/resources/templates/
. You can customize the generated code by modifying these templates:
java/
- Java SDK templatests/
- TypeScript templatespython/
- Python SDK templatesphp/
- PHP SDK templates- And more...
The generator supports custom OpenAPI extensions for enhanced functionality:
# Example OpenAPI spec with custom extensions
components:
schemas:
User:
type: object
properties:
id:
type: string
x-is-dependent-attribute: true
email:
type: string
x-is-multi-attribute: false
This SDK generator uses custom OpenAPI extension parameters (prefixed with x-cb-
) to enhance code generation capabilities. These extensions provide additional metadata for:
- Operation behavior control (list operations, bulk operations, idempotency)
- Parameter filtering and ordering
- Resource relationships and sub-resources
- Special data type handling (money fields, custom fields)
- URL construction and routing
For a complete list and detailed descriptions of all supported extensions, see X-CB Extensions Documentation.
x-cb-operation-method-name
: Defines SDK method namesx-cb-operation-is-list
: Marks list operations for special handlingx-cb-is-filter-parameter
: Enables filter parameter generationx-cb-resource-id
: Links operations to resource modelsx-cb-is-money-column
: Special handling for monetary values
Run the test suite:
# Run all tests
./gradlew test
# Run tests with coverage
./gradlew test jacocoTestReport
View coverage report at build/jacocoHtml/index.html
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Add tests for new functionality
- Run tests:
./gradlew test
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow Java naming conventions
- Use meaningful variable and method names
- Add JavaDoc comments for public APIs
- Ensure all tests pass before submitting
# Generate SDKs using latest versions
./gradlew run --args="-i chargebee_sdk_spec.json -l JAVA -o ../chargebee-java/src/main/java/com/chargebee"
./gradlew run --args="-i chargebee_sdk_spec.json -l PHP_V4 -o ../chargebee-php/src"
./gradlew run --args="-i chargebee_sdk_spec.json -l PYTHON_V3 -o ../chargebee-python/chargebee"
./gradlew run --args="-i chargebee_sdk_spec.json -l TYPESCRIPT_TYPINGS_V3 -o ../chargebee-node/types/"
./gradlew run --args="-i chargebee_sdk_spec.json -l NODE_V3 -o ../chargebee-node/src/resources"
# Generate SDKs using legacy versions (not recommended for new projects)
./gradlew run --args="-i chargebee_sdk_spec.json -l PYTHON -o ./python-legacy-sdk"
./gradlew run --args="-i chargebee_sdk_spec.json -l NODE -o ./node-legacy-sdk"
./gradlew run --args="-i chargebee_sdk_spec.json -l PHP -o ./php-legacy-sdk"
Generate SDKs for all supported languages targeting Chargebee's official client library repositories:
Prerequisites: Clone all Chargebee client repositories before running these commands.
# Generate current versions of SDKs
./gradlew run --args="-i chargebee_sdk_spec.json -l PHP_V4 -o ../chargebee-php/src" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l NODE_V3 -o ../chargebee-node/src/resources" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l PYTHON_V3 -o ../chargebee-python/chargebee" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l RUBY -o ../chargebee-ruby/lib/chargebee" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l TYPESCRIPT_TYPINGS_V3 -o ../chargebee-node/types/" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l JAVA -o ../chargebee-java/src/main/java/com/chargebee" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l DOTNET -o ../chargebee-dotnet/ChargeBee" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l GO -o ../chargebee-go" &&
echo "Current SDK versions generated successfully."
# Generate legacy versions of SDKs
./gradlew run --args="-i chargebee_sdk_spec.json -l PHP -o ../chargebee-php/lib" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l NODE -o ../chargebee-node/lib/resources" &&
./gradlew run --args="-i chargebee_sdk_spec.json -l PYTHON -o ../chargebee-python/chargebee" &&
echo "Legacy SDK versions generated successfully."
After generating the Node.js SDK (NODE_V3), run the following command in the SDK output directory to format the code:
npx prettier --write .
After generating the Python SDK (PYTHON_V3), run the following command in the SDK output directory to format the code:
black .
After generating the GO SDK, run the following command in the SDK output directory to format the code:
gofmt -w .
The above commands assume the following repository structure with cloned Chargebee repositories:
parent-directory/
βββ sdk-generator/ # This repository
βββ cb-openapi-generator/ # OpenAPI specifications
βββ chargebee-php/ # https://github.com/chargebee/chargebee-php
βββ chargebee-node/ # https://github.com/chargebee/chargebee-node
βββ chargebee-python/ # https://github.com/chargebee/chargebee-python
βββ chargebee-ruby/ # https://github.com/chargebee/chargebee-ruby
βββ chargebee-java/ # https://github.com/chargebee/chargebee-java
βββ chargebee-dotnet/ # https://github.com/chargebee/chargebee-dotnet
βββ chargebee-go/ # https://github.com/chargebee/chargebee-go
Important: The generator updates existing code within these repositories. Ensure you have the latest version of each repository before generating SDKs.
If you find any bugs or have any questions / feedback, open an issue in this repository or reach out to us on [email protected]
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with OpenAPI Generator concepts
- Uses Swagger Parser for OpenAPI parsing
- Template engine powered by Handlebars.java
Made with β€οΈ by chargebee