Generates OpenAPI 3.1.0 discovery documents for MPP-enabled HTTP operations.
The input is a keyword list or map containing :info, :routes, and optional
:service_info. Routes with payment metadata emit x-payment-info and a 402
response; routes with payment: nil or no :payment key are unpaid and omit
both. Payment metadata may use either discovery form, but generated documents
always contain the recommended multi-offer offers array on payable operations.
MPP.Discovery.OpenApi.generate(
info: %{title: "Example API", version: "1.0.0"},
service_info: %{
"categories" => ["compute"],
"docs" => %{"homepage" => "https://example.com"}
},
routes: [
[method: :get, path: "/health"],
[
method: :post,
path: "/v1/search",
summary: "Search documents",
payment: %{
"intent" => "charge",
"method" => "tempo",
"amount" => "100",
"currency" => "usd"
}
]
]
)Invalid generation config raises ArgumentError so malformed discovery
documents fail at build time rather than being published.
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
generate | 1 | Generate an OpenAPI 3.1.0 document with MPP discovery extensions. | config: value |
Summary
Functions
Generate an OpenAPI 3.1.0 document with MPP discovery extensions.
Functions
Generate an OpenAPI 3.1.0 document with MPP discovery extensions.
Parameters
config- Keyword list or map withinfo, non-emptyroutes, and optionalservice_info(value)
Returns
JSON-compatible OpenAPI 3.1.0 document (map)
# descripex:contract
%{
params: %{
config: %{
description: "Keyword list or map with `info`, non-empty `routes`, and optional `service_info`",
kind: :value
}
},
returns: %{type: :map, description: "JSON-compatible OpenAPI 3.1.0 document"}
}