openapi

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package openapi exposes the embedded OpenAPI spec for runtime documentation lookups, e.g., the `cub <entity> explain` commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schema

type Schema struct {
	Description          string             `yaml:"description"`
	Type                 string             `yaml:"type"`
	Format               string             `yaml:"format"`
	Enum                 []string           `yaml:"enum"`
	Properties           map[string]*Schema `yaml:"properties"`
	Items                *Schema            `yaml:"items"`
	AdditionalProperties *Schema            `yaml:"additionalProperties"`
	Ref                  string             `yaml:"$ref"`
	AllOf                []*Schema          `yaml:"allOf"`
	AnyOf                []*Schema          `yaml:"anyOf"`
	OneOf                []*Schema          `yaml:"oneOf"`
	ReadOnly             bool               `yaml:"readOnly"`
	Nullable             bool               `yaml:"nullable"`
	Required             []string           `yaml:"required"`
	Pattern              string             `yaml:"pattern"`
	Example              any                `yaml:"example"`
}

Schema is a minimal projection of an OpenAPI schema, sufficient for surfacing human-readable property documentation.

func LookupSchema

func LookupSchema(name string) (*Schema, error)

LookupSchema returns the named top-level schema from the embedded OpenAPI spec. The error indicates either a parse failure or an unknown schema name.

func Resolve added in v0.8.8

func Resolve(s *Schema) *Schema

Resolve returns the schema s stands for: the one its $ref names, or its allOf's one member names, followed until it is neither. A reference to a schema the spec does not have resolves to nil. The result is shared, and must not be modified.

func (*Schema) PropertyNames

func (s *Schema) PropertyNames() []string

PropertyNames returns the names of a schema's properties in sorted order.

func (*Schema) RefName

func (s *Schema) RefName() string

RefName returns the last segment of a $ref pointer (e.g., "#/components/schemas/UpdateType" -> "UpdateType"), or "" if the schema is not a reference. A property that references a schema and also has a description or readOnly of its own is written as an allOf of that one $ref, since siblings of a $ref are ignored, so that form names the schema too.

Directories

Path Synopsis
Package goclientnew provides primitives to interact with the openapi HTTP API.
Package goclientnew provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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