extractor

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractSchema

func ExtractSchema(fields map[string]any, types map[string]any) (*extv1.JSONSchemaProps, error)

ExtractSchema converts a field map using shorthand schema syntax into OpenAPI v3 JSON Schema.

This is the primary API for converting ComponentType/Trait schemas from the compact shorthand format into full JSON Schema that Kubernetes can validate against.

The shorthand syntax allows concise schema definitions:

  • Basic types: replicas: "integer"
  • With constraints: port: "integer | minimum=1 | maximum=65535"
  • With defaults: environment: "string | default=dev"
  • Arrays: tags: "[]string"
  • Maps: labels: "map<string>"
  • Custom types: database: "DatabaseConfig" (references types parameter)

The types parameter provides custom type definitions that can be referenced in field schemas. Fields are required by default unless they have a default value or explicit required=false marker.

Uses default options (required by default, unknown markers ignored).

func ExtractSchemaWithOptions

func ExtractSchemaWithOptions(fields map[string]any, types map[string]any, opts Options) (*extv1.JSONSchemaProps, error)

ExtractSchemaWithOptions converts a field map with custom extraction options.

Types

type Options

type Options struct {
	// RequiredByDefault determines whether fields without explicit 'required' or 'default'
	// markers are treated as required. Default: true.
	RequiredByDefault bool

	// ErrorOnUnknownMarkers causes parsing to fail when encountering unknown constraint markers.
	// Default: false (unknown markers are silently ignored).
	ErrorOnUnknownMarkers bool
}

Options configures schema extraction behavior.

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the default options for schema extraction.

Jump to

Keyboard shortcuts

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