specs

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package specs provides OpenAPI registry utilities. EXPERIMENTAL: This package is not yet API-stable.

Index

Constants

View Source
const (
	// Health check endpoints
	Livez          = "/livez"
	Readyz         = "/readyz"
	Healthz        = "/healthz"
	Health         = "/health"
	HealthDetailed = "/health/detailed"

	// Documentation endpoints
	Docs        = "/docs"
	DocsOpenAPI = "/docs/openapi.json"
	DocsVersion = "/docs/version"
	DocsInfo    = "/docs/info"

	// System endpoints
	Version = "/version"

	// Metrics endpoint (Prometheus)
	Metrics = "/metrics"

	// Pprof endpoints for runtime profiling.
	PprofIndex   = "/debug/pprof/"
	PprofCmdline = "/debug/pprof/cmdline"
	PprofProfile = "/debug/pprof/profile"
	PprofSymbol  = "/debug/pprof/symbol"
	PprofTrace   = "/debug/pprof/trace"
)

System endpoints for health checks and documentation

Variables

View Source
var AllEndpoints = struct {
	Health interface{}
	Docs   interface{}
	System interface{}
}{
	Health: HealthEndpoints,
	Docs:   DocsEndpoints,
	System: SystemEndpoints,
}

AllEndpoints groups all available endpoints

View Source
var DocsEndpoints = struct {
	Docs    string
	OpenAPI string
	Version string
	Info    string
}{
	Docs:    Docs,
	OpenAPI: DocsOpenAPI,
	Version: DocsVersion,
	Info:    DocsInfo,
}

DocsEndpoints groups all documentation-related endpoints

View Source
var HealthEndpoints = struct {
	Livez          string
	Readyz         string
	Healthz        string
	Health         string
	HealthDetailed string
}{
	Livez:          Livez,
	Readyz:         Readyz,
	Healthz:        Healthz,
	Health:         Health,
	HealthDetailed: HealthDetailed,
}

HealthEndpoints groups all health-related endpoints

View Source
var PprofEndpoints = struct {
	Index   string
	Cmdline string
	Profile string
	Symbol  string
	Trace   string
}{
	Index:   PprofIndex,
	Cmdline: PprofCmdline,
	Profile: PprofProfile,
	Symbol:  PprofSymbol,
	Trace:   PprofTrace,
}

PprofEndpoints groups all profiling endpoints.

View Source
var SystemEndpoints = struct {
	Version string
}{
	Version: Version,
}

SystemEndpoints groups all system-related endpoints

Functions

This section is empty.

Types

type Info

type Info struct {
	Title       string
	Description string
	Version     string
}

Info describes OpenAPI metadata for a registry.

type Operation

type Operation struct {
	Method      string
	Path        string
	Summary     string
	Description string
	Tags        []string
	Deprecated  bool
	RequestBody *RequestBody
	Responses   map[int]Response
}

Operation describes an API operation for registry usage.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry collects operations and produces a minimal OpenAPI document.

func NewRegistry

func NewRegistry(info Info) *Registry

NewRegistry constructs an OpenAPI registry with the provided info.

func (*Registry) OpenAPI

func (r *Registry) OpenAPI() ([]byte, error)

OpenAPI returns a JSON-encoded OpenAPI 3.0 document.

func (*Registry) Register

func (r *Registry) Register(op Operation)

Register registers an operation in the registry.

func (*Registry) SetServers

func (r *Registry) SetServers(servers []Server)

SetServers replaces the server list.

type RegistryProvider

type RegistryProvider struct {
	// contains filtered or unexported fields
}

RegistryProvider adapts an OpenAPI registry to the DocsProvider interface.

func NewRegistryProvider

func NewRegistryProvider(registry *Registry, info ports.DocsInfo, openAPIPath string) *RegistryProvider

NewRegistryProvider creates a DocsProvider backed by a registry.

func (*RegistryProvider) GetHTML

func (p *RegistryProvider) GetHTML() (string, error)

GetHTML returns a basic Swagger UI page pointing at the registry OpenAPI JSON.

func (*RegistryProvider) GetInfo

func (p *RegistryProvider) GetInfo() ports.DocsInfo

GetInfo returns the registry info.

func (*RegistryProvider) GetOpenAPI

func (p *RegistryProvider) GetOpenAPI() ([]byte, error)

GetOpenAPI returns the JSON OpenAPI document from the registry.

func (*RegistryProvider) GetVersion

func (p *RegistryProvider) GetVersion() (string, error)

GetVersion returns the registry version.

type RequestBody

type RequestBody struct {
	Description  string
	Required     bool
	ContentTypes []string
}

RequestBody describes request content metadata.

type Response

type Response struct {
	Description  string
	ContentTypes []string
}

Response describes response content metadata.

type Server

type Server struct {
	URL         string
	Description string
}

Server describes an OpenAPI server entry.

Jump to

Keyboard shortcuts

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