Generate extensible python HTTP client from OpenAPI spec
Project description
Borea Python HTTP Client SDK Generator
Please learn more about Borea and our mission at borea.dev and our organization on GitHub Borea-dev.
This repository contains a Python HTTP client SDK generator. It generates a Python client from an OpenAPI specification.
Table of Contents
Getting Started
Prerequisites
- Python 3.8 or higher
- pip (Python package installer)
Installation
Available as borea-python on PyPI.
pip install borea-python
For info on cloning and installing manually read Manual Install.
Usage
Running the Python SDK Generator
The SDK generator provides two main commands:
init- Creates a newborea.config.jsonconfiguration filegenerate- Generates a Python SDK from an OpenAPI specification
If no command is specified, the help message will be displayed.
Initialize a new configuration file
python -m borea_python.cli init
This will create a new borea.config.json file in the current directory with default settings. If the file already exists, you will be prompted to confirm overwriting it.
Generate the SDK
python -m borea_python.cli generate [OPTIONS]
The generator will create the Python HTTP client SDK based on the OpenAPI specification.
Configuration
IMPORTANT!
Command line arguments take precedence over settings in borea.config.json.
The project uses borea.config.json for configuration settings. Example config with the defaults:
{
"input": {
"openapi": ["openapi.json"]
},
"output": {
"clientSDK": "Formatted OpenAPI Title by default",
"models": "models",
"tests": false,
"xCodeSamples": false
},
"ignores": []
}
input: map input options to array of values, ordered by precedence. For example, first value is a file path and the second is a URL. If the file cannot be found, then the URL will be used.output: map output options to valuesignore: array ofglobpatterns to ignore. No file or directory matching the pattern will be created.
Command line help
python -m borea_python.cli generate --help
Output:
Usage: python -m borea_python.cli generate [OPTIONS]
Generate a Python SDK from an OpenAPI specification.
The OpenAPI specification can be provided as a local file path or a URL. For
URLs, both JSON and YAML formats are supported.
Options:
-i, --openapi-input TEXT Path to OpenAPI specification file or URL
-o, --sdk-output TEXT Output directory for the generated SDK
-m, --models-output TEXT Output directory for the generated models
-t, --tests TEXT Generate tests
-x, --x-code-samples TEXT Generate x-code-samples
-c, --config TEXT Path to borea.config.json
--help Show this message and exit.
Running Tests
To be implemented...
To run the test suite:
python -m pytest
Project Structure
src/- Contains the source code for the SDK generatoropenapi.json- OpenAPI specification file or wherever you decide to put itborea.config.json- Configuration file for the generator.venv/- Python virtual environment (created during setup)
Manual Install
Clone repo
git clone https://github.com/Borea-dev/python-client-generator.git
Run the automated setup script:
source is required to activate the virtual environment
source ./setup-venv.sh
This script will:
- Create a Python virtual environment (
.venv) - Activate the virtual environment
- Install all required dependencies
Available options:
setup-venv.sh [OPTIONS]
Options:
-r, --recreate Recreate virtual environment (deletes existing .venv)
-i, --reinstall Reinstall all requirements
-h, --help Show this help message
License
This project is licensed under the terms specified in the LICENSE file.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file borea_python-1.1.3.tar.gz.
File metadata
- Download URL: borea_python-1.1.3.tar.gz
- Upload date:
- Size: 28.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
565a2231af5c3c226752befbe2d7c2550e950a25eed3c6d8943690cf42267267
|
|
| MD5 |
f21909fafebdeb745a5db563cbf896c4
|
|
| BLAKE2b-256 |
0668ad5856694d5ca2f0261f5dfb4bcca21149c8beb021356a1d959a62eb3ed3
|
Provenance
The following attestation bundles were made for borea_python-1.1.3.tar.gz:
Publisher:
pypi.yml on Borea-dev/python-client-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
borea_python-1.1.3.tar.gz -
Subject digest:
565a2231af5c3c226752befbe2d7c2550e950a25eed3c6d8943690cf42267267 - Sigstore transparency entry: 194651472
- Sigstore integration time:
-
Permalink:
Borea-dev/python-client-generator@61b7d68fcdc87fabe5811c58dad2b34e60b5cce4 -
Branch / Tag:
refs/tags/v1.1.3 - Owner: https://github.com/Borea-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@61b7d68fcdc87fabe5811c58dad2b34e60b5cce4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file borea_python-1.1.3-py3-none-any.whl.
File metadata
- Download URL: borea_python-1.1.3-py3-none-any.whl
- Upload date:
- Size: 32.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
793705a009402bc295a77211dcb89c7746905cfbbd2500f59c8f785e2f625c20
|
|
| MD5 |
3117e0c6f6b7a7181172d221b5df59c0
|
|
| BLAKE2b-256 |
43626006a4129929524141a783ccf5bdfc226ee55734cd95d6ef8b72b92ef484
|
Provenance
The following attestation bundles were made for borea_python-1.1.3-py3-none-any.whl:
Publisher:
pypi.yml on Borea-dev/python-client-generator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
borea_python-1.1.3-py3-none-any.whl -
Subject digest:
793705a009402bc295a77211dcb89c7746905cfbbd2500f59c8f785e2f625c20 - Sigstore transparency entry: 194651473
- Sigstore integration time:
-
Permalink:
Borea-dev/python-client-generator@61b7d68fcdc87fabe5811c58dad2b34e60b5cce4 -
Branch / Tag:
refs/tags/v1.1.3 - Owner: https://github.com/Borea-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@61b7d68fcdc87fabe5811c58dad2b34e60b5cce4 -
Trigger Event:
push
-
Statement type: