openapi

package
v1.11.9 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Components

func Components(routes []server.RouteMeta) map[string]*Schema

func Emit

func Emit(routes []server.RouteMeta, path, title string) ([]string, error)

Emit writes a fresh self-contained OpenAPI file; reconcile handles an existing one.

func Reconcile

func Reconcile(routes []server.RouteMeta, path, title string) ([]string, error)

Missing entries are added, hand-written ones kept with a warning, structural conflicts are errors. Prose is never touched.

Types

type Operation

type Operation struct {
	Method     string
	OpID       string
	Parameters []string
	PathParams []Param
	BodyRef    string
	Response   *Schema
}

type Param

type Param struct {
	Name     string  `yaml:"name"`
	In       string  `yaml:"in"`
	Required bool    `yaml:"required"`
	Schema   *Schema `yaml:"schema"`
}

type Schema

type Schema struct {
	Ref         string             `yaml:"$ref,omitempty"`
	Type        string             `yaml:"type,omitempty"`
	Format      string             `yaml:"format,omitempty"`
	Nullable    bool               `yaml:"nullable,omitempty"`
	Description string             `yaml:"description,omitempty"`
	Enum        []string           `yaml:"enum,omitempty"`
	Pattern     string             `yaml:"pattern,omitempty"`
	MinLength   *int               `yaml:"minLength,omitempty"`
	MaxLength   *int               `yaml:"maxLength,omitempty"`
	Minimum     *float64           `yaml:"minimum,omitempty"`
	Maximum     *float64           `yaml:"maximum,omitempty"`
	ExclMinimum *float64           `yaml:"exclusiveMinimum,omitempty"`
	ExclMaximum *float64           `yaml:"exclusiveMaximum,omitempty"`
	MinItems    *int               `yaml:"minItems,omitempty"`
	MaxItems    *int               `yaml:"maxItems,omitempty"`
	Items       *Schema            `yaml:"items,omitempty"`
	Properties  map[string]*Schema `yaml:"properties,omitempty"`
	AddProps    *Schema            `yaml:"additionalProperties,omitempty"`
	Required    []string           `yaml:"required,omitempty"`
	// A rule OpenAPI has no keyword for. Here rather than in the description
	// because the generator has to be able to correct it, and it can never
	// rewrite prose.
	Constraints []string `yaml:"x-constraints,omitempty"`
}

Schema is the structural subset the generator owns; prose fields are reconcile's.

func (Schema) MarshalYAML

func (s Schema) MarshalYAML() (any, error)

3.1 spells a nullable scalar `type: [T,"null"]`. Patched onto the encoded node: a second struct listing every field is one field silently dropped from the document the day somebody adds it here and not there.

type Spec

type Spec struct {
	Schemas map[string]*Schema
	Params  map[string]Param
	Paths   map[string][]Operation
}

func Build

func Build(routes []server.RouteMeta) (*Spec, []string)

Directories

Path Synopsis
Separate from openapi because it imports testing, which has no business in the graph of a package a server links.
Separate from openapi because it imports testing, which has no business in the graph of a package a server links.

Jump to

Keyboard shortcuts

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