Skip to main content

OpenAPI CLI

OpenAPI CLI is a command-line interface (CLI) tool designed to interact with APIs generated by openapi-python-client. This tool allows you to configure and use API clients with ease.

Features

  • Configure API client modules
  • Validate client modules
  • Generate API client instances

Installation

To install OpenAPI CLI, use poetry:

poetry add openapi-cli[full]

To install the CLI globally, use pip:

pip install openapi-cli[full]

Optional

If you want to just use separator for your operation ids use:

poetry add openapi-cli

This will not have a cli, but you can use the separator in your code. If you want to still have ability to generate clients use the following:

poetry add openapi-cli[full] --group dev

This will keep your project build clean and will not install the cli in your production environment.

Usage

To use OpenAPI CLI in your project add the following to your pyproject.toml:

    [tool.poetry.scripts]
    your-api-cli = "openapi_cli:cli"

Then, you can run the CLI using in venv activated shell:

    your-api-cli --help

Configure the CLI

Before using the CLI, you need to configure it with your client module, base URL, and token.

Install the client module using downloaded module using openapi-python-client:

your-api-cli client install --module <name_of_your_module> 

Set the base URL and token for the client module:

openapi client api-config --base-url <url_of_your_api>
openapi client auth --token <your_token>

Patch the client to support nesting:

openapi client patch --separator <your_operation_id_separator>  # default is '_oaps_'

You can import separator to integrate it with your code:

from openapi_cli.separator import CLI_SEPARATOR

Requirements

  • Python 3.12+
  • Poetry

Setup

  1. Clone the repository.
  2. Install dependencies using poetry install.

Code Formatting

This project uses black and isort for code formatting. To format the code, run:

poetry run black .
poetry run isort .

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for openapi-cli 0.2.1.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openapi-cli 0.2.1.14
File Size Uploaded
openapi_cli-0.2.1.14.tar.gz 54.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openapi-cli 0.2.1.14
File Interpreter ABI Platform
openapi_cli-0.2.1.14-py3-none-any.whl Python 3 none any Details

Total release size: 93.1 kB

Release files / openapi_cli-0.2.1.14.tar.gz

Download URL openapi_cli-0.2.1.14.tar.gz
Size 54.8 kB
Tags Source
SHA-256 checksum
How to use checksums
59a976f769f31407ca7a3111c68d7356c73b6e0d61dd56f8d43f954aa97c12f6
BLAKE2b-256 checksum
How to use checksums
ef30b49294f4182bada86bc0cb96821e4f1ad9c3e8541f6961063654c13048dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.11.1 Darwin/24.4.0

Release files / openapi_cli-0.2.1.14-py3-none-any.whl

Download URL openapi_cli-0.2.1.14-py3-none-any.whl
Size 38.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f5d1897a788020e6a84d248dd9e417cc71a250d96fe98dbdb527d27b7c10561
BLAKE2b-256 checksum
How to use checksums
373d60b886f49ca14bf7741afb7bcbbab52b0b8e8809338cfe68e5a421b49149
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.11.1 Darwin/24.4.0
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page