pb33f / libopenapi

libopenapi is a fully featured, high performance OpenAPI 3.1, 3.0 and Swagger parser, library, validator and toolkit for golang applications.
https://pb33f.io/libopenapi/
Other
482 stars 64 forks source link

what changed does not detect custom extension change #348

Open LasneF opened 2 weeks ago

LasneF commented 2 weeks ago

custom extension are supported for the license https://spec.openapis.org/oas/latest.html#fixed-fields-2

given 2 spec with same license except that custom extension are not the same

they are seen as 100 % similar in the test case

func TestCompareLicense_Identicalz(t *testing.T) {

    left := `name: buckaroo
url: https://pb33f.io
x-myXtend : 324`

    right := `name: buckaroo
url: https://pb33f.io
x-myXtend : 325`

    var lNode, rNode yaml.Node
    _ = yaml.Unmarshal([]byte(left), &lNode)
    _ = yaml.Unmarshal([]byte(right), &rNode)

    // create low level objects
    var lDoc lowbase.License
    var rDoc lowbase.License
    _ = low.BuildModel(lNode.Content[0], &lDoc)
    _ = low.BuildModel(rNode.Content[0], &rDoc)
    _ = lDoc.Build(context.Background(), nil, lNode.Content[0], nil)
    _ = rDoc.Build(context.Background(), nil, rNode.Content[0], nil)

    // compare.
    extChanges := CompareLicense(&lDoc, &rDoc)
    assert.Nil(t, extChanges)
}