transformers

package
v1.76.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const XExtendKey = "x-extend"

XExtendKey is the OpenAPI extension key that signals schema inheritance. When present, the child schema is merged with the parent provided to Extend.

View Source
const XRequiredForHelm = "x-required-for-helm"

XRequiredForHelm is the OpenAPI extension key whose value is a field name or list of field names that must be present in the Helm values document.

Variables

This section is empty.

Functions

func Transform

func Transform(s *spec.Schema, transformers ...Transformer) *spec.Schema

Transform applies each Transformer in order to s, returning the final schema. Returns nil if s is nil.

Types

type AdditionalProperties

type AdditionalProperties struct {
	Parent *spec.Schema
}

AdditionalProperties is a Transformer that sets AdditionalProperties to false on every object schema node that does not already define it. This prevents values documents from containing undeclared keys that would otherwise pass validation silently.

func (*AdditionalProperties) Transform

func (t *AdditionalProperties) Transform(s *spec.Schema) *spec.Schema

Transform sets AdditionalProperties to false on s and recursively on every nested property and array item schema that has not already constrained it.

type Copy

type Copy struct{}

Copy is a Transformer that produces a deep clone of a schema via a JSON marshal/unmarshal round-trip. Used before mutations that must not affect the original schema object (e.g. before RequiredForHelm).

func (*Copy) Transform

func (t *Copy) Transform(s *spec.Schema) *spec.Schema

Transform returns a deep copy of s, leaving the original unmodified.

type Extend

type Extend struct {
	Parent *spec.Schema
}

Extend is a Transformer that merges a parent schema into the child schema when the child carries an x-extend extension. The child's own values take precedence over the parent's for all merged fields.

func (*Extend) Transform

func (t *Extend) Transform(s *spec.Schema) *spec.Schema

Transform merges the parent schema's definitions, extensions, required fields, properties, pattern properties, title, and description into s. A no-op when Parent is nil or x-extend is absent from s.

type ExtendSettings

type ExtendSettings struct {
	Schema *string `json:"schema,omitempty"`
}

ExtendSettings holds the parsed contents of an x-extend extension block. Schema names the parent schema document to inherit from (reserved for future multi-parent support; currently the parent is passed directly to Extend).

type RequiredForHelm

type RequiredForHelm struct{}

RequiredForHelm is a Transformer that promotes field names listed in the x-required-for-helm extension into the standard required array. This makes those fields mandatory at Helm rendering time even if they are optional in the regular values schema (e.g. fields that Helm templates always dereference).

func (*RequiredForHelm) Transform

func (t *RequiredForHelm) Transform(s *spec.Schema) *spec.Schema

Transform promotes x-required-for-helm values into required for the root schema and recursively for all nested object properties.

type Transformer

type Transformer interface {
	Transform(s *spec.Schema) *spec.Schema
}

Transformer mutates or replaces an OpenAPI spec.Schema, returning the result.

Jump to

Keyboard shortcuts

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