Skip to content

Commit d3c5899

Browse files
- Robot test fix.
1 parent 908178a commit d3c5899

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

pkg/docval/docval_fs.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ func (v *fileValidator) rewriteSchemaRefsToFileURLs(schemaPath string) ([]byte,
6666
}
6767

6868
// walk and rewrite
69-
rewriteRefs(m, rootPath)
69+
rewriteErr := rewriteRefs(m, rootPath)
70+
if rewriteErr != nil {
71+
return nil, rewriteErr
72+
}
7073

7174
// marshal back to JSON
7275

@@ -93,7 +96,7 @@ func readJSONSchema(path string, out *map[string]any) error {
9396
return nil
9497
}
9598

96-
func rewriteRefs(v any, baseDir string) {
99+
func rewriteRefs(v any, baseDir string) error {
97100
switch t := v.(type) {
98101
case map[string]any:
99102
if raw, ok := t["$ref"]; ok {
@@ -109,6 +112,11 @@ func rewriteRefs(v any, baseDir string) {
109112
if path != "" {
110113
abs := filepath.Join(baseDir, filepath.FromSlash(path))
111114
abs = filepath.Clean(abs)
115+
abs, absErr := filepath.Abs(abs)
116+
if absErr != nil {
117+
// leave as-is on error
118+
return absErr
119+
}
112120
// Construct file:// URL with platform-independent separators
113121
url := "file://" + filepath.ToSlash(abs)
114122
if frag != "" {
@@ -121,15 +129,22 @@ func rewriteRefs(v any, baseDir string) {
121129
}
122130
// walk children
123131
for k, child := range t {
124-
rewriteRefs(child, baseDir)
132+
err := rewriteRefs(child, baseDir)
133+
if err != nil {
134+
return err
135+
}
125136
t[k] = child
126137
}
127138
case []any:
128139
for i, child := range t {
129-
rewriteRefs(child, baseDir)
140+
err := rewriteRefs(child, baseDir)
141+
if err != nil {
142+
return err
143+
}
130144
t[i] = child
131145
}
132146
}
147+
return nil
133148
}
134149

135150
func splitRef(ref string) (path string, frag string) {

public/discovery/static_analyzer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ func (osa *genericStaticAnalyzer) Analyze() error {
978978
// --- DOCVAL ANALYSIS ---
979979
schemaDir := osa.schemaDir
980980
if !osa.cfg.IsSkipSchemaValidation() {
981-
result, err := osa.validator.ValidateAndParseFile(osa.cfg.GetDocRoot(), filepath.Join(schemaDir, "provider.schema.json"))
981+
result, err := osa.validator.ValidateAndParseFile(osa.cfg.GetDocRoot(), "provider.schema.json")
982982
if err != nil {
983983
osa.errors = append(osa.errors, fmt.Errorf("docval error in provider file: %v", err))
984984
}
@@ -994,7 +994,7 @@ func (osa *genericStaticAnalyzer) Analyze() error {
994994
}
995995
svcRelativePath := svc.GetServiceRefRef()
996996
svcPath := filepath.Join(osa.cfg.GetRegistryRootDir(), svcRelativePath)
997-
schemaPath := filepath.Join(schemaDir, "service-resource.schema.json")
997+
schemaPath := "service-resource.schema.json"
998998
if protocolType == client.LocalTemplated {
999999
schemaPath = filepath.Join(schemaDir, "local-templated-service-resource.schema.json")
10001000
}

test/robot/cli/aot/aot_adhoc.robot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Simple AOT Analysis Google Provider with CLI
1111
... aot
1212
... \./test/registry
1313
... \./test/registry/src/googleapis\.com/v0\.1\.2/provider\.yaml
14+
... \-\-schema-dir
15+
... cicd/schema-definitions
1416
... cwd=${CWD_FOR_EXEC}
1517
... stdout=${CURDIR}${/}/tmp${/}Simple-AOT-Analysis-Google-Provider-with-CLI.txt
1618
... stderr=${CURDIR}${/}/tmp${/}Simple-AOT-Analysis-Google-Provider-with-CLI_stderr.txt
@@ -30,6 +32,8 @@ Simple AOT Analysis AWS Provider with CLI
3032
... \./test/registry
3133
... \./test/registry/src/aws/v0\.1\.0/provider\.yaml
3234
... \-v
35+
... \-\-schema-dir
36+
... cicd/schema-definitions
3337
... cwd=${CWD_FOR_EXEC}
3438
... stdout=${CURDIR}${/}/tmp${/}Simple-AOT-Analysis-AWS-Provider-with-CLI.txt
3539
... stderr=${CURDIR}${/}/tmp${/}Simple-AOT-Analysis-AWS-Provider-with-CLI_stderr.txt
@@ -50,6 +54,8 @@ Simple AOT Service Level Analysis AWS EC2 with CLI
5054
... \./test/registry
5155
... \./test/registry/src/aws/v0\.1\.0/provider\.yaml
5256
... ec2
57+
... \-\-schema-dir
58+
... cicd/schema-definitions
5359
... cwd=${CWD_FOR_EXEC}
5460
... stdout=${CURDIR}${/}/tmp${/}Simple-AOT-Service-Level-Analysis-AWS-EC2-with-CLI.txt
5561
... stderr=${CURDIR}${/}/tmp${/}Simple-AOT-Service-Level-Analysis-AWS-EC2-with-CLI_stderr.txt

0 commit comments

Comments
 (0)