skillfed

apispec-oneofschema

Plugin for apispec providing support for Marshmallow-OneOfSchema schemas

apispec-oneofschema v3.0.2 237.7K downloads/30d#8,954 on PyPI12
Permissive license MIT AGING released

What it is and what it does

apispec-oneofschema is a plugin for apispec that bridges Marshmallow's OneOfSchema polymorphic type system with OpenAPI 3.0+ documentation. It automatically generates discriminator-based schema definitions in your OpenAPI spec, mapping polymorphic types to their corresponding schemas with proper references.

When you register a OneOfSchema with apispec using this plugin, it produces OpenAPI components that include a discriminator object with a propertyName and a mapping of type values to schema references. This lets API consumers understand which schema variant applies based on a discriminator field in the JSON payload, and it enables code generation tools to handle polymorphic responses correctly.

Use it for:

  • Document REST APIs with polymorphic request or response bodies where the type is determined by a discriminator field.
  • Generate OpenAPI specs for services using Marshmallow OneOfSchema for type-safe serialization of union types.
  • Enable API client generators to produce correct deserialization code for discriminator-based polymorphic types.
  • Validate and document complex data models with multiple schema variants in a single endpoint.
  • Integrate Marshmallow schema definitions directly into OpenAPI documentation without manual discriminator mapping.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Extends apispec to generate OpenAPI 3.0+ documentation for Marshmallow OneOfSchema schemas, mapping polymorphic types to discriminator-based schema references.

Yes, if you use Marshmallow OneOfSchema and need to generate OpenAPI 3.0+ documentation. The plugin fills a specific gap—apispec does not natively handle OneOfSchema discriminators—and has no known vulnerabilities. The aging maintenance status is a minor concern but not a blocker for a stable, focused tool. Install if this matches your stack; skip if you don't use OneOfSchema or target earlier OpenAPI versions.

Install

apispec-oneofschema on PyPI

pip

pip install apispec-oneofschema

uv

uv add apispec-oneofschema

poetry

poetry add apispec-oneofschema

Installing apispec-oneofschema

Before you install

Low friction installation with three straightforward runtime dependencies. Maintenance status is aging—last release was 382 days ago—but the repository remains active and unarchived, suggesting the package is stable rather than abandoned.

License in practice

MIT license is permissive, allowing use in commercial and proprietary projects with minimal restrictions beyond attribution.

Quickstart

pip install apispec-oneofschema

from apispec import APISpec
from apispec_oneofschema import MarshmallowPlugin
from marshmallow_oneofschema import OneOfSchema

spec = APISpec(
    title='Example',
    version='1.0.0',
    openapi_version='3.0.0',
    plugins=[MarshmallowPlugin()]
)
spec.components.schema('MySchema', schema=YourOneOfSchema)

Requires OpenAPI version 3.0.0 or greater; earlier versions do not support discriminator name-to-definition mapping.

Verify before relying

  • Whether the package works with current versions of apispec and marshmallow-oneofschema without breaking changes.
  • Python version compatibility (requires_python is unspecified in metadata).

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies 3 — apispec, marshmallow, marshmallow-oneofschema
Maintenance aging — 382 days since the last release
Last repo commit
First released
Downloads 237,688/month — #8,954 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: apispec_oneofschema-3.0.2-py3-none-any.whl

Tags

apispec marshmallow pluginopenapi oneof schemapolymorphic schema documentationmarshmallow discriminatorapi spec schema generationopenapi 3.0 discriminator
openapi-generationschema-validation

More Application Frameworks packages

fastapi

FastAPI is a Python web framework for building…

permissive · top 100 on PyPI

annotated-doc

Provides a way to document function parameters,…

permissive · top 100 on PyPI

textual

Textual is a Python framework for building…

permissive · top 100 on PyPI

typer

Typer builds command-line applications from…

permissive · top 1,000 on PyPI

mcp

Build and connect to Model Context Protocol…

permissive · top 1,000 on PyPI

Werkzeug

Werkzeug is a WSGI utility library providing…

permissive · top 1,000 on PyPI

marshmallow-oneofschema

Extends marshmallow to handle polymorphic…

permissive · top 5,000 on PyPI

marshmallow-fastoneofschema

Extends marshmallow to handle polymorphic…

permissive · top 15,000 on PyPI

apispec

Generates OpenAPI specification documents from…

permissive · top 5,000 on PyPI

apispec-webframeworks

Provides web framework plugins for apispec to…

permissive · top 15,000 on PyPI

marshmallow-jsonschema

Converts marshmallow schemas into JSON Schema…

permissive · top 5,000 on PyPI

marshmallow-polyfield

Extends Marshmallow with a PolyField class that…

permissive · top 15,000 on PyPI

flask-apispec

flask-apispec decorates Flask view functions…

permissive · top 15,000 on PyPI

dataclasses-jsonschema

Generates JSON Schema from Python dataclasses…

permissive · top 15,000 on PyPI

voluptuous-openapi

Converts Voluptuous validation schemas into…

permissive · top 15,000 on PyPI

marshmallow-mongoengine

Generates marshmallow schemas automatically…

permissive · top 15,000 on PyPI