Documentation
¶
Overview ¶
Package schema converts Go types (go/types) into an OpenAPI/JSON-Schema intermediate representation. The representation is version-neutral; the openapi package renders it for a concrete OpenAPI version.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstValue ¶
ConstValue converts a go/constant value into a Go scalar for enum lists.
func Key ¶
Key returns a stable structural key used to deduplicate schemas (e.g. when collecting the distinct response shapes for a status code).
func SortedEnum ¶
SortedEnum returns enum values in a stable order for deterministic output.
Types ¶
type Registry ¶
type Registry struct {
Components map[string]*Schema
Order []string // component names in insertion order
// Enums maps a type id ("pkgpath.Name") to its enumerated constant values.
Enums map[string][]any
// contains filtered or unexported fields
}
Registry collects named component schemas and converts types on demand.
type Schema ¶
type Schema struct {
Ref string
Type string // "string", "integer", "number", "boolean", "object", "array", ""
Format string
Items *Schema
Properties []*Property
Required []string
AdditionalProperties *Schema // nil + AdditionalAny=false => not set
AdditionalAny bool // additionalProperties: true (free-form object)
Enum []any
Nullable bool
Description string
OneOf []*Schema
}
Schema is a version-neutral schema node. Either Ref is set (a reference to a named component) or the inline fields describe the type.