Registry / web-framework / openapi-codec

openapi-codec

JSON →
library1.3.2pypypiunverified

OpenAPI-codec is a Python library that functions as a codec for the OpenAPI schema format (also known as Swagger) within the Core API framework. It enables Python clients to interact with services exposing OpenAPI schemas and automatically integrates with the Core API command-line client upon installation. The project's last update on GitHub was 7 years ago, and its latest release on PyPI was in July 2017, indicating that it is no longer actively maintained.

pip install openapi-codec
INSTALL
IMPORT
SIG · OPENAPI-CODEC
O
openapi-codec
web-frameworkpythonv1.3.2
Install
4.3s avg
Import
1015ms
Disk
22MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.658s · 24.5MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.3s · import 0.561s · 25MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OpenAPICodec
from openapi_codec import OpenAPICodec
from openapi_codec import OpenAPICodec

This quickstart demonstrates how to initialize a Core API client with the `OpenAPICodec` to interact with services exposing OpenAPI schemas. It highlights the need to explicitly specify `format='openapi'` if the server does not correctly use the `application/openapi+json` content type.

from openapi_codec import OpenAPICodec from coreapi.codecs import JSONCodec from coreapi import Client # Configure decoders for the Core API client decoders = [OpenAPICodec(), JSONCodec()] client = Client(decoders=decoders) # Example of fetching a schema that might require explicit format if content-type is generic # Use a public OpenAPI schema URL for demonstration, e.g., petstore.swagger.io # Note: This URL might return 'application/json' so format='openapi' is crucial. # Ensure COREAPI_FORMAT_OPENAPI is set in your environment or passed directly. # For a live example, you might need a service that truly serves 'application/openapi+json'. # This code assumes a valid OpenAPI JSON is returned at the URL. try: # Simulate a fetch, if direct URL doesn't work, consider a local file or mock. # For a real API, replace with the actual URL and handle potential authentication. document = client.get('http://petstore.swagger.io/v2/swagger.json', format='openapi') print('Successfully decoded OpenAPI document:') print(document.title) print(f'Number of endpoints: {len(document.data)}') except Exception as e: print(f'Error decoding document: {e}') print('Ensure the URL serves a valid OpenAPI schema and Core API/openapi-codec are installed.')
coreapi --version
Debug
Known issues
breakingThe library is abandoned; the last release was in July 2017, and the GitHub repository shows no activity for the past 7 years. This means it's unlikely to support newer Python versions, recent OpenAPI Specification (OAS) versions (e.g., 3.1, 3.2), or receive security patches.
fix
Consider migrating to actively maintained alternatives or custom parsing solutions if full OpenAPI v3+ support is required.
affects: <=1.3.2
gotchaIf the API server exposes the OpenAPI schema using a generic `application/json` content type instead of `application/openapi+json`, the `OpenAPICodec` might not be automatically selected by Core API.
fix
Explicitly include `format='openapi'` in your `client.get()` or `coreapi` CLI command to force the use of `OpenAPICodec`.
affects: <=1.3.2
deprecatedThe Core API framework itself, which `openapi-codec` depends on, also appears to be unmaintained. This means the entire ecosystem might be outdated and incompatible with modern Python practices or security standards.
fix
Evaluate the current maintenance status of `coreapi` and consider its implications for your project's long-term stability and security.
affects: <=1.3.2
Upgrade
Version history
1.3.2latest on PyPI · released Jul 19, 2017
Audit
Dependencies
coreapirequiredThis library is an OpenAPI codec specifically designed for the Core API framework.
Agent activity
21 hits · last 30 days
node
20
Resources
openapi-codec — pip install openapi-codec · libregistry