scanner

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

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 NewScanCtx(opts *Options) (*ScanCtx, error)

func (*ScanCtx) Debug

func (s *ScanCtx) Debug() bool

func (*ScanCtx) DeclForType

func (s *ScanCtx) DeclForType(t types.Type) (*EntityDecl, bool)

func (*ScanCtx) DescWithRef

func (s *ScanCtx) DescWithRef() bool

func (*ScanCtx) ExtraModels

func (s *ScanCtx) ExtraModels() iter.Seq2[*ast.Ident, *EntityDecl]

func (*ScanCtx) FindComments

func (s *ScanCtx) FindComments(pkg *packages.Package, name string) (*ast.CommentGroup, bool)

func (*ScanCtx) FindDecl

func (s *ScanCtx) FindDecl(pkgPath, name string) (*EntityDecl, bool)

func (*ScanCtx) FindEnumValues

func (s *ScanCtx) FindEnumValues(pkg *packages.Package, enumName string) (list []any, descList []string, _ bool)

func (*ScanCtx) FindModel

func (s *ScanCtx) FindModel(pkgPath, name string) (*EntityDecl, bool)

func (*ScanCtx) Meta

func (s *ScanCtx) Meta() iter.Seq[parsers.MetaSection]

func (*ScanCtx) Models

func (s *ScanCtx) Models() iter.Seq2[*ast.Ident, *EntityDecl]

func (*ScanCtx) MoveExtraToModel

func (s *ScanCtx) MoveExtraToModel(k *ast.Ident)

func (*ScanCtx) NumExtraModels

func (s *ScanCtx) NumExtraModels() int

func (*ScanCtx) Operations

func (s *ScanCtx) Operations() iter.Seq[parsers.ParsedPathContent]

func (*ScanCtx) Parameters

func (s *ScanCtx) Parameters() iter.Seq[*EntityDecl]

func (*ScanCtx) PkgForType

func (s *ScanCtx) PkgForType(t types.Type) (*packages.Package, bool)

func (*ScanCtx) RefAliases

func (s *ScanCtx) RefAliases() bool

func (*ScanCtx) Responses

func (s *ScanCtx) Responses() iter.Seq[*EntityDecl]

func (*ScanCtx) Routes

func (s *ScanCtx) Routes() iter.Seq[parsers.ParsedPathContent]

func (*ScanCtx) SetXNullableForPointers

func (s *ScanCtx) SetXNullableForPointers() bool

func (*ScanCtx) SkipExtensions

func (s *ScanCtx) SkipExtensions() bool

func (*ScanCtx) TransparentAliases

func (s *ScanCtx) TransparentAliases() bool

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

Jump to

Keyboard shortcuts

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