Documentation
¶
Overview ¶
Package openapi describes a reva deployment's HTTP surface as an OpenAPI document, built from the routes its services declared.
The routes alone already carry most of what a reader wants: which paths exist, which methods they answer, which parameters their patterns name, and which of them need credentials. A route that was given a router.Doc adds the rest - what it accepts, what it returns, and what it is for.
WebDAV is the one part that does not fit. OpenAPI names its operations in a fixed set of fields, and PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, REPORT, LOCK and UNLOCK are not among them, so those are reported on the path item as an extension rather than silently dropped. A route that matches every method cannot say which of them it serves, so its path item says that it matches every method instead.
Index ¶
Constants ¶
const Version = "3.1.0"
Version of the OpenAPI specification the document conforms to. 3.1 embeds JSON Schema as-is, which is what the reflected schemas already are.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Components ¶
type Components struct {
Schemas map[string]*Schema `json:"schemas,omitempty"`
SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes,omitempty"`
}
type Document ¶
type Document struct {
OpenAPI string `json:"openapi"`
Info Info `json:"info"`
Servers []Server `json:"servers,omitempty"`
Tags []Tag `json:"tags,omitempty"`
Paths map[string]*PathItem `json:"paths"`
Components Components `json:"components"`
}
Document is an OpenAPI document.
func From ¶
From builds the document describing the given routes, authenticated by the given schemes.
The schemes are the deployment's own, resolved from how its authentication is configured, so that what the document tells a client to send is what the server reads. Passing none leaves the document silent about authentication rather than guessing at it.
type Operation ¶
type Operation struct {
OperationID string `json:"operationId,omitempty"`
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Parameters []*Parameter `json:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses map[string]*Response `json:"responses,omitempty"`
Security []map[string][]string `json:"security,omitempty"`
}
type PathItem ¶
type PathItem struct {
Get *Operation `json:"get,omitempty"`
Put *Operation `json:"put,omitempty"`
Post *Operation `json:"post,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Options *Operation `json:"options,omitempty"`
Head *Operation `json:"head,omitempty"`
Patch *Operation `json:"patch,omitempty"`
Trace *Operation `json:"trace,omitempty"`
// Parameters shared by every operation of the path.
Parameters []*Parameter `json:"parameters,omitempty"`
// WebDAVMethods are the methods the path answers that OpenAPI has no field
// for. They are reported so that no method a service named is lost.
WebDAVMethods []string `json:"x-webdav-methods,omitempty"`
// AnyMethod is set when a route at the path matches every method. Its
// operations are then the usual ones OpenAPI names, and the path may
// answer others, WebDAV's among them, that are listed nowhere.
AnyMethod bool `json:"x-any-method,omitempty"`
}
PathItem holds the operations of one path.
type RequestBody ¶
type Schema ¶
type Schema = jsonschema.Schema
Schema is a JSON Schema. OpenAPI 3.1 embeds JSON Schema as it is, so the schemas reflected out of Go types need no translation.