Documentation
¶
Index ¶
- Variables
- type EntityDecl
- func (d *EntityDecl) HasModelAnnotation() bool
- func (d *EntityDecl) HasParameterAnnotation() bool
- func (d *EntityDecl) HasResponseAnnotation() bool
- func (d *EntityDecl) Names() (name, goName string)
- func (d *EntityDecl) Obj() *types.TypeName
- func (d *EntityDecl) ObjType() types.Type
- func (d *EntityDecl) OperationIDs() (result []string)
- func (d *EntityDecl) ResponseNames() (name, goName string)
- type Options
- type ScanCtx
- func (s *ScanCtx) Debug() bool
- func (s *ScanCtx) DeclForType(t types.Type) (*EntityDecl, bool)
- func (s *ScanCtx) DescWithRef() bool
- func (s *ScanCtx) ExtraModels() iter.Seq2[*ast.Ident, *EntityDecl]
- func (s *ScanCtx) FindComments(pkg *packages.Package, name string) (*ast.CommentGroup, bool)
- func (s *ScanCtx) FindDecl(pkgPath, name string) (*EntityDecl, bool)
- func (s *ScanCtx) FindEnumValues(pkg *packages.Package, enumName string) (list []any, descList []string, _ bool)
- func (s *ScanCtx) FindModel(pkgPath, name string) (*EntityDecl, bool)
- func (s *ScanCtx) Meta() iter.Seq[parsers.MetaSection]
- func (s *ScanCtx) Models() iter.Seq2[*ast.Ident, *EntityDecl]
- func (s *ScanCtx) MoveExtraToModel(k *ast.Ident)
- func (s *ScanCtx) NumExtraModels() int
- func (s *ScanCtx) Operations() iter.Seq[parsers.ParsedPathContent]
- func (s *ScanCtx) Parameters() iter.Seq[*EntityDecl]
- func (s *ScanCtx) PkgForType(t types.Type) (*packages.Package, bool)
- func (s *ScanCtx) RefAliases() bool
- func (s *ScanCtx) Responses() iter.Seq[*EntityDecl]
- func (s *ScanCtx) Routes() iter.Seq[parsers.ParsedPathContent]
- func (s *ScanCtx) SetXNullableForPointers() bool
- func (s *ScanCtx) SkipExtensions() bool
- func (s *ScanCtx) TransparentAliases() bool
- type TypeIndex
- type TypeIndexOption
- func WithDebug(enabled bool) TypeIndexOption
- func WithExcludeDeps(excluded bool) TypeIndexOption
- func WithExcludePkgs(excluded []string) TypeIndexOption
- func WithExcludeTags(excluded map[string]bool) TypeIndexOption
- func WithIncludePkgs(included []string) TypeIndexOption
- func WithIncludeTags(included map[string]bool) TypeIndexOption
- func WithRefAliases(enabled bool) TypeIndexOption
- func WithTransparentAliases(enabled bool) TypeIndexOption
- func WithXNullableForPointers(enabled bool) TypeIndexOption
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrScanner = errors.New("codescan:scanner")
ErrScanner is the sentinel error for all errors originating from the scanner package.
Functions ¶
This section is empty.
Types ¶
type EntityDecl ¶
type EntityDecl struct {
Comments *ast.CommentGroup
Type *types.Named
Alias *types.Alias // added to supplement Named, after go1.22
Ident *ast.Ident
Spec *ast.TypeSpec
File *ast.File
Pkg *packages.Package
// contains filtered or unexported fields
}
func (*EntityDecl) HasModelAnnotation ¶
func (d *EntityDecl) HasModelAnnotation() bool
func (*EntityDecl) HasParameterAnnotation ¶
func (d *EntityDecl) HasParameterAnnotation() bool
func (*EntityDecl) HasResponseAnnotation ¶
func (d *EntityDecl) HasResponseAnnotation() bool
func (*EntityDecl) Names ¶
func (d *EntityDecl) Names() (name, goName string)
func (*EntityDecl) Obj ¶
func (d *EntityDecl) Obj() *types.TypeName
Obj returns the type name for the declaration defining the named type or alias t.
func (*EntityDecl) ObjType ¶
func (d *EntityDecl) ObjType() types.Type
func (*EntityDecl) OperationIDs ¶
func (d *EntityDecl) OperationIDs() (result []string)
func (*EntityDecl) ResponseNames ¶
func (d *EntityDecl) ResponseNames() (name, goName string)
type Options ¶
type Options struct {
Packages []string
InputSpec *spec.Swagger
ScanModels bool
WorkDir string
BuildTags string
ExcludeDeps bool
Include []string
Exclude []string
IncludeTags []string
ExcludeTags []string
SetXNullableForPointers bool
RefAliases bool // aliases result in $ref, otherwise aliases are expanded
TransparentAliases bool // aliases are completely transparent, never creating definitions
DescWithRef bool // allow overloaded descriptions together with $ref, otherwise jsonschema draft4 $ref predates everything
SkipExtensions bool // skip generating x-go-* vendor extensions in the spec
Debug bool // enable verbose debug logging during scanning
}
type ScanCtx ¶
type ScanCtx struct {
// contains filtered or unexported fields
}
func NewScanCtx ¶
func (*ScanCtx) DeclForType ¶
func (s *ScanCtx) DeclForType(t types.Type) (*EntityDecl, bool)
func (*ScanCtx) DescWithRef ¶
func (*ScanCtx) ExtraModels ¶
func (*ScanCtx) FindComments ¶
func (*ScanCtx) FindEnumValues ¶
func (*ScanCtx) MoveExtraToModel ¶
func (*ScanCtx) NumExtraModels ¶
func (*ScanCtx) Operations ¶
func (s *ScanCtx) Operations() iter.Seq[parsers.ParsedPathContent]
func (*ScanCtx) Parameters ¶
func (s *ScanCtx) Parameters() iter.Seq[*EntityDecl]
func (*ScanCtx) RefAliases ¶
func (*ScanCtx) SetXNullableForPointers ¶
func (*ScanCtx) SkipExtensions ¶
func (*ScanCtx) TransparentAliases ¶
type TypeIndex ¶
type TypeIndex struct {
AllPackages map[string]*packages.Package
Models map[*ast.Ident]*EntityDecl
ExtraModels map[*ast.Ident]*EntityDecl
Meta []parsers.MetaSection
Routes []parsers.ParsedPathContent
Operations []parsers.ParsedPathContent
Parameters []*EntityDecl
Responses []*EntityDecl
// contains filtered or unexported fields
}
func NewTypeIndex ¶
func NewTypeIndex(pkgs []*packages.Package, opts ...TypeIndexOption) (*TypeIndex, error)
type TypeIndexOption ¶
type TypeIndexOption func(*TypeIndex)
func WithDebug ¶
func WithDebug(enabled bool) TypeIndexOption
func WithExcludeDeps ¶
func WithExcludeDeps(excluded bool) TypeIndexOption
func WithExcludePkgs ¶
func WithExcludePkgs(excluded []string) TypeIndexOption
func WithExcludeTags ¶
func WithExcludeTags(excluded map[string]bool) TypeIndexOption
func WithIncludePkgs ¶
func WithIncludePkgs(included []string) TypeIndexOption
func WithIncludeTags ¶
func WithIncludeTags(included map[string]bool) TypeIndexOption
func WithRefAliases ¶
func WithRefAliases(enabled bool) TypeIndexOption
func WithTransparentAliases ¶
func WithTransparentAliases(enabled bool) TypeIndexOption
func WithXNullableForPointers ¶
func WithXNullableForPointers(enabled bool) TypeIndexOption
Click to show internal directories.
Click to hide internal directories.