Skip to main content

openapi-spec-tools

This is a collection of tools for using OpenAPI specifications. The OpenAPI community has a plethora of tools, and this is intended to supplement those. The tools here provide functionality that has not been readily available elsewhere.

Getting started

The project has been published to PyPi, so you should be able to install it with something like one of the following (depending on how you do Python package management):

% pip install openapi-spec-tools
% uv add openapi-spec-tools

Generally, there are two intended ways to utilize this package:

  • Use the CLI tools to perform actions
    • oas - analyzing and modifying an OpenAPI spec
    • layout - generating and analyzing a YAML file that provides structure to the CLI/API generator
    • cli-gen - generates a CLI from an OpenAPI spec (and optionally a layout file)
    • api-gen - generates API code from an OpenAPI spec (and optionally a layout file)
  • Use the code in the Python modules for your own purpose

The sections below provide a brief description with links to more examples and details.

OAS

The oas script provides a tool for analyzing and modifying an OpenAPI spec. See OAS.md for more info.

Here's a trivial example:

(.env) % oas analyze models list pet.yaml 
Found 3 models:
    Error
    Pet
    Pets
(.env) % oas analyze models ops pet.yaml Pet
Found Pet is used by 3 operations:
    createPets
    listPets
    showPetById
(.env) % 

Layout

The CLI and API generation allow users to specify a layout file to reduce assumptions. More information about the layout generation, format and schema are covered in LAYOUT.md.

CLI Generation

The cli-gen tool allows users to create a user-friendly CLI using the OpenAPI spec and a layout file. The layout file provides the CLI structure and refers to the OpenAPI spec for details of operations. LAYOUT.md has more details about the layout file, and the CLI_GEN.md has more info about CLI generation.

Turn a simple layout like:

main:
  description: Manage pets
  operations:
    - name: add
      operationId: createPets

Into code that produces a CLI that has commands like:

% pets add --help
                                                                                                                                                        
 Usage: pets add [OPTIONS]                                             

 Create a pet
 
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --id                 INTEGER                                                                                                                         │
│ --name               TEXT                                                                                                                            │
│ --tag                TEXT                                                                                                                            │
│ --owner              TEXT                                                                                                                            │
│ --api-host           TEXT                              API host address [env var: API_HOST]                                                          │
│ --api-key            TEXT                              API key for authentication [env var: API_KEY]                                                 │
│ --api-timeout        INTEGER                           API request timeout in seconds for a single request [env var: API_TIMEOUT] [default: 5]       │
│ --log                [critical|error|warn|info|debug]  Log level [env var: LOG_LEVEL] [default: warn]                                                │
│ --format             [table|json|yaml]                 Output format style [env var: OUTPUT_FORMAT] [default: table]                                 │
│ --style              [none|bold|all]                   Style for output [env var: OUTPUT_STYLE] [default: all]                                       │
│ --help                                                 Show this message and exit.                                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
% 

See the examples in examples/ for some more complete works.

The CLI generator can be configured using a YAML file. For more details, see GEN_CONFIG.md.

API Generation

The api-gen tool allows users to generate API code using the OpenAPI spec. The generated Python code provides type hints and helpful comments, but does no real checking of the arguments and/or return values. The return values are typically dictionaries instead of a data class, such as the models provided in the standard OpenAPI generator.

The API generator can be configured using a YAML file. For more details, see GEN_CONFIG.md.

Contributing

The DEVELOPMENT.md has more information about getting setup as a developer.

The TODO.md has some ideas where this project can be improved and expanded -- please add your ideas here, or email Rick directly (rickwporter@gmail.com).

Metadata

Release files for openapi-spec-tools 0.19.0

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-spec-tools 0.19.0
File Size Uploaded
openapi_spec_tools-0.19.0.tar.gz 73.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openapi-spec-tools 0.19.0
File Interpreter ABI Platform
openapi_spec_tools-0.19.0-py3-none-any.whl Python 3 none any Details

Total release size: 167.3 kB

Release files / openapi_spec_tools-0.19.0.tar.gz

Download URL openapi_spec_tools-0.19.0.tar.gz
Size 73.1 kB
Tags Source
SHA-256 checksum
How to use checksums
81decc83d9a0a2ca2809de01a4cff849694e134a718ed8859ccb9dc44c7c7a2a
BLAKE2b-256 checksum
How to use checksums
30371ce75f8f1f03323a1c5a2c5b4910ec11b323d863dad00be456022da6dccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / openapi_spec_tools-0.19.0-py3-none-any.whl

Download URL openapi_spec_tools-0.19.0-py3-none-any.whl
Size 94.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d50859a3a0051a13efa607948756564bdce92dcd4e580b84341567fe6cffcfc
BLAKE2b-256 checksum
How to use checksums
69aa942efb5234d3deec4b82c353e0352ac2c52768a0ad31982cfbbe5f620a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.19.0 This release

2 release files

0.18.0

2 release files

0.17.2

2 release files

0.17.0

2 release files

0.14.0

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.10

2 release files

0.9.9

2 release files

0.9.8

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

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