api

package
v2.1.93 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceConfigFile is the name of the service configuration file within setup/
	ServiceConfigFile = "config.yml"
)

Variables

This section is empty.

Functions

func Discover

func Discover(opts DiscoverOptions) error

Discover scans the services directory and generates an imports file.

func GenerateService

func GenerateService(opts ServiceOptions) error

GenerateService generates all service files (types, handlers, register.go, middleware.go). If OutputDir is provided, creates the service directory structure including setup/. If run from an existing setup/ directory, uses that directory for configuration. The function:

  • Ensures setup directory exists with required files (creates if missing)
  • Generates types in <service>/types/
  • Generates handlers in <service>/handler/
  • Generates register.go in <service>/
  • Generates middleware.go in <service>/ (only if it doesn't exist)
  • Infers the service name from the directory name

func GenerateSpecFromStaticDir added in v2.1.72

func GenerateSpecFromStaticDir(staticDir, serviceName string) ([]byte, error)

GenerateSpecFromStaticDir generates an OpenAPI spec from a static files directory.

Types

type DiscoverOptions

type DiscoverOptions struct {
	// Optional: services directory to scan
	ServicesDir string

	// Optional: output file path (default: cmd/server/services_gen.go)
	OutputFile string
}

DiscoverOptions contains options for discovering services.

type Route

type Route struct {
	Method      string
	Path        string
	ContentType string
	Content     string
}

Route represents a static route with its content.

type ServiceOptions

type ServiceOptions struct {
	Name string // Optional: service name (default: inferred from directory name)

	// Optional: output directory for the service (default: current directory's parent)
	// When provided, setup dir will be <OutputDir>/setup/
	OutputDir string

	// Optional: path or URL to OpenAPI spec (default: openapi.yml/json in setup dir)
	SpecPath string

	// Optional: "openapi" or "static" (inferred from source if not provided)
	ServiceType string

	// Optional: maximum recursion depth for circular schemas
	MaxRecursionDepth int

	// Optional: maximum number of endpoints to process (0 = no limit, for debugging)
	MaxEndpoints int

	// Optional: path to custom codegen.yml to merge with template
	CodegenConfigPath string

	// Optional: path to custom config.yml to merge with template
	ServiceConfigPath string

	// Optional: suppress output messages (useful for automated tests)
	Quiet bool
}

ServiceOptions contains options for generating service files.

Jump to

Keyboard shortcuts

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