Issue #214 cannot be re-created, added test to validate.

The correct values are be extracted in version `0.14`+

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2023-12-18 10:38:21 -05:00
parent 0b7f809ac6
commit f67d666c4f

View File

@@ -1282,3 +1282,29 @@ components:
t.Errorf("high model: expected $schema to be 'https://example.com/custom-json-schema-dialect', but got '%v'", v)
}
}
func TestMissingExtensions_Issue214(t *testing.T) {
docBytes := []byte(`openapi: 3.1.0
x-time: 2020-12-24T12:00:00Z
x-string: test`)
doc, err := NewDocument(docBytes)
if err != nil {
panic(err)
}
model, errs := doc.BuildV3Model()
if len(errs) > 0 {
panic(errs)
}
// x-string works as expected
if extVal := model.Model.Extensions.GetOrZero("x-string"); extVal.Value != "test" {
t.Errorf("expected x-string to be 'test', but got %v", extVal)
}
// expected x-time to be '2020-12-24T12:00:00Z', but got <nil>
if extVal := model.Model.Extensions.GetOrZero("x-time"); extVal.Value != "2020-12-24T12:00:00Z" {
t.Errorf("expected x-time to be '2020-12-24T12:00:00Z', but got %v", extVal)
}
}