Help us shape the future of Go! Take the 2026 Go Developer Survey

docspage

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package docspage renders the API reference page for an OpenAPI spec. Zinc uses it for the docs page every app serves, and middleware/apidocs for the page it serves, so the two can't drift apart.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(ui UI, spec, title, assetsURL string) ([]byte, error)

Render returns the page for ui, loading the spec from spec. A non-empty assetsURL serves the renderer's files from there instead of the CDN.

Types

type Asset

type Asset struct {
	// Name is the file name the page loads below Config.AssetsURL.
	Name string
	// URL is the pinned CDN URL the file comes from by default.
	URL string
	// Integrity is the file's Subresource Integrity hash.
	Integrity string
	// Stylesheet is true for CSS, false for JavaScript.
	Stylesheet bool
}

Asset is one file a renderer loads.

func Files

func Files(ui UI) []Asset

Files lists the files a renderer loads. It returns nil for an unknown UI.

type UI

type UI string

UI is a docs renderer.

const (
	Scalar    UI = "scalar"     // @scalar/api-reference 1.72.1, the default
	SwaggerUI UI = "swagger-ui" // swagger-ui-dist 5.33.0
	Stoplight UI = "stoplight"  // @stoplight/elements 9.0.25
	Redoc     UI = "redoc"      // redoc 2.5.4
)

The renderers. Each loads a pinned version from cdn.jsdelivr.net, with a Subresource Integrity hash.

Jump to

Keyboard shortcuts

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