Skip to main content

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:

  1. init - Creates a new borea.config.json configuration file
  2. generate - 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 values
  • ignore: array of glob patterns 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 generator
  • openapi.json - OpenAPI specification file or wherever you decide to put it
  • borea.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:

  1. Create a Python virtual environment (.venv)
  2. Activate the virtual environment
  3. 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

borea_python-1.1.3.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

borea_python-1.1.3-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

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

Hashes for borea_python-1.1.3.tar.gz
Algorithm Hash digest
SHA256 565a2231af5c3c226752befbe2d7c2550e950a25eed3c6d8943690cf42267267
MD5 f21909fafebdeb745a5db563cbf896c4
BLAKE2b-256 0668ad5856694d5ca2f0261f5dfb4bcca21149c8beb021356a1d959a62eb3ed3

See more details on using hashes here.

Provenance

The following attestation bundles were made for borea_python-1.1.3.tar.gz:

Publisher: pypi.yml on Borea-dev/python-client-generator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for borea_python-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 793705a009402bc295a77211dcb89c7746905cfbbd2500f59c8f785e2f625c20
MD5 3117e0c6f6b7a7181172d221b5df59c0
BLAKE2b-256 43626006a4129929524141a783ccf5bdfc226ee55734cd95d6ef8b72b92ef484

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page