reflect

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyNameTag

func BodyNameTag(contentType string) string

func BoolTag

func BoolTag(value string) bool

func FloatTag

func FloatTag(value string) *float64

func ForEachField

func ForEachField(t reflect.Type, fn func(reflect.StructField))

func IgnoredField

func IgnoredField(field reflect.StructField, key string) bool

func IndirectType

func IndirectType(t reflect.Type) reflect.Type

func InferContentType added in v0.5.1

func InferContentType(value any) string

InferContentType inspects struct tags on value to determine request body content type. Returns "multipart/form-data" if any field tagged `form` holds a file type, "application/x-www-form-urlencoded" if any `form` tag is present, or "" otherwise.

func IntTag

func IntTag(value string) *int

func IsComponentType

func IsComponentType(t reflect.Type) bool

func IsOpenAPI30

func IsOpenAPI30(version string) bool

func IsTime

func IsTime(t reflect.Type) bool

func LowerCamel

func LowerCamel(value string) string

func NormalizeTagValue

func NormalizeTagValue(value any) any

func ParseTagValue

func ParseTagValue(value string) any

func ParseTagValues

func ParseTagValues(value string) []any

func ParseTypeTag

func ParseTypeTag(value string, version string) any

func SanitizeTypeName

func SanitizeTypeName(name string) string

func TagName

func TagName(field reflect.StructField, key string) string

Types

type OneOfValue

type OneOfValue interface {
	GetValues() []any
}

OneOfValue represents a reflected one-of union container.

type Reflector

type Reflector struct {
	Config      *openapi.Config
	Components  map[string]*openapi.Schema
	Names       map[reflect.Type]string
	Generating  map[reflect.Type]bool
	TypeMapping map[reflect.Type]reflect.Type
}

func NewReflector

func NewReflector(cfg *openapi.Config) *Reflector

func (*Reflector) ApplyExclusiveLimit

func (r *Reflector) ApplyExclusiveLimit(schema *openapi.Schema, tag reflect.StructTag, key string)

func (*Reflector) ApplyNullable

func (r *Reflector) ApplyNullable(schema *openapi.Schema, nullable bool)

func (*Reflector) ApplySchemaTags

func (r *Reflector) ApplySchemaTags(schema *openapi.Schema, field reflect.StructField)

func (*Reflector) ApplyXMLTags

func (r *Reflector) ApplyXMLTags(schema *openapi.Schema, tag reflect.StructTag)

func (*Reflector) InlineRefs

func (r *Reflector) InlineRefs() bool

func (*Reflector) ParameterField

func (r *Reflector) ParameterField(field reflect.StructField) (string, string, bool)

func (*Reflector) ParameterSchema

func (r *Reflector) ParameterSchema(field reflect.StructField, in, name string) *openapi.Parameter

func (*Reflector) RefSchema

func (r *Reflector) RefSchema(t reflect.Type) (*openapi.Schema, error)

func (*Reflector) RequestParts

func (r *Reflector) RequestParts(
	value any,
	ct string,
) ([]*openapi.Parameter, *openapi.Schema, error)

func (*Reflector) SchemaForType

func (r *Reflector) SchemaForType(
	t reflect.Type,
	mode SchemaMode,
	field *reflect.StructField,
) (*openapi.Schema, error)

func (*Reflector) SchemaForValue

func (r *Reflector) SchemaForValue(value any, mode SchemaMode) (*openapi.Schema, error)

func (*Reflector) SchemaFromTypeExposer

func (r *Reflector) SchemaFromTypeExposer(t reflect.Type) *openapi.Schema

func (*Reflector) SchemaFromValueExposer

func (r *Reflector) SchemaFromValueExposer(value any) *openapi.Schema

func (*Reflector) StripPrefixes

func (r *Reflector) StripPrefixes() []string

func (*Reflector) StructSchema

func (r *Reflector) StructSchema(
	t reflect.Type,
	nameTag string,
	onlyTagged bool,
	mode SchemaMode,
) (*openapi.Schema, error)

func (*Reflector) TypeName

func (r *Reflector) TypeName(t reflect.Type) string

type SchemaExposer

type SchemaExposer interface {
	OpenAPISchema(version string) *openapi.Schema
}

SchemaExposer lets a value provide an OpenAPI schema for a specific version.

type SchemaMode

type SchemaMode int
const (
	SchemaInline SchemaMode = iota
	SchemaUseComponent
)

type StaticSchemaExposer

type StaticSchemaExposer interface {
	OpenAPISchema() *openapi.Schema
}

StaticSchemaExposer lets a value provide a version-independent OpenAPI schema.

Jump to

Keyboard shortcuts

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