Documentation
¶
Overview ¶
Package openapi generates OpenAPI documents from Runa routes.
Index ¶
- func ApiKey(name string, in string, key string) route.Security
- func Basic(name string) route.Security
- func Bearer(name string) route.Security
- func ExportCommand(registry *Registry, routes *route.Registry) runacommand.Command
- func OAuth2(name string, flows OAuthFlows) route.Security
- func Provider(docs ...Config) provider.Provider
- type Components
- type Config
- type Document
- type Header
- type Info
- type Media
- type OAuthFlows
- type Operation
- type Option
- type Parameter
- type Registry
- func (registry *Registry) Config(name string) (Config, bool)
- func (registry *Registry) Document(name string, routes []*route.Route) (Document, bool)
- func (registry *Registry) JSONBytes(name string, routes []*route.Route) ([]byte, bool, error)
- func (registry *Registry) List() []Config
- func (registry *Registry) Mount(routes *route.Registry, name string, options ...Option) Config
- func (registry *Registry) MountConfig(routes *route.Registry, config Config) Config
- func (registry *Registry) Register(name string, options ...Option) Config
- func (registry *Registry) RegisterConfig(config Config) Config
- type RequestBody
- type Response
- type SecurityScheme
- type ServerInfo
- type Viewer
- type ViewerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportCommand ¶
func ExportCommand(registry *Registry, routes *route.Registry) runacommand.Command
ExportCommand creates an OpenAPI export command.
Types ¶
type Components ¶
type Components struct {
SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
}
Components stores reusable OpenAPI components.
type Config ¶
type Config struct {
Name string
Title string
Version string
Description string
Servers []ServerInfo
JSONPath string
UIPath string
Viewer Viewer
}
Config stores OpenAPI document domain config.
type Document ¶
type Document struct {
OpenAPI string `json:"openapi"`
Info Info `json:"info"`
Servers []ServerInfo `json:"servers,omitempty"`
Paths map[string]map[string]Operation `json:"paths"`
Components Components `json:"components,omitempty"`
}
Document is a minimal OpenAPI 3.1 document.
type Header ¶
type Header struct {
Description string `json:"description,omitempty"`
Schema *route.TypeSchema `json:"schema,omitempty"`
}
Header describes a response header.
type Info ¶
type Info struct {
Title string `json:"title"`
Version string `json:"version"`
Description string `json:"description,omitempty"`
}
Info describes the API.
type Media ¶
type Media struct {
Schema *route.TypeSchema `json:"schema,omitempty"`
}
Media describes media type content.
type Operation ¶
type Operation struct {
OperationID string `json:"operationId,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Security []map[string][]string `json:"security,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses map[string]Response `json:"responses"`
}
Operation describes an endpoint operation.
type Option ¶
type Option func(*Config)
Option configures an OpenAPI document domain.
type Parameter ¶
type Parameter struct {
Name string `json:"name"`
In string `json:"in"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Schema *route.TypeSchema `json:"schema,omitempty"`
}
Parameter describes an operation parameter.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores OpenAPI document domains.
func (*Registry) MountConfig ¶
MountConfig registers an OpenAPI config and mounts JSON/UI routes.
func (*Registry) RegisterConfig ¶
RegisterConfig registers a document domain from an already merged config.
type RequestBody ¶
type RequestBody struct {
Required bool `json:"required,omitempty"`
Content map[string]Media `json:"content"`
}
RequestBody describes an operation request body.
type Response ¶
type Response struct {
Description string `json:"description"`
Content map[string]Media `json:"content,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
}
Response describes an operation response.
type SecurityScheme ¶
type SecurityScheme struct {
Type string `json:"type"`
Scheme string `json:"scheme,omitempty"`
BearerFormat string `json:"bearerFormat,omitempty"`
In string `json:"in,omitempty"`
Name string `json:"name,omitempty"`
}
SecurityScheme describes a security scheme.
type ServerInfo ¶
type ServerInfo struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
}
ServerInfo describes an OpenAPI server.