openapi

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package openapi serves an OpenAPI specification and a Stoplight Elements docs site (interactive, with a "try it" console) from a single Register call. The Stoplight Elements assets are embedded in the framework, so a project ships only its generated spec — no per-project vendoring of the UI.

The Stoplight Elements distribution under assets/ is vendored from https://stoplight.io/open-source/elements (Apache-2.0), pinned at v9.0.0.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mux *http.ServeMux, spec []byte, opts ...Option) error

Register mounts the OpenAPI spec and the Stoplight Elements docs site onto the provided mux:

GET /openapi.yaml  -> the spec bytes
GET /docs/         -> the Stoplight UI (try-it console)

Serving both on the same server keeps the spec same-origin with the API it documents, so the "try it" console works without extra CORS configuration.

Types

type Option

type Option func(*config)

Option configures the docs endpoints.

func WithDocsPath

func WithDocsPath(p string) Option

WithDocsPath sets the path prefix the Stoplight UI is served at (default "/docs/"). It must end in a slash.

func WithSpecPath

func WithSpecPath(p string) Option

WithSpecPath sets the path the OpenAPI document is served at (default "/openapi.yaml").

func WithTitle

func WithTitle(t string) Option

WithTitle sets the docs page title.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL