A simple tool for generating client libraries from OpenAPI schemas
Project description
Crucible
Crucible is a CLI tool for generating and updating SDKs from OpenAPI specifications. It automates the creation of SDKs and ensures they remain up-to-date with the latest API changes.
Features
- Generate a new SDK project with a predefined structure.
- Update the SDK codebase based on the latest OpenAPI specification.
- Supports automatic updates via GitHub Actions.
- Manages dependencies and packaging using Poetry.
Installation
To install Crucible, you can use pipx:
Usage
pipx install crucible
Create a New SDK Project
To create a new SDK project:
crucible create_project my_sdk_project
This command will generate a new project with the following structure:
my_sdk_project/
├── causadb/
│ ├── __init__.py
│ ├── ...
├── tests/
│ ├── __init__.py
│ ├── test_example.py
├── pyproject.toml
├── README.md
├── setup.cfg
└── LICENSE
Update the SDK Codebase
To update the SDK codebase based on the latest OpenAPI specification:
crucible update_sdk crucible.yaml openapi.yaml causadb
This command will regenerate the code in the causadb/ directory while keeping other files like README, version, and tests persistent.
Integration with GitHub Actions
You can automate the update process by integrating Crucible with GitHub Actions. Create a workflow file .github/workflows/generate_sdk.yml:
name: Generate SDK
on:
push:
paths:
- openapi.yaml
jobs:
generate-sdk:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.poetry/bin:$PATH"
poetry --version
- name: Install dependencies
run: |
export PATH="$HOME/.poetry/bin:$PATH"
poetry install
- name: Update SDK
run: |
export PATH="$HOME/.poetry/bin:$PATH"
crucible update_sdk crucible.yaml openapi.yaml causadb
- name: Commit and push changes
run: |
git config --global user.name 'github-actions'
git config --global user.email 'github-actions@github.com'
git add causadb/
git commit -m 'Regenerate SDK from updated OpenAPI specification'
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for crucible_sdk-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c99ee0fc1d9fbeb5e8e16bb917220a9d26cb295e8f0ce49841c7b981a55d37bd |
|
MD5 | 74c926d84a310f7a4b90dd051db19589 |
|
BLAKE2b-256 | 441c65c0b7923455bdba822bc6fc28632eb88bd43458c7a2f4f03653c17bb1a7 |