internal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DescriptionAttr = "@description"
	TitleAttr       = "@title"
)

Variables

View Source
var StructFieldTypeMap = map[string]*SpecField{
	"string":    NewSpecField(StringType),
	"int":       NewSpecField(IntegerType),
	"float32":   NewSpecField(NumberType),
	"float64":   NewSpecField(NumberType),
	"bool":      NewSpecField(BooleanType),
	"time.Time": NewSpecFieldWithFormat(StringType, TimeFormat),
}

Functions

This section is empty.

Types

type CommentRegistry

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

func NewCommentRegistry

func NewCommentRegistry() *CommentRegistry

func (*CommentRegistry) Load

func (c *CommentRegistry) Load(pkgs ...*packages.Package)

Load loads struct as well as struct field comments and builds comment registry for given packages.

func (*CommentRegistry) Lookup

func (c *CommentRegistry) Lookup(key string) string

type MetadataParser

type MetadataParser struct {
}

func NewMetadataParser

func NewMetadataParser() *MetadataParser

func (*MetadataParser) ParseStructDesc

func (o *MetadataParser) ParseStructDesc(desc string) StructMetadata

type SpecField

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

func NewArraySpecField

func NewArraySpecField(itemsType SpecType) *SpecField

func NewSpecField

func NewSpecField(baseType SpecType) *SpecField

func NewSpecFieldWithFormat

func NewSpecFieldWithFormat(baseType SpecType, format string) *SpecField

func NewStructSpecField

func NewStructSpecField(ref string) *SpecField

func (*SpecField) BaseType

func (s *SpecField) BaseType() SpecType

func (*SpecField) IsValid

func (s *SpecField) IsValid() bool

func (*SpecField) SetFormat

func (s *SpecField) SetFormat(format string)

func (*SpecField) SetItemsType

func (s *SpecField) SetItemsType(itemsType SpecType)

func (*SpecField) SetRef

func (s *SpecField) SetRef(ref string)

func (*SpecField) ToSchemaProp

func (s *SpecField) ToSchemaProp(description string) spec.SchemaProps

type SpecType

type SpecType string
const (
	ArrayType   SpecType = "array"
	ObjectType  SpecType = "object"
	StructType  SpecType = "struct"
	BooleanType SpecType = "boolean"
	IntegerType SpecType = "integer"
	NumberType  SpecType = "number"
	StringType  SpecType = "string"

	TimeFormat = "RFC3339"
)

func (SpecType) String

func (s SpecType) String() string

type StructMetadata

type StructMetadata map[string]string

func (StructMetadata) Lookup

func (s StructMetadata) Lookup(key string, _default string) string

type TargetField

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

func NewTargetField

func NewTargetField(packageID string, structName string, fieldTag string, fieldName string) *TargetField

func (*TargetField) AdditionalProperties

func (t *TargetField) AdditionalProperties() *SpecField

func (*TargetField) CanonicalFieldName

func (t *TargetField) CanonicalFieldName(structTag string) string

func (*TargetField) Elem

func (t *TargetField) Elem() types.Type

func (*TargetField) HasAdditionalProperties

func (t *TargetField) HasAdditionalProperties() bool

func (*TargetField) ID

func (t *TargetField) ID() string

func (*TargetField) IsAdditionalProperties

func (t *TargetField) IsAdditionalProperties() bool

func (*TargetField) IsArrayType

func (t *TargetField) IsArrayType() bool

func (*TargetField) SetAdditionalProperties

func (t *TargetField) SetAdditionalProperties(additionalProperties *SpecField)

func (*TargetField) SetElem

func (t *TargetField) SetElem(elem types.Type)

func (*TargetField) SetIsAdditionalProperties

func (t *TargetField) SetIsAdditionalProperties()

func (*TargetField) SetIsArrayType

func (t *TargetField) SetIsArrayType()

func (*TargetField) SetSpecField

func (t *TargetField) SetSpecField(specField *SpecField)

func (*TargetField) SpecField

func (t *TargetField) SpecField() *SpecField

func (*TargetField) UnderlyingElem

func (t *TargetField) UnderlyingElem() types.Type

type TargetStruct

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

func NewTargetStruct

func NewTargetStruct(name string, origType types.Type, origStruct *types.Struct) *TargetStruct

func (*TargetStruct) ID

func (t *TargetStruct) ID() string

func (*TargetStruct) IsNamedType

func (t *TargetStruct) IsNamedType() bool

func (*TargetStruct) Name

func (t *TargetStruct) Name() string

func (*TargetStruct) OriginalStruct

func (t *TargetStruct) OriginalStruct() *types.Struct

func (*TargetStruct) OriginalType

func (t *TargetStruct) OriginalType() types.Type

func (*TargetStruct) ToNamedType

func (t *TargetStruct) ToNamedType() *types.Named

type TargetType

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

TargetType represents

func NewTargetType

func NewTargetType(name string, origObj types.Object) *TargetType

func (*TargetType) IsNamedType

func (t *TargetType) IsNamedType() bool

func (*TargetType) IsStruct

func (t *TargetType) IsStruct() bool

func (*TargetType) IsValid

func (t *TargetType) IsValid() bool

func (*TargetType) ToNamedType

func (t *TargetType) ToNamedType() *types.Named

func (*TargetType) ToTargetStruct

func (t *TargetType) ToTargetStruct() *TargetStruct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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