A lightweight CLI tool to generate a type-safe Python client from an OpenAPI specification.
Project description
[!WARNING] Early Development: This project is under active development. APIs may change.
Table of Contents
Quick Start
# Install
uv tool install openapi-burrito
# Generate
openapi-burrito generate openapi.json -o ./my_client
from my_client import Client
api = Client(base_url="https://api.example.com")
# Path-first API: type-checked paths and snake_case parameters
res = api.GET("/users/{user_id}", user_id=123)
if res.is_success:
print(res.data)
else:
print(f"Error {res.status_code}: {res.error}")
Features
- Path-First API - Call endpoints by path literal
(
api.GET("/users/{user_id}")), with full IDE autocomplete for paths and parameters - Type-Safe -
TypedDictmodels and@overloadsignatures - Zero Runtime - Generated code is yours, no runtime dependency on this tool
- httpx-Based - Async support, connection pooling, all httpx features
- Middleware System - Logging, retry, auth via composable middleware
- Snake Case Params - Path parameters auto-converted to Python style
(
{userId}→{user_id})
Installation
For Users
# As a CLI tool (recommended)
uv tool install openapi-burrito
# With preview server support (Swagger UI, Redoc)
uv tool install openapi-burrito[preview]
For Developers
# Clone and install all dev dependencies
git clone https://github.com/simon-lund/openapi-burrito.git
cd openapi-burrito
make install
# Run linting and type checks
make lint
# Run tests
make test
Security
This generator sanitizes identifiers and string literals to prevent code injection from malformed OpenAPI specs. However, always review untrusted specs before generating.
Parser Safety Audit
All fields output by the parser are validated/sanitized:
| Field | Validation | Notes |
|---|---|---|
| Model/param names | sanitize(mode="id") |
Converted to valid Python identifiers |
| Paths | sanitize(mode="str") |
String-escaped for literals |
| Descriptions/docs | sanitize(mode="doc") |
Docstring-escaped |
type strings |
Type translator | Built from validated schema types |
method |
HTTPMethod enum |
Only known HTTP methods allowed |
in (param location) |
Enum check | Only path|query|header|cookie |
required, read_only, write_only |
bool() cast |
Forced to boolean |
default |
repr() |
Python string representation |
A malicious spec could attempt injection like:
components:
schemas:
"User:\n pass\nimport os; os.system('rm -rf /') # ":
type: object
While this generator escapes such payloads, the safest approach is to only generate clients from trusted sources.
See CVE-2020-15142 for an example of this vulnerability class in other generators.
Documentation
| Guide | Description |
|---|---|
| Introduction | Installation and basic usage |
| Authentication | API keys, tokens, OAuth patterns |
| Middleware | Logging, retry, custom handling |
| Type System | UNSET, Unknown, NotRequired, limitations |
| CLI Reference | generate and preview commands |
| Contributing | Development setup and guidelines |
Examples
See the examples/ directory:
- Petstore - Classic Swagger Petstore API
- Artifacts MMO - Game API with complex schemas
Star History
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openapi_burrito-0.1.0.tar.gz.
File metadata
- Download URL: openapi_burrito-0.1.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15536fa1a0ba25567113810ecb85c6e0b75795b07a3e1ef2599b3efad5563289
|
|
| MD5 |
361937699f3c64c50e74058ece0ade24
|
|
| BLAKE2b-256 |
daa34b063d5d2c37abc325822feb9d6544ee0180f84f0888040c0b2d45b05303
|
Provenance
The following attestation bundles were made for openapi_burrito-0.1.0.tar.gz:
Publisher:
publish.yml on simon-lund/openapi-burrito
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_burrito-0.1.0.tar.gz -
Subject digest:
15536fa1a0ba25567113810ecb85c6e0b75795b07a3e1ef2599b3efad5563289 - Sigstore transparency entry: 794457701
- Sigstore integration time:
-
Permalink:
simon-lund/openapi-burrito@1e19fa3fcc62fd7b0be3f2f069f61cb3e2031520 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/simon-lund
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e19fa3fcc62fd7b0be3f2f069f61cb3e2031520 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openapi_burrito-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openapi_burrito-0.1.0-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89e518f0590f648967db65782ccedf90dae06627ad238f4c29768b42ac7175c7
|
|
| MD5 |
c63868e4828b0e167e105437be743b3a
|
|
| BLAKE2b-256 |
c190079f99abbb3a1f43722c372fef5632f6788ba9d9259bbcbcd75af4f3d750
|
Provenance
The following attestation bundles were made for openapi_burrito-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on simon-lund/openapi-burrito
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_burrito-0.1.0-py3-none-any.whl -
Subject digest:
89e518f0590f648967db65782ccedf90dae06627ad238f4c29768b42ac7175c7 - Sigstore transparency entry: 794457756
- Sigstore integration time:
-
Permalink:
simon-lund/openapi-burrito@1e19fa3fcc62fd7b0be3f2f069f61cb3e2031520 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/simon-lund
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1e19fa3fcc62fd7b0be3f2f069f61cb3e2031520 -
Trigger Event:
push
-
Statement type: