Use OpenAPI schema to generate command line client
Project description
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
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.patcher import CLI_SEPARATOR
Requirements
- Python 3.12+
- Poetry
Setup
- Clone the repository.
- 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.
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 openapi_cli-0.1.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d616f1267a0b3363200a81a821c7a7f99a288db1e10080e2595be2805dc9cc1c |
|
MD5 | d0968a57f9a1f0cfd4b849f38bc29d56 |
|
BLAKE2b-256 | 3323643cb455a6cfa0f430cf6a89326a69305b6024af25aadaa66fca30fce791 |