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.

web-frameworkserialization
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

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 footguns
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.
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.
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.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources