Skip to main content

📜 Cicerone

Turn OpenAPI schemas into Pydantic models

Package version codecov PyPI - License

Cicerone parses OpenAPI schemas into Pydantic models for introspection and traversal.

Cicerone is the fastest, most minimal, fully typed, pythonic library for dealing with OpenAPI schemas.

Features

  • Full support: Tested against hundreds of real schemas to ensure 100% compliance.
  • Pydantic-based models: Type-safe object models.
  • Multiple input formats: Load from files, URLs, or in-memory data in various formats.
  • OpenAPI 3.x support: Works with OpenAPI 3.0 and 3.1 specifications
  • Minimal dependencies: Only relies on Pydantic and pyyaml. The rest is core Python.
  • Simple API: Intuitive methods for common operations.
  • Modern Python: Fully typed and 100% test coverage codebase.

Installation

pip

pip install cicerone

uv

uv add cicerone

Quick Start

Parsing Specifications

from cicerone import parse as cicerone_parse

# From a file
file_spec = cicerone_parse.parse_spec_from_file("openapi.yaml")

# From a URL
url_spec = cicerone_parse.parse_spec_from_url("https://api.example.com/openapi.json")

# From a dictionary
dict_spec = cicerone_parse.parse_spec_from_dict({"openapi": "3.0.0", ...})

# From JSON string
json_spec = cicerone_parse.parse_spec_from_json('{"openapi": "3.0.0", ...}')

# From YAML string
yaml_spec = cicerone_parse.parse_spec_from_yaml('openapi: "3.0.0"\n...')

Exploring the schema

from cicerone import parse as cicerone_parse

spec = cicerone_parse.parse_spec_from_file('tests/fixtures/petstore_openapi3.yaml')

print("OpenAPISpec:", spec)
>>> OpenAPISpec: <OpenAPISpec: 'Test API' v3.0.0, 2 paths, 2 schemas>

print("Paths:", spec.paths)
>>> Paths: <Paths: 2 paths, 3 operations [/users, /users/{userId}]>

print("PathItem:", spec.paths["/users"])
>>> PathItem: <PathItem: /users [GET, POST]>

print("Operation:", spec.operation_by_operation_id("listUsers"))
>>> Operation: <Operation: GET /users, id=listUsers, 'List all users', tags=['users']>

print("Components:", spec.components)
>>> Components: <Components: 2 schemas [User, Error]>

print("Schema:", spec.components.get_schema("User"))
>>> Schema: <Schema: type=object, 5 properties, required=['id', 'username', 'email']>

user = spec.components.get_schema("User")
print(f"User properties: {list(user.properties.keys())}")
>>> User properties: ['id', 'username', 'email', 'age', 'roles']

Resolving References

Resolve $ref references to their typed objects:

from cicerone import parse as cicerone_parse

spec = cicerone_parse.parse_spec_from_file('tests/fixtures/petstore_openapi3.yaml')

# Resolve a reference to get a typed Schema object
# follow_nested=True will recursively resolve all nested $refs
user_schema = spec.resolve_reference('#/components/schemas/User', follow_nested=True)
print(f"User schema type: {user_schema.type}")
>>> User schema type: object
print(f"Required fields: {user_schema.required}")
>>> Required fields: ['id', 'username', 'email']

Metadata

Release files for cicerone 0.3.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 cicerone 0.3.0
File Size Uploaded
cicerone-0.3.0.tar.gz 249.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cicerone 0.3.0
File Interpreter ABI Platform
cicerone-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 283.5 kB

Release files / cicerone-0.3.0.tar.gz

Download URL cicerone-0.3.0.tar.gz
Size 249.7 kB
Tags Source
SHA-256 checksum
How to use checksums
65b70b9718159a09c6448dabf5811551e082bc95a7fb66bf608bf7f4c6574bec
BLAKE2b-256 checksum
How to use checksums
9841b35fb2536f69e2ec7ef477e5fdb86ff700ab5483e2ade32c091c6d313ed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.6

Release files / cicerone-0.3.0-py3-none-any.whl

Download URL cicerone-0.3.0-py3-none-any.whl
Size 33.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e66047d33392a783aef80b988c1bab5b2c7aee5f46f9a0086f07424339c6bab
BLAKE2b-256 checksum
How to use checksums
01d874b02952cfaa43fb1856a0dede9fe6442b25a26fac4ae1ff4c991e651d05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.6

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

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