commands

package
v1.28.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package commands provides CLI command handlers for oastools.

Index

Constants

View Source
const (
	FormatText = "text"
	FormatJSON = "json"
	FormatYAML = "yaml"
)

Output format constants

View Source
const StdinFilePath = "-"

StdinFilePath is the special file path used to indicate reading from stdin.

Variables

This section is empty.

Functions

func HandleConvert

func HandleConvert(args []string) error

HandleConvert executes the convert command

func HandleDiff

func HandleDiff(args []string) error

HandleDiff executes the diff command

func HandleFix

func HandleFix(args []string) error

HandleFix executes the fix command

func HandleGenerate

func HandleGenerate(args []string) error

HandleGenerate executes the generate command

func HandleJoin

func HandleJoin(args []string) error

HandleJoin executes the join command

func HandleOverlay added in v1.24.0

func HandleOverlay(args []string) error

HandleOverlay executes the overlay command

func HandleParse

func HandleParse(args []string) error

HandleParse executes the parse command

func HandleValidate

func HandleValidate(args []string) error

HandleValidate executes the validate command

func MarshalDocument

func MarshalDocument(doc any, format parser.SourceFormat) ([]byte, error)

MarshalDocument marshals a document to bytes in the specified format

func OutputStructured

func OutputStructured(data any, format string) error

OutputStructured outputs data in the specified format (json or yaml) to stdout. Returns an error if marshaling fails.

func ValidateCollisionStrategy

func ValidateCollisionStrategy(strategyName, value string) error

ValidateCollisionStrategy validates a collision strategy name and returns an error if invalid. The strategyName parameter is used in the error message (e.g., "path-strategy").

func ValidateEquivalenceMode added in v1.23.0

func ValidateEquivalenceMode(value string) error

ValidateEquivalenceMode validates an equivalence mode and returns an error if invalid.

func ValidateOutputFormat

func ValidateOutputFormat(format string) error

ValidateOutputFormat validates an output format and returns an error if invalid.

func ValidateOutputPath

func ValidateOutputPath(outputPath string, inputPaths []string) error

ValidateOutputPath checks if the output path is safe to write to

Types

type ConvertFlags

type ConvertFlags struct {
	Target     string
	Output     string
	Strict     bool
	NoWarnings bool
	Quiet      bool
	SourceMap  bool
}

ConvertFlags contains flags for the convert command

func SetupConvertFlags

func SetupConvertFlags() (*flag.FlagSet, *ConvertFlags)

SetupConvertFlags creates and configures a FlagSet for the convert command. Returns the FlagSet and a ConvertFlags struct with bound flag variables.

type DiffFlags

type DiffFlags struct {
	Breaking  bool
	NoInfo    bool
	Format    string
	SourceMap bool
}

DiffFlags contains flags for the diff command

func SetupDiffFlags

func SetupDiffFlags() (*flag.FlagSet, *DiffFlags)

SetupDiffFlags creates and configures a FlagSet for the diff command. Returns the FlagSet and a DiffFlags struct with bound flag variables.

type FixFlags

type FixFlags struct {
	Output    string
	Infer     bool
	Quiet     bool
	SourceMap bool

	// Schema name fixing flags
	FixSchemaNames        bool
	GenericNaming         string
	GenericSeparator      string
	GenericParamSeparator string
	PreserveCasing        bool

	// Pruning flags
	PruneSchemas bool
	PrunePaths   bool
	PruneAll     bool

	// Dry run flag
	DryRun bool
}

FixFlags contains flags for the fix command

func SetupFixFlags

func SetupFixFlags() (*flag.FlagSet, *FixFlags)

SetupFixFlags creates and configures a FlagSet for the fix command. Returns the FlagSet and a FixFlags struct with bound flag variables.

type GenerateFlags

type GenerateFlags struct {
	Output       string
	PackageName  string
	Client       bool
	Server       bool
	Types        bool
	NoPointers   bool
	NoValidation bool
	Strict       bool
	NoWarnings   bool
	SourceMap    bool

	// Security generation options
	NoSecurity      bool
	OAuth2Flows     bool
	CredentialMgmt  bool
	SecurityEnforce bool
	OIDCDiscovery   bool
	NoReadme        bool

	// File splitting options
	MaxLinesPerFile int
	MaxTypesPerFile int
	MaxOpsPerFile   int
	SplitByTag      bool
	NoSplitByTag    bool
	SplitByPath     bool
	NoSplitByPath   bool
}

GenerateFlags contains flags for the generate command

func SetupGenerateFlags

func SetupGenerateFlags() (*flag.FlagSet, *GenerateFlags)

SetupGenerateFlags creates and configures a FlagSet for the generate command. Returns the FlagSet and a GenerateFlags struct with bound flag variables.

type JoinFlags

type JoinFlags struct {
	Output            string
	PathStrategy      string
	SchemaStrategy    string
	ComponentStrategy string
	NoMergeArrays     bool
	NoDedupTags       bool
	Quiet             bool
	SourceMap         bool
	// Advanced collision strategies
	RenameTemplate  string
	EquivalenceMode string
	CollisionReport bool
	SemanticDedup   bool
	// Namespace prefix configuration
	NamespacePrefix namespacePrefixFlag
	AlwaysPrefix    bool
}

JoinFlags contains flags for the join command

func SetupJoinFlags

func SetupJoinFlags() (*flag.FlagSet, *JoinFlags)

SetupJoinFlags creates and configures a FlagSet for the join command. Returns the FlagSet and a JoinFlags struct with bound flag variables.

type OverlayApplyFlags added in v1.24.0

type OverlayApplyFlags struct {
	Spec   string
	Output string
	Strict bool
	Quiet  bool
}

OverlayApplyFlags contains flags for the overlay apply command

func SetupOverlayApplyFlags added in v1.24.0

func SetupOverlayApplyFlags() (*flag.FlagSet, *OverlayApplyFlags)

SetupOverlayApplyFlags creates and configures a FlagSet for the overlay apply command. Returns the FlagSet and an OverlayApplyFlags struct with bound flag variables.

type OverlayValidateFlags added in v1.24.0

type OverlayValidateFlags struct {
	Quiet bool
}

OverlayValidateFlags contains flags for the overlay validate command

func SetupOverlayValidateFlags added in v1.24.0

func SetupOverlayValidateFlags() (*flag.FlagSet, *OverlayValidateFlags)

SetupOverlayValidateFlags creates and configures a FlagSet for the overlay validate command. Returns the FlagSet and an OverlayValidateFlags struct with bound flag variables.

type ParseFlags

type ParseFlags struct {
	ResolveRefs       bool
	ResolveHTTPRefs   bool
	Insecure          bool
	ValidateStructure bool
	Quiet             bool
}

ParseFlags contains flags for the parse command

func SetupParseFlags

func SetupParseFlags() (*flag.FlagSet, *ParseFlags)

SetupParseFlags creates and configures a FlagSet for the parse command. Returns the FlagSet and a ParseFlags struct with bound flag variables.

type ValidateFlags

type ValidateFlags struct {
	Strict     bool
	NoWarnings bool
	Quiet      bool
	Format     string
	SourceMap  bool
}

ValidateFlags contains flags for the validate command

func SetupValidateFlags

func SetupValidateFlags() (*flag.FlagSet, *ValidateFlags)

SetupValidateFlags creates and configures a FlagSet for the validate command. Returns the FlagSet and a ValidateFlags struct with bound flag variables.

Jump to

Keyboard shortcuts

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