MCPcopy Create free account
hub / github.com/rilldata/rill / parseSchemaFromYAML

Function parseSchemaFromYAML

runtime/parser/schema.go:85–105  ·  view source on GitHub ↗

parseSchemaFromYAML parses a JSON schema from YAML content.

(yamlContent string)

Source from the content-addressed store, hash-verified

83
84// parseSchemaFromYAML parses a JSON schema from YAML content.
85func parseSchemaFromYAML(yamlContent string) (*jsonschema.Schema, error) {
86 // First parse YAML to a generic interface
87 var yamlData any
88 if err := yaml.Unmarshal([]byte(yamlContent), &yamlData); err != nil {
89 return nil, fmt.Errorf("failed to parse YAML: %w", err)
90 }
91
92 // Convert to JSON (this handles YAML-specific types like map[string]any)
93 jsonBytes, err := json.Marshal(yamlData)
94 if err != nil {
95 return nil, fmt.Errorf("failed to convert YAML to JSON: %w", err)
96 }
97
98 // Parse into jsonschema.Schema
99 var schema jsonschema.Schema
100 if err := json.Unmarshal(jsonBytes, &schema); err != nil {
101 return nil, fmt.Errorf("failed to parse JSON schema: %w", err)
102 }
103
104 return &schema, nil
105}

Callers 2

JSONSchemaForRillYAMLFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected