• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

astronomer / astro-cli / d8c087d9-3e34-4a26-9912-4e9425408752

04 Feb 2026 08:31PM UTC coverage: 32.799% (+0.005%) from 32.794%
d8c087d9-3e34-4a26-9912-4e9425408752

push

circleci

jeremybeard
Fix linting

18 of 95 new or added lines in 9 files covered. (18.95%)

5 existing lines in 1 file now uncovered.

21211 of 64670 relevant lines covered (32.8%)

8.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pkg/openapi/schema.go
1
package openapi
2

3
import (
4
        "strings"
5
)
6

7
// SchemaResolver resolves $ref references in an OpenAPI spec.
8
type SchemaResolver struct {
9
        spec *OpenAPISpec
10
}
11

12
// NewSchemaResolver creates a new schema resolver.
13
func NewSchemaResolver(spec *OpenAPISpec) *SchemaResolver {
×
14
        return &SchemaResolver{spec: spec}
×
15
}
×
16

17
// ResolveSchema resolves a schema, following $ref if present.
18
// Returns the resolved schema and the reference name (if it was a $ref).
NEW
19
func (r *SchemaResolver) ResolveSchema(schema *Schema) (resolved *Schema, refName string) {
×
20
        if schema == nil {
×
21
                return nil, ""
×
22
        }
×
23

24
        if schema.Ref != "" {
×
25
                refName := extractRefName(schema.Ref)
×
26
                resolved := r.lookupSchema(refName)
×
27
                if resolved != nil {
×
28
                        return resolved, refName
×
29
                }
×
30
        }
31

32
        return schema, ""
×
33
}
34

35
// lookupSchema looks up a schema by name in components/schemas.
36
func (r *SchemaResolver) lookupSchema(name string) *Schema {
×
37
        if r.spec == nil || r.spec.Components == nil || r.spec.Components.Schemas == nil {
×
38
                return nil
×
39
        }
×
40

41
        if schema, ok := r.spec.Components.Schemas[name]; ok {
×
42
                return &schema
×
43
        }
×
44
        return nil
×
45
}
46

47
// GetSchemaByRef looks up a schema by its full $ref path.
48
func (r *SchemaResolver) GetSchemaByRef(ref string) *Schema {
×
49
        return r.lookupSchema(extractRefName(ref))
×
50
}
×
51

52
// extractRefName extracts the schema name from a $ref string.
53
// e.g., "#/components/schemas/CreateDeploymentRequest" -> "CreateDeploymentRequest"
54
func extractRefName(ref string) string {
×
55
        const prefix = "#/components/schemas/"
×
56
        if strings.HasPrefix(ref, prefix) {
×
57
                return ref[len(prefix):]
×
58
        }
×
59
        // Handle other ref formats if needed
60
        parts := strings.Split(ref, "/")
×
61
        if len(parts) > 0 {
×
62
                return parts[len(parts)-1]
×
63
        }
×
64
        return ref
×
65
}
66

67
// IsRequired checks if a property name is in the required list.
68
func IsRequired(name string, required []string) bool {
×
69
        for _, r := range required {
×
70
                if r == name {
×
71
                        return true
×
72
                }
×
73
        }
74
        return false
×
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc