Documentation
¶
Overview ¶
nolint
nolint
nolint:gochecknoglobals
nolint
Index ¶
- Variables
- func ExtractGoComments(base string, rootPath string, commentMap map[string]string) error
- func GetFieldName(fieldType reflect.StructField) (string, bool)
- func GetNameAndRequiredFlag(field reflect.StructField) (string, bool)
- func NewProperties() *orderedmap.OrderedMap[string, *Schema]
- func SetProperties(field reflect.StructField, s *Schema)
- type CustomGenerator
- type Definitions
- type Generator
- type Id
- type Reflector
- type Schema
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TrueSchema = &Schema{boolean: &[]bool{true}[0]} FalseSchema = &Schema{boolean: &[]bool{false}[0]} )
View Source
var CustomGenerators = &customSchema{ mapSchema: make(map[string]CustomGenerator), }
nolint:gochecknoglobals
View Source
var Version = "v1"
Functions ¶
func ExtractGoComments ¶
ExtractGoComments reads all Go files in a given path and its subdirectories, extracting doc comments for exported types and their fields. `base` is the import path prefix to match the final FQNs.
func GetFieldName ¶
func GetFieldName(fieldType reflect.StructField) (string, bool)
func GetNameAndRequiredFlag ¶
func GetNameAndRequiredFlag(field reflect.StructField) (string, bool)
func NewProperties ¶
func NewProperties() *orderedmap.OrderedMap[string, *Schema]
func SetProperties ¶
func SetProperties(field reflect.StructField, s *Schema)
Types ¶
type CustomGenerator ¶
type CustomGenerator func(field reflect.StructField, s *Schema)
type Definitions ¶
type Generator ¶
type Generator struct {
Reflector *Reflector
}
func NewGenerator ¶
func NewGenerator() *Generator
type Reflector ¶
type Reflector struct {
BaseSchemaId Id
Anonymous bool
AssignAnchor bool
AllowAdditionalProperties bool
RequiredFromYamlSchemaTags bool
DoNotReference bool
ExpandedStruct bool
FieldNameReflector func(f reflect.StructField) (string, bool)
FieldReflector func(f reflect.StructField, s *Schema)
FieldNameTag string
IgnoredTypes []any
Lookup func(reflect.Type) Id
Mapper func(reflect.Type) *Schema
Namer func(reflect.Type) string
KeyNamer func(string) string
AdditionalFields func(reflect.Type) []reflect.StructField
CommentMap map[string]string
}
func (*Reflector) AddGoComments ¶
func (*Reflector) SetBaseSchemaId ¶
type Schema ¶
type Schema struct {
Version string `yaml:"$schema,omitempty"`
Id Id `yaml:"$id,omitempty"`
Anchor string `yaml:"$anchor,omitempty"`
Ref string `yaml:"$ref,omitempty"`
DynamicRef string `yaml:"$dynamicRef,omitempty"`
Definitions Definitions `yaml:"$defs,omitempty"`
Comments string `yaml:"$comment,omitempty"`
AllOf []*Schema `yaml:"allOf,omitempty"`
AnyOf []*Schema `yaml:"anyOf,omitempty"`
OneOf []*Schema `yaml:"oneOf,omitempty"`
Not *Schema `yaml:"not,omitempty"`
If *Schema `yaml:"if,omitempty"`
Then *Schema `yaml:"then,omitempty"`
Else *Schema `yaml:"else,omitempty"`
DependentSchemas map[string]*Schema `yaml:"dependentSchemas,omitempty"`
PrefixItems []*Schema `yaml:"prefixItems,omitempty"`
Items *Schema `yaml:"items,omitempty"`
Contains *Schema `yaml:"contains,omitempty"`
Properties *orderedmap.OrderedMap[string, *Schema] `yaml:"properties,omitempty"`
PatternProperties map[string]*Schema `yaml:"patternProperties,omitempty"`
AdditionalProperties *Schema `yaml:"additionalProperties,omitempty"`
PropertyNames *Schema `yaml:"propertyNames,omitempty"`
Type string `yaml:"type,omitempty"`
Enum []any `yaml:"enum,omitempty"`
Const any `yaml:"const,omitempty"`
MultipleOf *int64 `yaml:"multipleOf,omitempty"`
Maximum *int64 `yaml:"maximum,omitempty"`
ExclusiveMaximum *int64 `yaml:"exclusiveMaximum,omitempty"`
Minimum *int64 `yaml:"minimum,omitempty"`
ExclusiveMinimum *int64 `yaml:"exclusiveMinimum,omitempty"`
MaxLength *uint64 `yaml:"maxLength,omitempty"`
MinLength *uint64 `yaml:"minLength,omitempty"`
Pattern string `yaml:"pattern,omitempty"`
MaxItems *uint64 `yaml:"maxItems,omitempty"`
MinItems *uint64 `yaml:"minItems,omitempty"`
UniqueItems bool `yaml:"uniqueItems,omitempty"`
MaxContains *uint64 `yaml:"maxContains,omitempty"`
MinContains *uint64 `yaml:"minContains,omitempty"`
MaxProperties *uint64 `yaml:"maxProperties,omitempty"`
MinProperties *uint64 `yaml:"minProperties,omitempty"`
Secrets []string `yaml:"secrets,omitempty"`
Required []string `yaml:"required,omitempty"`
DependentRequired map[string][]string `yaml:"dependentRequired,omitempty"`
Format string `yaml:"format,omitempty"`
ContentEncoding string `yaml:"contentEncoding,omitempty"`
ContentMediaType string `yaml:"contentMediaType,omitempty"`
ContentSchema *Schema `yaml:"contentSchema,omitempty"`
Title string `yaml:"title,omitempty"`
Description string `yaml:"description,omitempty"`
Default any `yaml:"default,omitempty"`
Deprecated bool `yaml:"deprecated,omitempty"`
ReadOnly bool `yaml:"readOnly,omitempty"`
WriteOnly bool `yaml:"writeOnly,omitempty"`
Examples []any `yaml:"examples,omitempty"`
Extras map[string]any `yaml:"-"`
// contains filtered or unexported fields
}
func ReflectFromType ¶
func (*Schema) MarshalYAML ¶
func (*Schema) UnmarshalYAML ¶
Click to show internal directories.
Click to hide internal directories.