Swagger v2 high model at 100% coverage.

This commit is contained in:
Dave Shanley
2022-09-11 21:09:16 -04:00
parent 02633ad333
commit d2b974829d
6 changed files with 421 additions and 12 deletions

View File

@@ -0,0 +1,37 @@
// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT
package base
import (
lowmodel "github.com/pb33f/libopenapi/datamodel/low"
lowbase "github.com/pb33f/libopenapi/datamodel/low/base"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
"testing"
)
func TestNewExternalDoc(t *testing.T) {
var cNode yaml.Node
yml := `description: hack code
url: https://pb33f.io
x-hack: code`
_ = yaml.Unmarshal([]byte(yml), &cNode)
var lowExt lowbase.ExternalDoc
_ = lowmodel.BuildModel(&cNode, &lowExt)
_ = lowExt.Build(cNode.Content[0], nil)
highExt := NewExternalDoc(&lowExt)
assert.Equal(t, "hack code", highExt.Description)
assert.Equal(t, "https://pb33f.io", highExt.URL)
assert.Equal(t, "code", highExt.Extensions["x-hack"])
wentLow := highExt.GoLow()
assert.Equal(t, 2, wentLow.URL.ValueNode.Line)
}