Documentation
¶
Overview ¶
Package commands provides CLI command handlers for oastools.
Index ¶
- Constants
- func FormatSpecPath(specPath string) string
- func HandleConvert(args []string) error
- func HandleDiff(args []string) error
- func HandleFix(args []string) error
- func HandleGenerate(args []string) error
- func HandleJoin(args []string) error
- func HandleOverlay(args []string) error
- func HandleParse(args []string) error
- func HandleValidate(args []string) error
- func MapPrimaryOperationPolicy(policy string) joiner.PrimaryOperationPolicy
- func MarshalDocument(doc any, format parser.SourceFormat) ([]byte, error)
- func OutputSpecHeader(specPath, version string)
- func OutputSpecStats(sourceSize int64, stats parser.DocumentStats, loadTime any)
- func OutputStructured(data any, format string) error
- func ValidateCollisionStrategy(strategyName, value string) error
- func ValidateEquivalenceMode(value string) error
- func ValidateOutputFormat(format string) error
- func ValidateOutputPath(outputPath string, inputPaths []string) error
- func ValidatePrimaryOperationPolicy(policy string) error
- func Writef(w io.Writer, format string, args ...any)
- type ConvertFlags
- type DiffFlags
- type FixFlags
- type GenerateFlags
- type JoinFlags
- type OverlayApplyFlags
- type OverlayValidateFlags
- type ParseFlags
- type ValidateFlags
Constants ¶
const ( FormatText = "text" FormatJSON = "json" FormatYAML = "yaml" )
Output format constants
const StdinFilePath = "-"
StdinFilePath is the special file path used to indicate reading from stdin.
Variables ¶
This section is empty.
Functions ¶
func FormatSpecPath ¶ added in v1.30.1
FormatSpecPath returns a display-friendly path for the specification. Returns "<stdin>" if the path is StdinFilePath, otherwise returns the path as-is.
func HandleConvert ¶
HandleConvert executes the convert command
func HandleGenerate ¶
HandleGenerate executes the generate command
func HandleOverlay ¶ added in v1.24.0
HandleOverlay executes the overlay command
func HandleValidate ¶
HandleValidate executes the validate command
func MapPrimaryOperationPolicy ¶ added in v1.39.1
func MapPrimaryOperationPolicy(policy string) joiner.PrimaryOperationPolicy
MapPrimaryOperationPolicy maps a string policy to the joiner enum.
func MarshalDocument ¶
func MarshalDocument(doc any, format parser.SourceFormat) ([]byte, error)
MarshalDocument marshals a document to bytes in the specified format
func OutputSpecHeader ¶ added in v1.35.0
func OutputSpecHeader(specPath, version string)
OutputSpecHeader outputs the common specification header to stderr. This includes oastools version, specification path, and OAS version.
func OutputSpecStats ¶ added in v1.35.0
func OutputSpecStats(sourceSize int64, stats parser.DocumentStats, loadTime any)
OutputSpecStats outputs the common specification statistics to stderr. This includes source size, path count, operation count, schema count, and load time.
func OutputStructured ¶
OutputStructured outputs data in the specified format (json or yaml) to stdout. Returns an error if marshaling fails.
func ValidateCollisionStrategy ¶
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
ValidateEquivalenceMode validates an equivalence mode and returns an error if invalid.
func ValidateOutputFormat ¶
ValidateOutputFormat validates an output format and returns an error if invalid.
func ValidateOutputPath ¶
ValidateOutputPath checks if the output path is safe to write to
func ValidatePrimaryOperationPolicy ¶ added in v1.39.1
ValidatePrimaryOperationPolicy validates the primary operation policy flag value.
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 ¶
DiffFlags contains flags for the diff command
func SetupDiffFlags ¶
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
// Duplicate operationId fixing flags
FixDuplicateOperationIds bool
OperationIdTemplate string
OperationIdPathSep string
OperationIdTagSep string
// Stub missing refs flags
StubMissingRefs bool
StubResponseDesc string
// Dry run flag
DryRun bool
}
FixFlags contains flags for the fix command
func SetupFixFlags ¶
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
// Server generation options
ServerRouter string
ServerMiddleware bool
ServerBinder bool
ServerResponses bool
ServerStubs bool
ServerEmbedSpec bool
ServerAll 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
// Operation context configuration
OperationContext bool
PrimaryOperationPolicy string
// Overlay configuration
PreOverlays stringSliceFlag
PostOverlay string
}
JoinFlags contains flags for the join command
func SetupJoinFlags ¶
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
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
ValidateStructure bool
NoWarnings bool
Quiet bool
Format string
SourceMap bool
IncludeDocument 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.