Documentation
¶
Overview ¶
Package engine provides the core OpenAPI generation engine used by both the CLI and the generator package.
Index ¶
- Constants
- type Engine
- func (e *Engine) GenerateMetadataOnly() (*metadata.Metadata, error)
- func (e *Engine) GenerateMetadataOnlyWithLogger(logger *VerboseLogger) (*metadata.Metadata, error)
- func (e *Engine) GenerateOpenAPI() (*spec.OpenAPISpec, error)
- func (e *Engine) GetConfig() *EngineConfig
- func (e *Engine) GetMetadata() *metadata.Metadata
- func (e *Engine) ModuleRoot() string
- type EngineConfig
- type VerboseLogger
Constants ¶
const ( // Default values for OpenAPI generation DefaultOutputFile = "openapi.json" DefaultInputDir = "." DefaultTitle = "Generated API" DefaultAPIVersion = "1.0.0" DefaultContactName = "Anton Starikov" DefaultContactURL = "https://github.com/antst/go-apispec" DefaultContactEmail = "antst@gmail.com" DefaultOpenAPIVersion = "3.1.1" DefaultMaxNodesPerTree = 50000 DefaultMaxChildrenPerNode = 500 DefaultMaxArgsPerFunction = 100 DefaultMaxNestedArgsDepth = 100 DefaultMaxRecursionDepth = 10 DefaultMetadataFile = "metadata.yaml" CopyrightNotice = "go-apispec - Copyright 2025 Ehab Terra, 2025-2026 Anton Starikov" LicenseNotice = "Licensed under the Apache License 2.0. See LICENSE and NOTICE." )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine represents the OpenAPI generation engine
func NewEngine ¶
func NewEngine(config *EngineConfig) *Engine
NewEngine creates a new Engine with the given configuration
func (*Engine) GenerateMetadataOnly ¶
GenerateMetadataOnly generates only metadata and call graph without OpenAPI spec. This is useful for diagram servers and other tools that only need the call graph.
func (*Engine) GenerateMetadataOnlyWithLogger ¶
func (e *Engine) GenerateMetadataOnlyWithLogger(logger *VerboseLogger) (*metadata.Metadata, error)
GenerateMetadataOnlyWithLogger generates only metadata and call graph without OpenAPI spec with a custom logger
func (*Engine) GenerateOpenAPI ¶
func (e *Engine) GenerateOpenAPI() (*spec.OpenAPISpec, error)
func (*Engine) GetConfig ¶
func (e *Engine) GetConfig() *EngineConfig
GetConfig returns the current engine configuration
func (*Engine) GetMetadata ¶
GetMetadata returns the current metadata
func (*Engine) ModuleRoot ¶
type EngineConfig ¶
type EngineConfig struct {
InputDir string
OutputFile string
Title string
APIVersion string
Description string
TermsOfService string
ContactName string
ContactURL string
ContactEmail string
LicenseName string
LicenseURL string
OpenAPIVersion string
ConfigFile string
APISpecConfig *spec.APISpecConfig // Direct config object (takes precedence over ConfigFile)
OutputConfig string
WriteMetadata bool
SplitMetadata bool
DiagramPath string
PaginatedDiagram bool
DiagramPageSize int
MaxNodesPerTree int
MaxChildrenPerNode int
MaxArgsPerFunction int
MaxNestedArgsDepth int
MaxRecursionDepth int
// Include/exclude filters
IncludeFiles []string
IncludePackages []string
IncludeFunctions []string
IncludeTypes []string
ExcludeFiles []string
ExcludePackages []string
ExcludeFunctions []string
ExcludeTypes []string
SkipCGOPackages bool
AnalyzeFrameworkDependencies bool
AutoIncludeFrameworkPackages bool
// SkipHTTPFramework excludes net/http from framework dependency analysis
SkipHTTPFramework bool
// Auto-exclude common test files and folders (e.g., *_test.go, tests/)
AutoExcludeTests bool
// Auto-exclude common mock files and folders (e.g., *_mock.go, mocks/)
AutoExcludeMocks bool
// Verbose output control
Verbose bool
// Output naming: use short names for operationIds and schema names.
// ShortNamesSet indicates the CLI flag was explicitly provided.
ShortNames bool
ShortNamesSet bool
// contains filtered or unexported fields
}
EngineConfig holds configuration for the OpenAPI generation engine
func DefaultEngineConfig ¶
func DefaultEngineConfig() *EngineConfig
DefaultEngineConfig returns a new EngineConfig with default values
type VerboseLogger ¶
type VerboseLogger struct {
// contains filtered or unexported fields
}
VerboseLogger provides conditional logging based on verbose setting
func NewVerboseLogger ¶
func NewVerboseLogger(verbose bool) *VerboseLogger
NewVerboseLogger creates a new verbose logger
func (*VerboseLogger) Print ¶
func (vl *VerboseLogger) Print(args ...interface{})
Print prints output only if verbose is enabled
func (*VerboseLogger) Printf ¶
func (vl *VerboseLogger) Printf(format string, args ...interface{})
Printf prints formatted output only if verbose is enabled
func (*VerboseLogger) Println ¶
func (vl *VerboseLogger) Println(args ...interface{})
Println prints output only if verbose is enabled