A CLI for every service which exposes a OpenAPI (Swagger) specification endpoint.
From the OpenAPI Specification project:
The goal of The OpenAPI Specification is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.
To start a CLI session run:
docker run -it privcloudcom/open-cli3 -s <swagger-spec-url>
e.g:
docker run -it privcloudcom/open-cli3 -s http://petstore.swagger.io/v3/swagger.json
To install locally via PIP run:
pip3 install open-cli3
To start a CLI session run:
open-cli3 -s <swagger-spec-url>
e.g:
open-cli3 -s https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore-expanded.json
Running CLI session will automatically create config file at path ~/.open-cli3-config/config.cfg
To use profile config pass profile flag with desired profile name:
open-cli3 --profile <profile_name>
e.g.:
open-cli3 --profile profile1
This will work only if you specify profile in your open-cli3 config file: path ~/.open-cli3-config/config.cfg
.
Example of config file:
[profile1]
endpoint = <endpoint>
access_token = <access_token>
To get data without running CLI session, please specify -c
flag. It will automatically execute specified command
and return result data. Example:
open-cli3 -s <swagger-spec-url> -c 'auth:login --body.email=<user_email> --body.password=<user_password>'
or
open-cli3 --profile profile1 -c 'auth:login --body.email=<user_email> --body.password=<user_password>'
).
If a profile name (--profile
flag) and swagger url (-s
flag) are provided (example:
open-cli3 -s <swagger-spec-url> --profile profile1
), the profile will take precedence. If such profile does not exist CLI will automatically create config file for the profile.
If you want to measure the request and response total time you should use --print-request-time
flag. Example:
open-cli3 -s <swagger-spec-url> --print-request-time true
For help run:
open-cli3 -h
This project relies on OpenApi3 openapi3 project & on Jonathan Slenders python-prompt-toolkit.