MCPcopy Create free account
hub / github.com/compozy/agh / schemaTypes

Function schemaTypes

internal/tools/schema.go:340–361  ·  view source on GitHub ↗
(raw json.RawMessage)

Source from the content-addressed store, hash-verified

338}
339
340func schemaTypes(raw json.RawMessage) ([]string, error) {
341 if len(bytes.TrimSpace(raw)) == 0 {
342 return nil, nil
343 }
344 var single string
345 if err := json.Unmarshal(raw, &single); err == nil {
346 if err := validateSchemaTypeName(single); err != nil {
347 return nil, err
348 }
349 return []string{single}, nil
350 }
351 var many []string
352 if err := json.Unmarshal(raw, &many); err != nil {
353 return nil, fmt.Errorf("type must be a string or string array: %w", err)
354 }
355 for _, item := range many {
356 if err := validateSchemaTypeName(item); err != nil {
357 return nil, err
358 }
359 }
360 return many, nil
361}
362
363func validateSchemaTypeName(schemaType string) error {
364 switch schemaType {

Callers 2

validateSchemaNodeFunction · 0.85

Calls 1

validateSchemaTypeNameFunction · 0.85

Tested by

no test coverage detected