gozod

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(mapper goToZodMapper, outputFileName string)

func GenerateString

func GenerateString(mapper goToZodMapper, outputFileName string) string

func NewMapper

func NewMapper(options ...Option) goToZodMapper

func NewMapperWithSupport

func NewMapperWithSupport(options ...Option) goToZodMapper

func SupportingDeclarations

func SupportingDeclarations(mapper goToZodMapper) ts.Source

func WithDiscriminatedUnion

func WithDiscriminatedUnion(t goinsp.GenType, discriminatorProperty string, types ...goinsp.Type) func(*config)

Types

type JSONDiscriminatedUnion

type JSONDiscriminatedUnion struct {
	DiscriminatorProperty string
	Types                 []goinsp.Type
}

type JSONDiscriminator

type JSONDiscriminator struct {
	Property string
	Value    string
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithCommentsLoader

func WithCommentsLoader(loader comments.Loader) Option

func WithDiscriminator

func WithDiscriminator(t goinsp.GenType, property, value string) Option

func WithName

func WithName(t goinsp.GenType, name string) Option

func WithResolvingSchema

func WithResolvingSchema(t goinsp.GenType, schema func(resolver Resolver[goinsp.Type, zod.ZodType]) zod.ZodType) Option

func WithResolvingTransform

func WithResolvingTransform(t goinsp.GenType, expr func(resolver Resolver[goinsp.Type, zod.ZodType]) ts.Source) Option

func WithSchema

func WithSchema(t goinsp.GenType, schema zod.ZodType) Option

func WithTemplate

func WithTemplate(t goinsp.GenType, template string) Option

func WithTransform

func WithTransform(t goinsp.GenType, expr ts.Source) Option

func WithUndiscriminatedUnion

func WithUndiscriminatedUnion(t goinsp.GenType, types ...goinsp.Type) Option

func WithUnnamedType

func WithUnnamedType(t goinsp.GenType) Option

type Resolver

type Resolver[A, B any] interface {
	Resolve(A) B
}

type TypeOptions

type TypeOptions struct {
	// contains filtered or unexported fields
}

func ForType

func ForType(t goinsp.GenType) TypeOptions

func When

func When[T any]() TypeOptions

func WhenGeneric

func WhenGeneric[T any]() TypeOptions

func (TypeOptions) Named

func (o TypeOptions) Named(name string) TypeOptions

func (TypeOptions) ResolvingSchema

func (o TypeOptions) ResolvingSchema(schema func(resolver Resolver[goinsp.Type, zod.ZodType]) zod.ZodType) TypeOptions

func (TypeOptions) ResolvingTransform

func (o TypeOptions) ResolvingTransform(f func(resolver Resolver[goinsp.Type, zod.ZodType]) ts.Source) TypeOptions

func (TypeOptions) Schema

func (o TypeOptions) Schema(schema zod.ZodType) TypeOptions

func (TypeOptions) Template

func (o TypeOptions) Template(template string) TypeOptions

func (TypeOptions) Transform

func (o TypeOptions) Transform(f ts.Source) TypeOptions

func (TypeOptions) Transformf

func (o TypeOptions) Transformf(format string, as ...any) TypeOptions

func (TypeOptions) UndiscriminatedUnionOf

func (o TypeOptions) UndiscriminatedUnionOf(disjuncts ...goinsp.Type) Option

func (TypeOptions) Unnamed

func (o TypeOptions) Unnamed() TypeOptions

Jump to

Keyboard shortcuts

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