Documentation
¶
Index ¶
- Constants
- Variables
- func Print(w io.Writer, fn func(p Printer))
- func Unmarshal(data []byte, v any) error
- type Anchor
- type AnyType
- type ArrayType
- type BooleanType
- type CanSwaggerDoc
- type Core
- type Discriminator
- type EnumType
- type Ext
- type GoEnumValues
- type GoTaggedUnionType
- type GoUnionType
- type IntersectionType
- type Metadata
- type NullType
- type NumberType
- type ObjectType
- type OpenAPISchemaFormatGetter
- type OpenAPISchemaGetter
- type OpenAPISchemaTypeGetter
- type Payload
- type Printer
- type PrinterTo
- type Props
- func (p *Props) Delete(key string) (didDelete bool)
- func (p *Props) Get(key string) (Schema, bool)
- func (p Props) IsZero() bool
- func (p *Props) KeyValues() iter.Seq2[string, Schema]
- func (p *Props) Len() int
- func (p Props) MarshalJSONTo(encoder *jsontext.Encoder) error
- func (p *Props) Set(key string, value Schema) bool
- func (p *Props) UnmarshalJSONFrom(d *jsontext.Decoder) error
- type RefType
- type Schema
- type SchemaPrintOption
- type StringType
- type URI
- type URIRef
- type UnionType
- type ValidationSchema
Constants ¶
View Source
const ( XEnumLabels = `x-enum-labels` XGoType = `x-go-type` XGoVendorType = `x-go-vendor-type` XGoStarLevel = `x-go-star-level` XGoFieldName = `x-go-field-name` XTagValidate = `x-tag-validate` XPatternErrMsg = `x-pattern-err-msg` )
Variables ¶
View Source
var ( ErrInvalidJSONSchemaObject = errors.New("invalid json schema object") ErrInvalidJSONSchemaType = errors.New("invalid json schema type") )
Functions ¶
Types ¶
type Anchor ¶
type Anchor string
Anchor openapi:anchor
func (Anchor) OpenAPISchema ¶
func (*Anchor) UnmarshalText ¶
type ArrayType ¶
type BooleanType ¶
func Boolean ¶
func Boolean() *BooleanType
func (BooleanType) PrintTo ¶
func (BooleanType) PrintTo(w io.Writer, _ ...SchemaPrintOption)
type CanSwaggerDoc ¶
CanSwaggerDoc interface of k8s pkgs
type Core ¶
type Core struct {
// default https://json-schema.org/draft/2020-12/schema
Schema *URI `json:"$schema,omitzero"`
ID *URIRef `json:"$id,omitzero"`
Comment string `json:"$comment,omitzero"`
Vocabulary map[URI]bool `json:"$vocabulary,omitzero"`
// https://json-schema.org/understanding-json-schema/structuring#anchor
Anchor string `json:"$anchor,omitzero"`
// for generics type
// https://json-schema.org/blog/posts/dynamicref-and-generics
DynamicAnchor string `json:"$dynamicAnchor,omitzero"`
Defs map[string]Schema `json:"$defs,omitzero"`
}
type Discriminator ¶
type GoEnumValues ¶
type GoEnumValues interface {
EnumValues() []any
}
type GoTaggedUnionType ¶
type GoTaggedUnionType = validation.UnionType
type GoUnionType ¶
type GoUnionType interface {
OneOf() []any
}
type IntersectionType ¶
func AllOf ¶
func AllOf(schemas ...Schema) *IntersectionType
func (IntersectionType) PrintTo ¶
func (t IntersectionType) PrintTo(w io.Writer, options ...SchemaPrintOption)
type Metadata ¶
type Metadata struct {
Title string `json:"title,omitzero"`
Description string `json:"description,omitzero"`
Default any `json:"default,omitzero"`
WriteOnly *bool `json:"writeOnly,omitzero"`
ReadOnly *bool `json:"readOnly,omitzero"`
Examples []any `json:"examples,omitzero"`
Deprecated *bool `json:"deprecated,omitzero"`
Ext
}
func (*Metadata) DeepCopyInto ¶
func (*Metadata) GetMetadata ¶
type NumberType ¶
type NumberType struct {
Type string `json:"type,omitzero"`
// validate
MultipleOf *float64 `json:"multipleOf,omitzero"`
Maximum *float64 `json:"maximum,omitzero"`
ExclusiveMaximum *float64 `json:"exclusiveMaximum,omitzero"`
Minimum *float64 `json:"minimum,omitzero"`
ExclusiveMinimum *float64 `json:"exclusiveMinimum,omitzero"`
Core
Metadata
}
func (NumberType) PrintTo ¶
func (t NumberType) PrintTo(w io.Writer, optionFns ...SchemaPrintOption)
type ObjectType ¶
type ObjectType struct {
Type string `json:"type,omitzero"`
Properties Props `json:"properties,omitzero"`
PropertyNames Schema `json:"propertyNames,omitzero"`
AdditionalProperties Schema `json:"additionalProperties,omitzero"`
// validate
Required []string `json:"required,omitzero"`
MaxProperties *uint64 `json:"maxProperties,omitzero"`
MinProperties *uint64 `json:"minProperties,omitzero"`
Core
Metadata
}
func MapOf ¶
func MapOf(v Schema) *ObjectType
func RecordOf ¶
func RecordOf(k, v Schema) *ObjectType
func (ObjectType) PrintTo ¶
func (t ObjectType) PrintTo(w io.Writer, optionFns ...SchemaPrintOption)
func (*ObjectType) SetProperty ¶
func (t *ObjectType) SetProperty(name string, schema Schema, required bool)
type OpenAPISchemaFormatGetter ¶
type OpenAPISchemaFormatGetter interface {
OpenAPISchemaFormat() string
}
type OpenAPISchemaGetter ¶
type OpenAPISchemaGetter interface {
OpenAPISchema() Schema
}
type OpenAPISchemaTypeGetter ¶
type OpenAPISchemaTypeGetter interface {
OpenAPISchemaType() []string
}
type Payload ¶
type Payload struct {
Schema
}
func (Payload) MarshalJSON ¶
func (*Payload) UnmarshalJSON ¶
type PrinterTo ¶
type PrinterTo interface {
PrintTo(w io.Writer, optionFns ...SchemaPrintOption)
}
type RefType ¶
type Schema ¶
type Schema interface {
GetCore() *Core
GetMetadata() *Metadata
PrintTo(w io.Writer, options ...SchemaPrintOption)
}
type SchemaPrintOption ¶
type SchemaPrintOption func(o *printOption)
type StringType ¶
type StringType struct {
Type string `json:"type,omitzero"`
Format string `json:"format,omitzero"`
MaxLength *uint64 `json:"maxLength,omitzero"`
MinLength *uint64 `json:"minLength,omitzero"`
Pattern string `json:"pattern,omitzero"`
Core
Metadata
}
func Binary ¶
func Binary() *StringType
func Bytes ¶
func Bytes() *StringType
func String ¶
func String() *StringType
func (StringType) PrintTo ¶
func (t StringType) PrintTo(w io.Writer, _ ...SchemaPrintOption)
type URIRef ¶
URIRef uri-reference
func ParseURIRef ¶
func (URIRef) MarshalText ¶
func (*URIRef) UnmarshalText ¶
type UnionType ¶
type UnionType struct {
OneOf []Schema `json:"oneOf"`
Discriminator *Discriminator `json:"discriminator,omitzero"`
Core
Metadata
}
type ValidationSchema ¶
Click to show internal directories.
Click to hide internal directories.