types

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAtomic

func IsAtomic(s string) bool

IsAtomic returns true if s is an atomic type name.

Types

type Atomic

type Atomic string

Atomic represents primitive types: string, integer, boolean, float.

const (
	String  Atomic = "string"
	Integer Atomic = "integer"
	Boolean Atomic = "boolean"
	Float   Atomic = "float"
)

func (Atomic) Deps

func (a Atomic) Deps() []string

func (Atomic) Schema

func (a Atomic) Schema(_ Resolver) (*extv1.JSONSchemaProps, error)

type Custom

type Custom string

Custom represents a reference to a user-defined type. At parse time, this type is unvalidated - the name may not exist in the type registry. Resolution happens later when Schema() is called with a Resolver that has the custom types loaded. If the type doesn't exist, Schema() will return an error from the Resolver.

func (Custom) Deps

func (c Custom) Deps() []string

func (Custom) Schema

func (c Custom) Schema(r Resolver) (*extv1.JSONSchemaProps, error)

type Map

type Map struct {
	Value Type
}

Map represents a map type: map[string]V. we do not support non-string keys in maps.

func (Map) Deps

func (m Map) Deps() []string

func (Map) Schema

func (m Map) Schema(r Resolver) (*extv1.JSONSchemaProps, error)

type Object

type Object struct{}

Object represents a schemaless object with unknown fields preserved.

func (Object) Deps

func (Object) Deps() []string

func (Object) Schema

func (Object) Schema(_ Resolver) (*extv1.JSONSchemaProps, error)

type Resolver

type Resolver interface {
	// Resolve returns the OpenAPI schema for a custom type by name.
	// Returns an error if the type is not found.
	Resolve(name string) (*extv1.JSONSchemaProps, error)
}

Resolver resolves custom type names to their schemas. It is used by Type.Schema to look up user-defined types during schema generation.

type Slice

type Slice struct {
	Elem Type
}

Slice represents an array type: []T.

func (Slice) Deps

func (s Slice) Deps() []string

func (Slice) Schema

func (s Slice) Schema(r Resolver) (*extv1.JSONSchemaProps, error)

type Struct

type Struct struct {
	Fields map[string]Type
}

Struct represents an object with named fields.

func (Struct) Deps

func (s Struct) Deps() []string

func (Struct) Schema

func (s Struct) Schema(r Resolver) (*extv1.JSONSchemaProps, error)

type Type

type Type interface {
	// Deps returns the names of custom types this type depends on.
	// Used for topological sorting when loading custom types.
	// Returns nil for types with no dependencies (e.g., atomics).
	Deps() []string

	// Schema generates the OpenAPI JSONSchemaProps for this type.
	// The resolver is used to look up custom type schemas.
	Schema(Resolver) (*extv1.JSONSchemaProps, error)
}

Type represents a parsed SimpleSchema type that can provide dependencies and build OpenAPI schemas. Implementations include Atomic (primitives), Slice, Map (collections), Object, Struct, and Custom (user-defined types).

Jump to

Keyboard shortcuts

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