bf9395e022
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package schemas
|
|
|
|
import "strings"
|
|
|
|
// ResolvePointer extends RFC 6901 with `/*` for array items; tolerates structural mismatches.
|
|
func ResolvePointer(schema map[string]interface{}, path string) []map[string]interface{} {
|
|
if path == "" || path == "/" {
|
|
return []map[string]interface{}{schema}
|
|
}
|
|
trimmed := strings.TrimPrefix(path, "/")
|
|
parts := strings.Split(trimmed, "/")
|
|
|
|
current := []map[string]interface{}{schema}
|
|
for _, part := range parts {
|
|
next := []map[string]interface{}{}
|
|
for _, node := range current {
|
|
if part == "*" {
|
|
items, ok := node["items"].(map[string]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
next = append(next, items)
|
|
continue
|
|
}
|
|
props, ok := node["properties"].(map[string]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
child, ok := props[part].(map[string]interface{})
|
|
if !ok {
|
|
continue
|
|
}
|
|
next = append(next, child)
|
|
}
|
|
if len(next) == 0 {
|
|
return nil
|
|
}
|
|
current = next
|
|
}
|
|
return current
|
|
}
|