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 ServiceSpec. 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 spec
and mesh descriptor read 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/json": {
"schema": { "$ref": "#/components/schemas/BenzeneError" } } } }
// ... one entry per failure status, ordered by HTTP code
}
}
}
},
"components": {
"schemas": {
"BenzeneError": { "type": "object",
"properties": { "status": { "type": "string" }, "detail": { "type": "string" } },
"required": ["status", "detail"] },
"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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file benzene_openapi-0.1.0b1.tar.gz.
File metadata
- Download URL: benzene_openapi-0.1.0b1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3af33226f78c6e6a5d2018cf05a6a582414a664477368c7d4911357451ec257f
|
|
| MD5 |
71d62464e9ea5b7496eb53149ca3bfb4
|
|
| BLAKE2b-256 |
b66047e2f62bb45a8baef3e6f570cc358b715f5f4160f032b3af1449ad8ba404
|
Provenance
The following attestation bundles were made for benzene_openapi-0.1.0b1.tar.gz:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_openapi-0.1.0b1.tar.gz -
Subject digest:
3af33226f78c6e6a5d2018cf05a6a582414a664477368c7d4911357451ec257f - Sigstore transparency entry: 2467247468
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file benzene_openapi-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: benzene_openapi-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c8c1f86b0bce224131b21a7c222e18ed6fb41d80ca1475a910839e43546d815
|
|
| MD5 |
1b274adc350bb1e0968c89fdd3fcbbe8
|
|
| BLAKE2b-256 |
feb65a2a78f10066c5d2747d08c381318f8917b4440a147f72ee3d3092c7d7fb
|
Provenance
The following attestation bundles were made for benzene_openapi-0.1.0b1-py3-none-any.whl:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_openapi-0.1.0b1-py3-none-any.whl -
Subject digest:
5c8c1f86b0bce224131b21a7c222e18ed6fb41d80ca1475a910839e43546d815 - Sigstore transparency entry: 2467225750
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type: