Load, resolve, and normalise OpenAPI 3.x / Swagger 2.0 specs into a version-agnostic model.
Project description
openapi-normalizer
Load, resolve, and normalise OpenAPI 3.x and Swagger 2.0 specifications into a single, version-agnostic data model.
- 🔗 $ref resolution — resolves intra-document references with cycle protection
- 📦 Version normalisation — OpenAPI 3.x and Swagger 2.0 become the same internal model
- 🌐 HTTP + local files — load specs from URLs or filesystem paths
- 📄 JSON + YAML — both formats supported
- ✅ Typed, tested, and linted
Installation
pip install openapi-normalizer
Requires Python 3.10+.
Quickstart
from openapi_normalizer import load_spec, resolve_refs, parse_spec
# Load from URL or file (JSON or YAML)
document = load_spec("https://petstore3.swagger.io/api/v3/openapi.json")
# Resolve all intra-document $ref pointers
document = resolve_refs(document)
# Normalise into a version-agnostic model
spec = parse_spec(document)
print(spec.title) # "Swagger Petstore - OpenAPI 3.0"
print(spec.base_url) # "/api/v3"
for op in spec.operations:
print(op.method, op.path, op.operation_id)
API
load_spec(ref, *, timeout=30.0) → dict
Load a spec from a URL or local file. Returns the parsed document as a dict.
resolve_refs(document) → dict
Resolve all local $ref pointers (e.g. #/components/schemas/Pet) in-place. External references are preserved. Cycles are broken safely.
detect_version(document) → str
Return "openapi-3" or "swagger-2".
parse_spec(document, *, source_ref=None, base_url_override=None) → ParsedSpec
Normalise a ref-resolved document into a ParsedSpec containing:
title,base_url,spec_versionoperations— list ofOperation(method, path, parameters, request body, tags)security_schemes— dict ofSecurityScheme(type, scheme, name, location)
License
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_normalizer-0.1.0.tar.gz.
File metadata
- Download URL: openapi_normalizer-0.1.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
181d95b3cf59054d83097f2f5575a9f64f48f919ab88b5d6091ad02e2ef5f37f
|
|
| MD5 |
8106ab0695e7c2d015eccb0159b438bb
|
|
| BLAKE2b-256 |
e144dfc2640996acc31787b4180e1a7ce7ae3cbf091fbc032faf454da7c9b092
|
Provenance
The following attestation bundles were made for openapi_normalizer-0.1.0.tar.gz:
Publisher:
release.yml on sssdavid529/openapi-normalizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_normalizer-0.1.0.tar.gz -
Subject digest:
181d95b3cf59054d83097f2f5575a9f64f48f919ab88b5d6091ad02e2ef5f37f - Sigstore transparency entry: 1684835845
- Sigstore integration time:
-
Permalink:
sssdavid529/openapi-normalizer@b86cd817d542f0a68dc1b740159d6a624349ef98 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sssdavid529
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b86cd817d542f0a68dc1b740159d6a624349ef98 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openapi_normalizer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openapi_normalizer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4879124f62bbafb598dad0e2282928ecff2ce8e1b1cf5a1273cbad060a31142
|
|
| MD5 |
f936c988459fb4e31dc8bc2a1406fca2
|
|
| BLAKE2b-256 |
f7118be5d129940986160b202fa10d4a6fe370595c44241ba63970ca3206d303
|
Provenance
The following attestation bundles were made for openapi_normalizer-0.1.0-py3-none-any.whl:
Publisher:
release.yml on sssdavid529/openapi-normalizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_normalizer-0.1.0-py3-none-any.whl -
Subject digest:
c4879124f62bbafb598dad0e2282928ecff2ce8e1b1cf5a1273cbad060a31142 - Sigstore transparency entry: 1684835899
- Sigstore integration time:
-
Permalink:
sssdavid529/openapi-normalizer@b86cd817d542f0a68dc1b740159d6a624349ef98 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sssdavid529
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b86cd817d542f0a68dc1b740159d6a624349ef98 -
Trigger Event:
push
-
Statement type: