script

package
v1.9.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertFieldError

func ConvertFieldError(err error) error

ConvertFieldError convert the cue error to the field error

func ConvertOpenAPISchema2SwaggerObject

func ConvertOpenAPISchema2SwaggerObject(data []byte) (*openapi3.Schema, error)

ConvertOpenAPISchema2SwaggerObject converts OpenAPI v2 JSON schema to Swagger Object

func Error added in v1.9.0

func Error(val cuelang.Value) error

Error return value's error information.

func FixOpenAPISchema

func FixOpenAPISchema(name string, schema *openapi3.Schema)

FixOpenAPISchema fixes tainted `description` filed, missing of title `field`.

Types

type CUE

type CUE string

CUE the cue script with the template format Like this: ------------ metadata: {}

template: {
	parameter: {}
	output: {}
}

------------

func BuildCUEScriptWithDefaultContext

func BuildCUEScriptWithDefaultContext(defaultContext []byte, content []byte) CUE

BuildCUEScriptWithDefaultContext build a cue script instance from a byte array.

func (CUE) MergeValues

func (c CUE) MergeValues(context interface{}, properties map[string]interface{}) (*value.Value, error)

MergeValues merge the input values to the cue script The context variables could be referenced in all fields. The parameter only could be referenced in the template area.

func (CUE) ParsePropertiesToSchema

func (c CUE) ParsePropertiesToSchema(templateFieldPath ...string) (*openapi3.Schema, error)

ParsePropertiesToSchema parse the properties in cue script to the openapi schema Read the template.parameter field

func (CUE) ParsePropertiesToSchemaWithCueX added in v1.9.0

func (c CUE) ParsePropertiesToSchemaWithCueX(templateFieldPath string) (*openapi3.Schema, error)

ParsePropertiesToSchemaWithCueX parse the properties in cue script to the openapi schema Read the template.parameter field

func (CUE) ParseToTemplateValue

func (c CUE) ParseToTemplateValue() (*value.Value, error)

ParseToTemplateValue parse the cue script to cue.Value. It must include a valid template.

func (CUE) ParseToTemplateValueWithCueX added in v1.9.0

func (c CUE) ParseToTemplateValueWithCueX() (cuelang.Value, error)

ParseToTemplateValueWithCueX parse the cue script to cue.Value. It must include a valid template.

func (CUE) ParseToValue

func (c CUE) ParseToValue() (*value.Value, error)

ParseToValue parse the cue script to cue.Value

func (CUE) ParseToValueWithCueX added in v1.9.0

func (c CUE) ParseToValueWithCueX() (cuelang.Value, error)

ParseToValueWithCueX parse the cue script to cue.Value

func (CUE) RunAndOutput

func (c CUE) RunAndOutput(context interface{}, properties map[string]interface{}, outputField ...string) (*value.Value, error)

RunAndOutput run the cue script and return the values of the specified field. The output field must be under the template field.

func (CUE) RunAndOutputWithCueX added in v1.9.0

func (c CUE) RunAndOutputWithCueX(ctx context.Context, context interface{}, properties map[string]interface{}, outputField ...string) (cuelang.Value, error)

RunAndOutputWithCueX run the cue script and return the values of the specified field. The output field must be under the template field.

func (CUE) ValidateProperties

func (c CUE) ValidateProperties(properties map[string]interface{}) error

ValidateProperties validate the input properties by the template

func (CUE) ValidatePropertiesWithCueX added in v1.9.0

func (c CUE) ValidatePropertiesWithCueX(properties map[string]interface{}) error

ValidatePropertiesWithCueX validate the input properties by the template

type ParameterError

type ParameterError struct {
	Name    string
	Message string
}

ParameterError the error report of the parameter field validation

func (*ParameterError) Error

func (e *ParameterError) Error() string

Error return the error message

Jump to

Keyboard shortcuts

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