Skip to content

Commit 79b90ce

Browse files
committed
Fix minor bug not deserializing a full-value in Paths#UnmarshalNextJSON
1 parent a28e98e commit 79b90ce

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/validation/spec/paths.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ func (p *Paths) UnmarshalNextJSON(opts jsonv2.UnmarshalOptions, dec *jsonv2.Deco
114114
p.Paths[k] = pi
115115
default:
116116
_, err := dec.ReadValue() // skip value
117-
return err
117+
if err != nil {
118+
return err
119+
}
118120
}
119121
}
120122
default:

pkg/validation/spec/paths_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ var paths = Paths{
3333
}
3434

3535
const pathsJSON = `{"x-framework":"go-swagger","/":{"$ref":"cats"}}`
36+
const pathsJSONInvalidKey = `{"x-framework":"go-swagger","/":{"$ref":"cats"}, "not-path-nor-extension": "invalid"}`
3637

3738
func TestIntegrationPaths(t *testing.T) {
3839
var actual Paths
3940
if assert.NoError(t, json.Unmarshal([]byte(pathsJSON), &actual)) {
4041
assert.EqualValues(t, actual, paths)
4142
}
43+
if assert.NoError(t, json.Unmarshal([]byte(pathsJSONInvalidKey), &actual)) {
44+
assert.EqualValues(t, actual, paths)
45+
}
4246

4347
assertParsesJSON(t, pathsJSON, paths)
44-
48+
assertParsesJSON(t, pathsJSONInvalidKey, paths)
4549
}
4650

4751
func TestPathsRoundtrip(t *testing.T) {

0 commit comments

Comments
 (0)