openapi

package
v0.3.103-beta Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package openapi builds an OpenAPI 3.0.x document from gateway route registrations (ADR 0045).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Title       string `json:"title"`
	Version     string `json:"version"`
	Description string `json:"description,omitempty"`
}

Info is the OpenAPI top-level metadata block.

type Operation

type Operation struct {
	Summary   string              `json:"summary,omitempty"`
	Tags      []string            `json:"tags,omitempty"`
	Responses map[string]Response `json:"responses"`
}

Operation is one endpoint's summary + tags.

type PathItem

type PathItem struct {
	Get    *Operation `json:"get,omitempty"`
	Post   *Operation `json:"post,omitempty"`
	Put    *Operation `json:"put,omitempty"`
	Patch  *Operation `json:"patch,omitempty"`
	Delete *Operation `json:"delete,omitempty"`
}

PathItem holds the operations for one path.

type Response

type Response struct {
	Description string `json:"description"`
}

Response is a minimal default response entry; every operation advertises the standard JSON envelope.

type Spec

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

Spec accumulates route registrations and renders an OpenAPI 3.0.x document.

func New

func New(info Info) *Spec

New starts an empty spec with the given info.

func (*Spec) AddSecuritySchemes

func (s *Spec) AddSecuritySchemes()

AddSecuritySchemes declares that the spec carries the bearer auth scheme (used by both user sessions and integration tokens).

func (*Spec) Handler

func (s *Spec) Handler() http.Handler

Handler serves /openapi.json and a Swagger UI page at /swagger.

func (*Spec) JSON

func (s *Spec) JSON() ([]byte, error)

JSON renders the OpenAPI document.

func (*Spec) Register

func (s *Spec) Register(method, path, summary string, tags ...string)

Register adds one operation to the spec; after mounted routes are loaded, it annotates only those operations.

func (*Spec) RegisterMountedRoutes

func (s *Spec) RegisterMountedRoutes(routes []httpx.Route)

RegisterMountedRoutes adds every method-bearing route collected from the HTTP gateway.

func (*Spec) SetTagDescription

func (s *Spec) SetTagDescription(tag, description string)

SetTagDescription annotates a tag shown in the Swagger UI grouping.

Jump to

Keyboard shortcuts

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