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.
- Python 3.8 or higher
- pip (Python package installer)
Available as borea-python on PyPI.
pip install borea-pythonFor info on cloning and installing manually read Manual Install.
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.
python -m borea_python.cli initThis 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.
python -m borea_python.cli generate [OPTIONS]The generator will create the Python HTTP client SDK based on the OpenAPI specification.
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.
python -m borea_python.cli generate --helpOutput:
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.
To be implemented...
To run the test suite:
python -m pytestsrc/- 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)
git clone https://github.com/Borea-dev/python-client-generator.gitRun the automated setup script:
source is required to activate the virtual environment
source ./setup-venv.shThis 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 messageThis project is licensed under the terms specified in the LICENSE file.