Core
The root github.com/go-openapi/runtime package defines a small set of
interfaces shared by every other piece of the runtime.
Everything else โ client transport, server middleware pipeline โ is built on top of these.
Concepts
ProducerandConsumerare the codecs that map data structures to and from JSON, YAML, XML, byte streams, etc.- “Parameters bindings” is the machinery to serialize / deserialize OpenAPI request parameters as go types
- “Content negotiation” refers to the handling of the
Content-Typeheader to agree on a serialization and encoding format. - “Operation” is the OpenAPI term for “handler”, i.e. a unitary service invoked by a request
Module map
runtime ships as three Go modules, each with its own go.mod and dependencies.
| Module | Purpose |
|---|---|
github.com/go-openapi/runtime | Core interfaces, content-type codecs, client transport, full server middleware pipeline. Pulls in analysis, loads, spec, strfmt, validate. |
github.com/go-openapi/runtime/server-middleware | Standalone, dependency-free server middleware: media types, content negotiation, doc UIs. Usable from any plain net/http server. |
github.com/go-openapi/runtime/client-middleware/opentracing | Optional OpenTracing transport middleware (compatibility add-on โ new code should use the OpenTelemetry support built into client.Runtime). |
server-middlewarelets you reuse the negotiation and doc-UI primitives without inheriting the OpenAPI spec/loads/validate dependency tree.
Where the pieces fit
flowchart TD
cli["Application client code<br/>(models, โฆ)"]
app["Application server code<br/>(handlers, models, โฆ)"]
client[["client<br/>(transport)"]]
mw[["middleware<br/>(pipeline)"]]
sm[["server-middleware<br/>(standalone โ stdlib only)"]]
core{{"runtime<br/>core interfaces<br/>Consumer ยท Producer<br/>Authenticator ยท Authorizer<br/>OperationHandler ยท Validatable"}}
cli -- import --> client
app -- import --> mw
app --> sm
client --> core
mw --> core
mw -.-> sm
middlewarereuses theserver-middlewareprimitives (the dotted arrow): negotiation, media-type matching and the doc-UI handlers all live inserver-middleware.
Backward-compatibility note
The legacy entry points pre-existing in package
middlewarebefore v0.30.0 (NegotiateContentType,SwaggerUI, โฆ) are still available as a shim (middleware/seam.go) that now forwards to the new module โ see server / deprecated shims.
Read on for what each interface does, the built-in content-type codecs and the validation hooks.
- The five core interfaces โ Consumer, Producer, Authenticator, Authorizer, OperationHandler โ and where each one fires on the client and server sides.
- Built-in Consumer / Producer factories (JSON, XML, CSV, text, bytestream, YAML) and how to register your own.
- Validatable and ContextValidatable interfaces, when the runtime invokes them, and how they interact with spec-based validation.