{"id":7466,"library":"openapi-codec","title":"OpenAPI Codec for Core API","description":"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.","status":"abandoned","version":"1.3.2","language":"en","source_language":"en","source_url":"http://github.com/core-api/python-openapi-codec/","tags":["openapi","swagger","coreapi","codec","api-client","abandoned"],"install":[{"cmd":"pip install openapi-codec","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This library is an OpenAPI codec specifically designed for the Core API framework.","package":"coreapi","optional":false}],"imports":[{"note":"The primary codec class is directly available under the top-level package.","wrong":"from openapi_codec.codec import OpenAPICodec","symbol":"OpenAPICodec","correct":"from openapi_codec import OpenAPICodec"}],"quickstart":{"code":"from openapi_codec import OpenAPICodec\nfrom coreapi.codecs import JSONCodec\nfrom coreapi import Client\n\n# Configure decoders for the Core API client\ndecoders = [OpenAPICodec(), JSONCodec()]\nclient = Client(decoders=decoders)\n\n# Example of fetching a schema that might require explicit format if content-type is generic\n# Use a public OpenAPI schema URL for demonstration, e.g., petstore.swagger.io\n# Note: This URL might return 'application/json' so format='openapi' is crucial.\n# Ensure COREAPI_FORMAT_OPENAPI is set in your environment or passed directly.\n# For a live example, you might need a service that truly serves 'application/openapi+json'.\n# This code assumes a valid OpenAPI JSON is returned at the URL.\n\ntry:\n    # Simulate a fetch, if direct URL doesn't work, consider a local file or mock.\n    # For a real API, replace with the actual URL and handle potential authentication.\n    document = client.get('http://petstore.swagger.io/v2/swagger.json', format='openapi')\n    print('Successfully decoded OpenAPI document:')\n    print(document.title)\n    print(f'Number of endpoints: {len(document.data)}')\nexcept Exception as e:\n    print(f'Error decoding document: {e}')\n    print('Ensure the URL serves a valid OpenAPI schema and Core API/openapi-codec are installed.')","lang":"python","description":"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."},"warnings":[{"fix":"Consider migrating to actively maintained alternatives or custom parsing solutions if full OpenAPI v3+ support is required.","message":"The 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.","severity":"breaking","affected_versions":"<=1.3.2"},{"fix":"Explicitly include `format='openapi'` in your `client.get()` or `coreapi` CLI command to force the use of `OpenAPICodec`.","message":"If 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.","severity":"gotcha","affected_versions":"<=1.3.2"},{"fix":"Evaluate the current maintenance status of `coreapi` and consider its implications for your project's long-term stability and security.","message":"The 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.","severity":"deprecated","affected_versions":"<=1.3.2"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install openapi-codec` to install the package.","cause":"The `openapi-codec` library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'openapi_codec'"},{"fix":"When fetching the schema, explicitly specify the format: `client.get(url, format='openapi')` or `coreapi get <url> --format openapi`.","cause":"Core API failed to automatically detect the OpenAPI format, often because the server returned a generic `Content-Type` header (e.g., `application/json`) for an OpenAPI schema.","error":"coreapi.exceptions.ParseError: Could not determine format. Expected one of..."},{"fix":"Ensure `coreapi` is installed and up-to-date (though note the overall maintenance status). Review `coreapi` documentation for client instantiation if this issue persists. The correct pattern is `client = Client(decoders=decoders)`.","cause":"This error likely indicates an incompatibility or an outdated version of `coreapi` when trying to instantiate the `Client` with `decoders`. Alternatively, if `OpenAPICodec` itself is instantiated with unexpected arguments, but the primary example uses it without args.","error":"TypeError: __init__() got an unexpected keyword argument 'decoders'"}]}