Documentation
¶
Overview ¶
Package transform provides in-place, document-aware OpenAPI transformations.
The package operates directly on YAML node trees so retained ordering, scalar style, comments, and extension fields are preserved.
Index ¶
- func HasReachableOperations(root *yaml.Node, specVersion string) bool
- func Transform(root *yaml.Node, specVersion string, options Options) (FilterStats, PruneStats, error)
- func ValidateBundled(root *yaml.Node) error
- func ValidateTagFilterOptions(options TagFilterOptions) error
- type ComponentGraph
- type ComponentID
- type FilterStats
- type MatchStrategy
- type Options
- type PruneStats
- type TagFilterOptions
- type Warning
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasReachableOperations ¶
HasReachableOperations reports whether at least one operation is reachable from the document's Paths or Webhooks Objects. Unreferenced reusable Path Items and Callbacks are not publication roots.
func Transform ¶
func Transform(root *yaml.Node, specVersion string, options Options) (FilterStats, PruneStats, error)
Transform filters operations and prunes unused components with one YAML preparation and bundled-reference validation pass. Standalone filter and prune entry points use this same path.
func ValidateBundled ¶
ValidateBundled rejects document references whose URI portion is external. Runtime URLs such as Example Object externalValue values are ignored.
func ValidateTagFilterOptions ¶
func ValidateTagFilterOptions(options TagFilterOptions) error
ValidateTagFilterOptions checks the tag match strategy and rejects blank tags.
Types ¶
type ComponentGraph ¶
type ComponentGraph struct {
// contains filtered or unexported fields
}
ComponentGraph is a read-only reachability graph for reusable components.
func BuildComponentGraph ¶
func BuildComponentGraph(root *yaml.Node, specVersion string) (*ComponentGraph, error)
BuildComponentGraph validates local component references and builds a graph whose roots are references made by the retained, non-component document.
func (*ComponentGraph) Unreachable ¶
func (g *ComponentGraph) Unreachable() []ComponentID
Unreachable returns registered components not reachable from document roots.
type ComponentID ¶
ComponentID uniquely identifies a reusable OpenAPI component.
type FilterStats ¶
type FilterStats struct {
OperationsSeen int
OperationsKept int
OperationsRemoved int
PathItemsRemoved int
WebhooksRemoved int
CallbackItemsRemoved int
Warnings []Warning
}
FilterStats summarizes inclusive operation filtering.
func FilterOperationsByTags ¶
func FilterOperationsByTags(root *yaml.Node, specVersion string, options TagFilterOptions) (FilterStats, error)
FilterOperationsByTags keeps only operations matching the inclusive tag allow-list. An empty allow-list is a no-op.
type MatchStrategy ¶
type MatchStrategy string
MatchStrategy controls how operation tags are compared with included tags.
const ( // MatchAny keeps an operation containing at least one included tag. MatchAny MatchStrategy = "any" // MatchAll keeps an operation containing every included tag. MatchAll MatchStrategy = "all" )
type Options ¶
type Options struct {
TagFilter TagFilterOptions
PruneUnused bool
}
Options selects publication transforms. Filtering runs before pruning so only components reachable from retained operations remain.
type PruneStats ¶
type PruneStats struct {
ComponentsSeen int
ComponentsKept int
ComponentsRemoved int
RemovedBySection map[string]int
// contains filtered or unexported fields
}
PruneStats summarizes component reachability pruning.
func PruneUnusedComponents ¶
func PruneUnusedComponents(root *yaml.Node, specVersion string) (PruneStats, error)
PruneUnusedComponents removes every reusable component that is unreachable from retained non-component document content.
type TagFilterOptions ¶
type TagFilterOptions struct {
IncludeTags []string
MatchStrategy MatchStrategy
}
TagFilterOptions configures inclusive operation filtering.
type Warning ¶
Warning describes a non-fatal publication problem found by a transform.
func RetainWarningsForPrunedDocument ¶
func RetainWarningsForPrunedDocument(warnings []Warning, prune PruneStats) []Warning
RetainWarningsForPrunedDocument removes warnings owned by components that were deleted by the supplied prune operation.