kube-openapik8s.io/kube-openapi/pkg/schemamutation Index | Files

package schemamutation

import "k8s.io/kube-openapi/pkg/schemamutation"

Index

Functions

func ReplaceReferences

func ReplaceReferences(walkRef func(ref *spec.Ref) *spec.Ref, sp *spec.Swagger) *spec.Swagger

ReplaceReferences rewrites the references without mutating the input. The output might share data with the input.

Types

type RefCallbackFunc

type RefCallbackFunc func(ref *spec.Ref) *spec.Ref
var RefCallbackNoop RefCallbackFunc = func(ref *spec.Ref) *spec.Ref {
	return ref
}

type SchemaCallbackFunc

type SchemaCallbackFunc func(schema *spec.Schema) *spec.Schema
var SchemaCallBackNoop SchemaCallbackFunc = func(schema *spec.Schema) *spec.Schema {
	return schema
}

type Walker

type Walker struct {
	// SchemaCallback will be called on each schema, taking the original schema,
	// and before any other callbacks of the Walker.
	// If the schema needs to be mutated, DO NOT mutate it in-place,
	// always create a copy, mutate, and return it.
	SchemaCallback func(schema *spec.Schema) *spec.Schema

	// RefCallback will be called on each ref.
	// If the ref needs to be mutated, DO NOT mutate it in-place,
	// always create a copy, mutate, and return it.
	RefCallback func(ref *spec.Ref) *spec.Ref
}

Walker runs callback functions on all references of an OpenAPI spec, replacing the values when visiting corresponding types.

func (*Walker) WalkRoot

func (w *Walker) WalkRoot(swagger *spec.Swagger) *spec.Swagger

func (*Walker) WalkSchema

func (w *Walker) WalkSchema(schema *spec.Schema) *spec.Schema

Source Files

walker.go

Version
v0.0.0-20250318190949-c8a335a9a2ff (latest)
Published
Mar 18, 2025
Platform
linux/amd64
Imports
1 packages
Last checked
4 weeks ago

Tools for package owners.