Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
NewHandler creates a new http.HandlerFunc that produces an HTML-producing route, which uses Stoplight Elements' OpenAPI viewer for a given OpenAPI specification. Returns an error if the OpenAPI was invalid, or any errors are returned when trying to prepare the handler
Example ¶
rawSpec := `
openapi: 3.1.0
info:
version: 1.0.0
title: Example OpenAPI spec
paths: {}
`
loader := openapi3.NewLoader()
doc, err := loader.LoadFromData([]byte(rawSpec))
handler, err := NewHandler(doc, err)
if err != nil {
panic(err)
}
http.Handle("/docs", handler)
// then we'd usually strart the server, i.e:
// log.Fatal(http.ListenAndServe(":8080", nil))
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.