This release is a pre-release and may not be stable for production use.
benzene-openapi
An OpenAPI 3.1 document derived from a Benzene Python
handler registry — a sibling projection to the JSON Schema this port already derives and to the Cloud
Service Profile's Contract Document. Depends on benzene-core (schemas + registry) and benzene-http (the
/benzene/invoke base and the status mapping).
pip install benzene-openapi
Benzene is message-topic-based, not REST, so there is nothing to hand a Swagger UI or a client
generator out of the box. openapi_document closes that gap: it projects the same registry the
Contract Document reads into a standard OpenAPI document, reusing benzene.core.json_schema for every
payload schema — never re-deriving one.
from dataclasses import dataclass
from benzene.core import Registry
from benzene.openapi import openapi_document
@dataclass
class PlaceOrder:
sku: str
quantity: int
@dataclass
class OrderPlaced:
order_id: str
registry = Registry().register(
"orders:place", handler, request_type=PlaceOrder, response_type=OrderPlaced
)
document = openapi_document(registry, title="Orders", version="2.1.0")
Each registered (topic, version) becomes one POST operation under the profile's well-known invoke
base (/benzene/invoke/{topic}, with a /{version} segment for a versioned handler), and every
Benzene failure status is mapped to its HTTP code through benzene.http.to_http:
{
"openapi": "3.1.0",
"info": { "title": "Orders", "version": "2.1.0" },
"paths": {
"/benzene/invoke/orders:place": {
"post": {
"operationId": "ordersPlace",
"summary": "Invoke topic orders:place",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": { "$ref": "#/components/schemas/OrdersPlaceRequest" }
}
}
},
"responses": {
"200": { "description": "ok", "content": { "application/json": {
"schema": { "$ref": "#/components/schemas/OrdersPlaceResponse" } } } },
"400": { "description": "bad-request", "content": { "application/problem+json": {
"schema": { "$ref": "#/components/schemas/BenzeneProblem" } } } }
// ... one entry per failure status, ordered by HTTP code
}
}
}
},
"components": {
"schemas": {
// The RFC 9457 problem document a failure carries. `status` is RFC 9457's integer HTTP
// code; the Benzene status travels as `benzeneStatus`.
"BenzeneProblem": { "type": "object",
"properties": {
"type": { "type": "string", "format": "uri" }, "title": { "type": "string" },
"status": { "type": "integer" }, "detail": { "type": "string" },
"instance": { "type": "string" }, "benzeneStatus": { "type": "string" },
"errors": { "type": "array",
"items": { "$ref": "#/components/schemas/BenzeneError" } } },
"required": ["benzeneStatus", "status"] },
"BenzeneError": { "type": "object",
"properties": { "message": { "type": "string" }, "field": { "type": "string" },
"code": { "type": "string" } },
"required": ["message"] },
"OrdersPlaceRequest": { "type": "object", "properties": {
"sku": { "type": "string" }, "quantity": { "type": "integer" } },
"required": ["sku", "quantity"] },
"OrdersPlaceResponse": { "type": "object", "properties": {
"orderId": { "type": "string" } }, "required": ["orderId"] }
}
}
}
The payload schemas are exactly what benzene.core.json_schema emits — 2020-12 subset, wire-naming
(orderId) property names, required tracking the caller's obligation — and OpenAPI 3.1 adopts that
same dialect, so they drop in unchanged. The invoke base comes from benzene.http.StandardPaths; pass
server_paths=StandardPaths(prefix="/api") to relocate it.
Output is deterministic: topics are sorted by (id, version), paths and component-schema keys are
sorted lexicographically, and responses are ordered by HTTP code, so the same registry always yields an
identical, diff-friendly document. Pure — no broker, no third-party package. Mirrors .NET's
Benzene.Schema.OpenApi, and contributes the benzene.openapi subpackage to the shared benzene
namespace.
Metadata
Release files for benzene-openapi 0.1.0b2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| benzene_openapi-0.1.0b2.tar.gz | 7.7 kB | With provenance | Details for benzene_openapi-0.1.0b2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| benzene_openapi-0.1.0b2-py3-none-any.whl | Python 3 | none | any | Details for benzene_openapi-0.1.0b2-py3-none-any.whl |
Total release size: 17.0 kB
Release files / benzene_openapi-0.1.0b2.tar.gz
| Download URL | benzene_openapi-0.1.0b2.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ef91333eb123bc2fe279116fbb2517081e142998769a44b48484b6806e81e56
|
|
BLAKE2b-256 checksum How to use checksums |
8b91f67a31f8490c115a17d0a2ced812826a1043f593377601894d661c29a709
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / benzene_openapi-0.1.0b2-py3-none-any.whl
| Download URL | benzene_openapi-0.1.0b2-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ac3f91d48b211178496332d9148ddd2f5d52d7ccb53a48cddfe9b3cbfd126a2f
|
|
BLAKE2b-256 checksum How to use checksums |
83b8d63b9780bfa1b25ffd3971b9355f9c1dc3249fe53544b8245b22dab4be74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logSecurity for benzene-openapi 0.1.0b2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for benzene_openapi-0.1.0b2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.