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']

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cicerone-0.3.0.tar.gz (249.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cicerone-0.3.0-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

Details for the file cicerone-0.3.0.tar.gz.

File metadata

  • Download URL: cicerone-0.3.0.tar.gz
  • Upload date:
  • Size: 249.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for cicerone-0.3.0.tar.gz
Algorithm Hash digest
SHA256 65b70b9718159a09c6448dabf5811551e082bc95a7fb66bf608bf7f4c6574bec
MD5 a62acc2af915806eebe01c73b9c3f9af
BLAKE2b-256 9841b35fb2536f69e2ec7ef477e5fdb86ff700ab5483e2ade32c091c6d313ed7

See more details on using hashes here.

File details

Details for the file cicerone-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: cicerone-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 33.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for cicerone-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0e66047d33392a783aef80b988c1bab5b2c7aee5f46f9a0086f07424339c6bab
MD5 fe745ac058f6755c3cede64f11906821
BLAKE2b-256 01d874b02952cfaa43fb1856a0dede9fe6442b25a26fac4ae1ff4c991e651d05

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page