simpleschema

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownMarker = errors.New("unknown marker")

ErrUnknownMarker is returned when an unrecognized marker is encountered.

Functions

func FromOpenAPISpec

func FromOpenAPISpec(schema *extv1.JSONSchemaProps) (map[string]interface{}, error)

FromOpenAPISpec converts an OpenAPI schema to a SimpleSchema object.

func ParseTypeString added in v0.8.5

func ParseTypeString(s string) (types.Type, error)

ParseTypeString parses the type portion of a field string (before any "|").

func ToOpenAPISpec

func ToOpenAPISpec(obj map[string]interface{}, customTypes map[string]interface{}) (*extv1.JSONSchemaProps, error)

ToOpenAPISpec converts a SimpleSchema object to an OpenAPI schema.

The first input obj is a map[string]interface{} where the key is the field name and the value is the field type.

The second input customTypes is a map[string]interface{} where the key is the type name and the value its specification. These custom types will be available as predefined types in the transformer.

Types

type Marker

type Marker struct {
	MarkerType MarkerType
	Key        string
	Value      string
}

Marker represents a marker found in the NeoCRD schema.

func ParseField added in v0.8.5

func ParseField(s string) (types.Type, []*Marker, error)

ParseField parses a field string like "[]string | required=true" into a Type and Markers.

func ParseMarkers added in v0.8.5

func ParseMarkers(markers string) ([]*Marker, error)

ParseMarkers parses a string of markers and returns a slice of Marker structs. The marker string should be in the format `marker=value`.

type MarkerType

type MarkerType string

MarkerType represents the type of marker that is found in the NeoCRD schema.

const (
	// MarkerTypeRequired represents the `required` marker.
	MarkerTypeRequired MarkerType = "required"
	// MarkerTypeDefault represents the `default` marker.
	MarkerTypeDefault MarkerType = "default"
	// MarkerTypeDescription represents the `description` marker.
	MarkerTypeDescription MarkerType = "description"
	// MarkerTypeMinimum represents the `minimum` marker.
	MarkerTypeMinimum MarkerType = "minimum"
	// MarkerTypeMaximum represents the `maximum` marker.
	MarkerTypeMaximum MarkerType = "maximum"
	// MarkerTypeValidation represents the `validation` marker.
	MarkerTypeValidation MarkerType = "validation"
	// MarkerTypeEnum represents the `enum` marker.
	MarkerTypeEnum MarkerType = "enum"
	// MarkerTypeImmutable represents the `immutable` marker.
	MarkerTypeImmutable MarkerType = "immutable"
	// MarkerTypePattern represents the `pattern` marker.
	MarkerTypePattern MarkerType = "pattern"
	// MarkerTypeUniqueItems represents the `uniqueItems` marker.
	MarkerTypeUniqueItems MarkerType = "uniqueItems"
	// MarkerTypeMinLength represents the `minLength` marker.
	MarkerTypeMinLength MarkerType = "minLength"
	// MarkerTypeMaxLength represents the `maxLength` marker.
	MarkerTypeMaxLength MarkerType = "maxLength"
	// MarkerTypeMinItems represents the `minItems` marker.
	MarkerTypeMinItems MarkerType = "minItems"
	// MarkerTypeMaxItems represents the `maxItems` marker.
	MarkerTypeMaxItems MarkerType = "maxItems"
	// MarkerTypeListType represents the `listType` marker.
	MarkerTypeListType MarkerType = "listType"
	// MarkerTypeListMapKey represents the `listMapKey` marker.
	MarkerTypeListMapKey MarkerType = "listMapKey"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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