Documentation
¶
Overview ¶
Package openapi describes an app's HTTP routes as an OpenAPI 3.1 document.
Install New in InstalledApps to serve the document; nothing is served unless you do. Every route included in the registry is listed with its method, path, path parameters and name. A route can add detail with tango.Doc.
Index ¶
Constants ¶
const EnvVar = "TANGO_OPENAPI"
EnvVar is the environment variable Dev reads. Set it to a true value ("1", "true") to serve the document and the UI.
const Version = "3.1.0"
Version is the OpenAPI version of the documents this package writes.
Variables ¶
This section is empty.
Functions ¶
func Dev ¶
Dev is New for development: it serves the document and the UI only when the TANGO_OPENAPI environment variable is true, so a production process that does not set it exposes neither. `tango openapi` and `tango check` work either way, because they read the route table and serve nothing.
Types ¶
type Options ¶
type Options struct {
// Title is the API's name. Default "API".
Title string
// Version is the API's own version, not the OpenAPI version. Default "0.0.0".
Version string
// Description is shown under the title.
Description string
// Servers are base URLs such as "https://api.example.com".
Servers []string
// Path is where the JSON document is served. Default "/openapi.json".
Path string
// UI serves a browsable page for the document, such as swaggerui.New().
// Nil serves none.
UI UI
// UIPath is where the UI is served. Default "/docs/".
UIPath string
// ExcludePrefixes leaves out every route whose path starts with one of
// them, such as "/admin/" for pages that are not part of the API.
ExcludePrefixes []string
}
Options configures New and Document. The zero value is usable.