Voluptuous OpenAPI Converter

0.3.0 · active · verified Thu Apr 16

voluptuous-openapi is a Python library that converts Voluptuous schemas into OpenAPI Schema objects. It is currently at version 0.3.0 and appears to have a stable, though not rapid, release cadence, with the latest release on Dec 30, 2025.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a basic Voluptuous schema with required, optional, and type-specific validators, and then convert it into a dictionary representing an OpenAPI Schema object using `voluptuous-openapi.convert`.

import voluptuous as vol
from voluptuous_openapi import convert

# Define a simple Voluptuous schema
schema = vol.Schema({
    vol.Required('name'): vol.All(str, vol.Length(min=5)),
    vol.Optional('age'): vol.All(int, vol.Range(min=0)),
    'email': vol.Email,
})

# Convert the Voluptuous schema to an OpenAPI Schema object
openapi_schema = convert(schema)

# Print the resulting OpenAPI schema (dictionary representation)
import json
print(json.dumps(openapi_schema, indent=2))

view raw JSON →