Skip to content

Commit d49fbe2

Browse files
committed
rename
1 parent 18d8150 commit d49fbe2

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

jsonschema/resolve.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ type Resolved struct {
2626
// map from $ids to their schemas
2727
resolvedURIs map[string]*Schema
2828
// map from schemas to additional info computed during resolution
29-
resolvedInfo map[*Schema]*resolvedInfo
29+
resolvedInfos map[*Schema]*resolvedInfo
3030
}
3131

3232
func newResolved(s *Schema) *Resolved {
3333
return &Resolved{
34-
root: s,
35-
resolvedURIs: map[string]*Schema{},
36-
resolvedInfo: map[*Schema]*resolvedInfo{},
34+
root: s,
35+
resolvedURIs: map[string]*Schema{},
36+
resolvedInfos: map[*Schema]*resolvedInfo{},
3737
}
3838
}
3939

@@ -89,7 +89,7 @@ func (r *Resolved) schemaString(s *Schema) string {
8989
if s.ID != "" {
9090
return s.ID
9191
}
92-
info := r.resolvedInfo[s]
92+
info := r.resolvedInfos[s]
9393
if info.path != "" {
9494
return info.path
9595
}
@@ -187,7 +187,7 @@ func (r *resolver) resolve(s *Schema, baseURI *url.URL) (*Resolved, error) {
187187
}
188188
rs := newResolved(s)
189189

190-
if err := s.check(rs.resolvedInfo); err != nil {
190+
if err := s.check(rs.resolvedInfos); err != nil {
191191
return nil, err
192192
}
193193

@@ -199,7 +199,7 @@ func (r *resolver) resolve(s *Schema, baseURI *url.URL) (*Resolved, error) {
199199
// which may differ if the schema has an $id.
200200
// We must set the map before calling resolveRefs, or ref cycles will cause unbounded recursion.
201201
r.loaded[baseURI.String()] = rs
202-
r.loaded[rs.resolvedInfo[s].uri.String()] = rs
202+
r.loaded[rs.resolvedInfos[s].uri.String()] = rs
203203

204204
if err := r.resolveRefs(rs); err != nil {
205205
return nil, err
@@ -385,8 +385,8 @@ func (s *Schema) checkLocal(report func(error), infos map[*Schema]*resolvedInfo)
385385
func resolveURIs(rs *Resolved, baseURI *url.URL) error {
386386
var resolve func(s, base *Schema) error
387387
resolve = func(s, base *Schema) error {
388-
info := rs.resolvedInfo[s]
389-
baseInfo := rs.resolvedInfo[base]
388+
info := rs.resolvedInfos[s]
389+
baseInfo := rs.resolvedInfos[base]
390390

391391
// ids are scoped to the root.
392392
if s.ID != "" {
@@ -405,7 +405,7 @@ func resolveURIs(rs *Resolved, baseURI *url.URL) error {
405405
}
406406
rs.resolvedURIs[info.uri.String()] = s
407407
base = s // needed for anchors
408-
baseInfo = rs.resolvedInfo[base]
408+
baseInfo = rs.resolvedInfos[base]
409409
}
410410
info.base = base
411411

@@ -436,7 +436,7 @@ func resolveURIs(rs *Resolved, baseURI *url.URL) error {
436436
}
437437

438438
// Set the root URI to the base for now. If the root has an $id, this will change.
439-
rs.resolvedInfo[rs.root].uri = baseURI
439+
rs.resolvedInfos[rs.root].uri = baseURI
440440
// The original base, even if changed, is still a valid way to refer to the root.
441441
rs.resolvedURIs[baseURI.String()] = rs.root
442442

@@ -448,7 +448,7 @@ func resolveURIs(rs *Resolved, baseURI *url.URL) error {
448448
// that needs to be loaded.
449449
func (r *resolver) resolveRefs(rs *Resolved) error {
450450
for s := range rs.root.all() {
451-
info := rs.resolvedInfo[s]
451+
info := rs.resolvedInfos[s]
452452
if s.Ref != "" {
453453
refSchema, _, err := r.resolveRef(rs, s, s.Ref)
454454
if err != nil {
@@ -484,8 +484,8 @@ func (r *resolver) resolveRef(rs *Resolved, s *Schema, ref string) (_ *Schema, d
484484
return nil, "", err
485485
}
486486
// URI-resolve the ref against the current base URI to get a complete URI.
487-
base := rs.resolvedInfo[s].base
488-
refURI = rs.resolvedInfo[base].uri.ResolveReference(refURI)
487+
base := rs.resolvedInfos[s].base
488+
refURI = rs.resolvedInfos[base].uri.ResolveReference(refURI)
489489
// The non-fragment part of a ref URI refers to the base URI of some schema.
490490
// This part is the same for dynamic refs too: their non-fragment part resolves
491491
// lexically.
@@ -517,9 +517,9 @@ func (r *resolver) resolveRef(rs *Resolved, s *Schema, ref string) (_ *Schema, d
517517
assert(referencedSchema != nil, "nil referenced schema")
518518
// Copy the resolvedInfos from lrs into rs, without overwriting
519519
// (hence we can't use maps.Insert).
520-
for s, i := range lrs.resolvedInfo {
521-
if rs.resolvedInfo[s] == nil {
522-
rs.resolvedInfo[s] = i
520+
for s, i := range lrs.resolvedInfos {
521+
if rs.resolvedInfos[s] == nil {
522+
rs.resolvedInfos[s] = i
523523
}
524524
}
525525
}
@@ -531,7 +531,7 @@ func (r *resolver) resolveRef(rs *Resolved, s *Schema, ref string) (_ *Schema, d
531531
// A JSON Pointer is either the empty string or begins with a '/',
532532
// whereas anchors are always non-empty strings that don't contain slashes.
533533
if frag != "" && !strings.HasPrefix(frag, "/") {
534-
resInfo := rs.resolvedInfo[referencedSchema]
534+
resInfo := rs.resolvedInfos[referencedSchema]
535535
info, found := resInfo.anchors[frag]
536536

537537
if !found {

jsonschema/resolve_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ func TestPaths(t *testing.T) {
9191
{root.PrefixItems[1].Items, "/prefixItems/1/items"},
9292
}
9393
rs := newResolved(root)
94-
if err := root.checkStructure(rs.resolvedInfo); err != nil {
94+
if err := root.checkStructure(rs.resolvedInfos); err != nil {
9595
t.Fatal(err)
9696
}
9797

9898
var got []item
9999
for s := range root.all() {
100-
got = append(got, item{s, rs.resolvedInfo[s].path})
100+
got = append(got, item{s, rs.resolvedInfos[s].path})
101101
}
102102
if !slices.Equal(got, want) {
103103
t.Errorf("\ngot %v\nwant %v", got, want)
@@ -133,7 +133,7 @@ func TestResolveURIs(t *testing.T) {
133133
}
134134

135135
rs := newResolved(root)
136-
if err := root.check(rs.resolvedInfo); err != nil {
136+
if err := root.check(rs.resolvedInfos); err != nil {
137137
t.Fatal(err)
138138
}
139139
if err := resolveURIs(rs, base); err != nil {
@@ -170,7 +170,7 @@ func TestResolveURIs(t *testing.T) {
170170
t.Errorf("IDs:\ngot %+v\n\nwant %+v", got, wantIDs)
171171
}
172172
for s := range root.all() {
173-
info := rs.resolvedInfo[s]
173+
info := rs.resolvedInfos[s]
174174
if want := wantAnchors[s]; want != nil {
175175
if got := info.anchors; !maps.Equal(got, want) {
176176
t.Errorf("anchors:\ngot %+v\n\nwant %+v", got, want)
@@ -207,7 +207,7 @@ func TestRefCycle(t *testing.T) {
207207

208208
check := func(s *Schema, key string) {
209209
t.Helper()
210-
if rs.resolvedInfo[s].resolvedRef != schemas[key] {
210+
if rs.resolvedInfos[s].resolvedRef != schemas[key] {
211211
t.Errorf("%s resolvedRef != schemas[%q]", s.json(), key)
212212
}
213213
}

jsonschema/validate.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (st *state) validate(instance reflect.Value, schema *Schema, callerAnns *an
9090
instance = instance.Elem()
9191
}
9292

93-
schemaInfo := st.rs.resolvedInfo[schema]
93+
schemaInfo := st.rs.resolvedInfos[schema]
9494

9595
// type: https://json-schema.org/draft/2020-12/draft-bhutton-json-schema-validation-01#section-6.1.1
9696
if schema.Type != "" || schema.Types != nil {
@@ -214,8 +214,8 @@ func (st *state) validate(instance reflect.Value, schema *Schema, callerAnns *an
214214
// For an example, search for "detached" in testdata/draft2020-12/dynamicRef.json.
215215
var dynamicSchema *Schema
216216
for _, s := range st.stack {
217-
base := st.rs.resolvedInfo[s].base
218-
info, ok := st.rs.resolvedInfo[base].anchors[schemaInfo.dynamicRefAnchor]
217+
base := st.rs.resolvedInfos[s].base
218+
info, ok := st.rs.resolvedInfos[base].anchors[schemaInfo.dynamicRefAnchor]
219219
if ok && info.dynamic {
220220
dynamicSchema = info.schema
221221
break
@@ -557,7 +557,7 @@ func (st *state) resolveDynamicRef(schema *Schema) (*Schema, error) {
557557
if schema.DynamicRef == "" {
558558
return nil, nil
559559
}
560-
info := st.rs.resolvedInfo[schema]
560+
info := st.rs.resolvedInfos[schema]
561561
// The ref behaves lexically or dynamically, but not both.
562562
assert((info.resolvedDynamicRef == nil) != (info.dynamicRefAnchor == ""),
563563
"DynamicRef not statically resolved properly")
@@ -575,8 +575,8 @@ func (st *state) resolveDynamicRef(schema *Schema) (*Schema, error) {
575575
// on the stack.
576576
// For an example, search for "detached" in testdata/draft2020-12/dynamicRef.json.
577577
for _, s := range st.stack {
578-
base := st.rs.resolvedInfo[s].base
579-
info, ok := st.rs.resolvedInfo[base].anchors[info.dynamicRefAnchor]
578+
base := st.rs.resolvedInfos[s].base
579+
info, ok := st.rs.resolvedInfos[base].anchors[info.dynamicRefAnchor]
580580
if ok && info.dynamic {
581581
return info.schema, nil
582582
}
@@ -615,7 +615,7 @@ func (rs *Resolved) ApplyDefaults(instancep any) error {
615615
func (st *state) applyDefaults(instancep reflect.Value, schema *Schema) (err error) {
616616
defer util.Wrapf(&err, "applyDefaults: schema %s, instance %v", st.rs.schemaString(schema), instancep)
617617

618-
schemaInfo := st.rs.resolvedInfo[schema]
618+
schemaInfo := st.rs.resolvedInfos[schema]
619619
instance := instancep.Elem()
620620
if instance.Kind() == reflect.Map || instance.Kind() == reflect.Struct {
621621
if instance.Kind() == reflect.Map {

0 commit comments

Comments
 (0)