schemamutation

package
v0.0.0-...-baa1f0e Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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

Jump to

Keyboard shortcuts

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