engine

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 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        = "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

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

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

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

	// 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

Jump to

Keyboard shortcuts

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