Skip to content

Commit 97fae13

Browse files
committed
Update the validate-examples tool to ensure only x-publsher is allowed
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
1 parent 7a223d7 commit 97fae13

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tools/validate-examples/main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,16 @@ func runValidation() error {
7676

7777
// Extract server portion if this is a PublishRequest format
7878
serverData := data
79+
publishRequestValid := true
7980
if dataMap, ok := data.(map[string]any); ok {
8081
if server, exists := dataMap["server"]; exists {
82+
// This is a PublishRequest format - validate only expected properties exist
83+
for key := range dataMap {
84+
if key != "server" && key != "x-publisher" {
85+
log.Printf(" Invalid PublishRequest property: ❌ %s (only 'server' and optional 'x-publisher' are allowed)", key)
86+
publishRequestValid = false
87+
}
88+
}
8189
serverData = server
8290
}
8391
}
@@ -101,8 +109,8 @@ func runValidation() error {
101109
registryValid = true
102110
}
103111

104-
// Only count as validated if both schemas passed
105-
if baseValid && registryValid {
112+
// Only count as validated if all validations passed
113+
if publishRequestValid && baseValid && registryValid {
106114
validatedCount++
107115
}
108116

0 commit comments

Comments
 (0)