Documentation ¶
Index ¶
- Variables
- func ErrorsToString(errs []gojsonschema.ResultError) (ret string)
- func ValidateRequest(ctx context.Context, schema *proto.Schema, action *proto.Action, input any) (*gojsonschema.Result, error)
- type Components
- type JSONSchema
- func JSONSchemaForActionInput(ctx context.Context, schema *proto.Schema, action *proto.Action) JSONSchema
- func JSONSchemaForActionResponse(ctx context.Context, schema *proto.Schema, action *proto.Action) JSONSchema
- func JSONSchemaForMessage(ctx context.Context, schema *proto.Schema, action *proto.Action, ...) JSONSchema
- func ValidateResponse(ctx context.Context, schema *proto.Schema, action *proto.Action, response any) (JSONSchema, *gojsonschema.Result, error)
- type RelaxedDateFormatChecker
Constants ¶
This section is empty.
Variables ¶
View Source
var (
AnyTypes = []string{"string", "object", "array", "integer", "number", "boolean", "null"}
)
Functions ¶
func ErrorsToString ¶
func ErrorsToString(errs []gojsonschema.ResultError) (ret string)
func ValidateRequest ¶
func ValidateRequest(ctx context.Context, schema *proto.Schema, action *proto.Action, input any) (*gojsonschema.Result, error)
ValidateRequest validates that the input is valid for the given action and schema. If validation errors are found they will be contained in the returned result. If an error is returned then validation could not be completed, likely to do an invalid JSON schema being created.
Types ¶
type Components ¶
type Components struct {
Schemas map[string]JSONSchema `json:"schemas"`
}
type JSONSchema ¶
type JSONSchema struct { // Type is generally just a string, but when we need a type to be // null it is a list containing the type and the string "null". // In JSON output for most cases we just want a string, not a list // of one string, so we use any here so it can be either Type any `json:"type,omitempty"` // The enum field needs to be able to contains strings and null, // so we use *string here Enum []*string `json:"enum,omitempty"` // Validation for strings Format string `json:"format,omitempty"` // Validation for objects Properties map[string]JSONSchema `json:"properties,omitempty"` AdditionalProperties *bool `json:"additionalProperties,omitempty"` UnevaluatedProperties *bool `json:"unevaluatedProperties,omitempty"` Required []string `json:"required,omitempty"` OneOf []JSONSchema `json:"oneOf,omitempty"` AnyOf []JSONSchema `json:"anyOf,omitempty"` Title string `json:"title,omitempty"` // For arrays Items *JSONSchema `json:"items,omitempty"` // Used to link to a type defined in the root $defs Ref string `json:"$ref,omitempty"` // Only used in the root JSONSchema object to define types that // can then be referenced using $ref Components *Components `json:"components,omitempty"` }
func JSONSchemaForMessage ¶
func JSONSchemaForMessage(ctx context.Context, schema *proto.Schema, action *proto.Action, message *proto.Message) JSONSchema
Generates JSONSchema for an operation by generating properties for the root input message. Any subsequent nested messages are referenced.
func ValidateResponse ¶
type RelaxedDateFormatChecker ¶ added in v0.369.1
type RelaxedDateFormatChecker struct{}
func (RelaxedDateFormatChecker) IsFormat ¶ added in v0.369.1
func (f RelaxedDateFormatChecker) IsFormat(input interface{}) bool
Checks that the value matches the a ISO8601 except the date component is mandatory
Click to show internal directories.
Click to hide internal directories.