engine

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package engine provides the core OpenAPI generation engine used by both the CLI and the generator package.

Index

Constants

View Source
const (
	// Default values for OpenAPI generation
	DefaultOutputFile         = "openapi.json"
	DefaultInputDir           = "."
	DefaultTitle              = "Generated API"
	DefaultAPIVersion         = "1.0.0"
	DefaultContactName        = "Ehab"
	DefaultContactURL         = "https://ehabterra.github.io/"
	DefaultContactEmail       = "[email protected]"
	DefaultOpenAPIVersion     = "3.1.1"
	DefaultMaxNodesPerTree    = 50000
	DefaultMaxChildrenPerNode = 500
	DefaultMaxArgsPerFunction = 100
	DefaultMaxNestedArgsDepth = 100
	DefaultMaxRecursionDepth  = 10
	DefaultMetadataFile       = "metadata.yaml"
	CopyrightNotice           = "apispec - Copyright 2025 Ehab Terra"
	LicenseNotice             = "Licensed under the Apache License 2.0. See LICENSE and NOTICE."
	FullLicenseNotice         = "\n\nCopyright 2025 Ehab Terra. 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 added in v0.3.0

func (e *Engine) GenerateMetadataOnly() (*metadata.Metadata, error)

GenerateOpenAPI generates an OpenAPI specification from the configured input directory 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 added in v0.3.0

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 added in v0.3.0

func (e *Engine) GetConfig() *EngineConfig

GetConfig returns the current engine configuration

func (*Engine) GetMetadata added in v0.3.0

func (e *Engine) GetMetadata() *metadata.Metadata

GetMetadata returns the current metadata

func (*Engine) ModuleRoot

func (e *Engine) ModuleRoot() string

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
	// 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 added in v0.3.0

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

VerboseLogger provides conditional logging based on verbose setting

func NewVerboseLogger added in v0.3.0

func NewVerboseLogger(verbose bool) *VerboseLogger

NewVerboseLogger creates a new verbose logger

func (*VerboseLogger) Print added in v0.3.0

func (vl *VerboseLogger) Print(args ...interface{})

Print prints output only if verbose is enabled

func (*VerboseLogger) Printf added in v0.3.0

func (vl *VerboseLogger) Printf(format string, args ...interface{})

Printf prints formatted output only if verbose is enabled

func (*VerboseLogger) Println added in v0.3.0

func (vl *VerboseLogger) Println(args ...interface{})

Println prints output only if verbose is enabled

Jump to

Keyboard shortcuts

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