fix: Update tests where appropriate

This commit is contained in:
Benjamin Nolan (TwoWholeWorms)
2023-01-07 08:33:54 +01:00
committed by Dave Shanley
parent 1f2709fef3
commit 5f9541283a
8 changed files with 1261 additions and 1147 deletions

View File

@@ -4,413 +4,419 @@
package v3 package v3
import ( import (
"fmt" "fmt"
"github.com/pb33f/libopenapi/datamodel" "io/ioutil"
v2 "github.com/pb33f/libopenapi/datamodel/high/v2" "testing"
lowv2 "github.com/pb33f/libopenapi/datamodel/low/v2"
lowv3 "github.com/pb33f/libopenapi/datamodel/low/v3" "github.com/pb33f/libopenapi/datamodel"
"github.com/stretchr/testify/assert" v2 "github.com/pb33f/libopenapi/datamodel/high/v2"
"io/ioutil" lowv2 "github.com/pb33f/libopenapi/datamodel/low/v2"
"testing" lowv3 "github.com/pb33f/libopenapi/datamodel/low/v3"
"github.com/stretchr/testify/assert"
) )
var lowDoc *lowv3.Document var lowDoc *lowv3.Document
func initTest() { func initTest() {
data, _ := ioutil.ReadFile("../../../test_specs/burgershop.openapi.yaml") data, _ := ioutil.ReadFile("../../../test_specs/burgershop.openapi.yaml")
info, _ := datamodel.ExtractSpecInfo(data) info, _ := datamodel.ExtractSpecInfo(data)
var err []error var err []error
lowDoc, err = lowv3.CreateDocument(info) lowDoc, err = lowv3.CreateDocument(info)
if err != nil { if err != nil {
panic("broken something") panic("broken something")
} }
} }
func BenchmarkNewDocument(b *testing.B) { func BenchmarkNewDocument(b *testing.B) {
initTest() initTest()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
_ = NewDocument(lowDoc) _ = NewDocument(lowDoc)
} }
} }
func TestNewDocument_Extensions(t *testing.T) { func TestNewDocument_Extensions(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Equal(t, "darkside", h.Extensions["x-something-something"]) assert.Equal(t, "darkside", h.Extensions["x-something-something"])
} }
func TestNewDocument_ExternalDocs(t *testing.T) { func TestNewDocument_ExternalDocs(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Equal(t, "https://pb33f.io", h.ExternalDocs.URL) assert.Equal(t, "https://pb33f.io", h.ExternalDocs.URL)
} }
func TestNewDocument_Security(t *testing.T) { func TestNewDocument_Security(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Security, 1) assert.Len(t, h.Security, 1)
assert.Len(t, h.Security[0].Requirements, 1) assert.Len(t, h.Security[0].Requirements, 1)
assert.Len(t, h.Security[0].Requirements["OAuthScheme"], 2) assert.Len(t, h.Security[0].Requirements["OAuthScheme"], 2)
} }
func TestNewDocument_Info(t *testing.T) { func TestNewDocument_Info(t *testing.T) {
initTest() initTest()
highDoc := NewDocument(lowDoc) highDoc := NewDocument(lowDoc)
assert.Equal(t, "3.1.0", highDoc.Version) assert.Equal(t, "3.1.0", highDoc.Version)
assert.Equal(t, "Burger Shop", highDoc.Info.Title) assert.Equal(t, "Burger Shop", highDoc.Info.Title)
assert.Equal(t, "https://pb33f.io", highDoc.Info.TermsOfService) assert.Equal(t, "https://pb33f.io", highDoc.Info.TermsOfService)
assert.Equal(t, "pb33f", highDoc.Info.Contact.Name) assert.Equal(t, "pb33f", highDoc.Info.Contact.Name)
assert.Equal(t, "buckaroo@pb33f.io", highDoc.Info.Contact.Email) assert.Equal(t, "buckaroo@pb33f.io", highDoc.Info.Contact.Email)
assert.Equal(t, "https://pb33f.io", highDoc.Info.Contact.URL) assert.Equal(t, "https://pb33f.io", highDoc.Info.Contact.URL)
assert.Equal(t, "pb33f", highDoc.Info.License.Name) assert.Equal(t, "pb33f", highDoc.Info.License.Name)
assert.Equal(t, "https://pb33f.io/made-up", highDoc.Info.License.URL) assert.Equal(t, "https://pb33f.io/made-up", highDoc.Info.License.URL)
assert.Equal(t, "1.2", highDoc.Info.Version) assert.Equal(t, "1.2", highDoc.Info.Version)
assert.Equal(t, "https://pb33f.io/schema", highDoc.JsonSchemaDialect) assert.Equal(t, "https://pb33f.io/schema", highDoc.JsonSchemaDialect)
wentLow := highDoc.GoLow() wentLow := highDoc.GoLow()
assert.Equal(t, 1, wentLow.Version.ValueNode.Line) assert.Equal(t, 1, wentLow.Version.ValueNode.Line)
assert.Equal(t, 3, wentLow.Info.Value.Title.KeyNode.Line) assert.Equal(t, 3, wentLow.Info.Value.Title.KeyNode.Line)
wentLower := highDoc.Info.Contact.GoLow() wentLower := highDoc.Info.Contact.GoLow()
assert.Equal(t, 8, wentLower.Name.ValueNode.Line) assert.Equal(t, 8, wentLower.Name.ValueNode.Line)
assert.Equal(t, 11, wentLower.Name.ValueNode.Column) assert.Equal(t, 11, wentLower.Name.ValueNode.Column)
wentLowAgain := highDoc.Info.GoLow() wentLowAgain := highDoc.Info.GoLow()
assert.Equal(t, 3, wentLowAgain.Title.ValueNode.Line) assert.Equal(t, 3, wentLowAgain.Title.ValueNode.Line)
assert.Equal(t, 10, wentLowAgain.Title.ValueNode.Column) assert.Equal(t, 10, wentLowAgain.Title.ValueNode.Column)
wentOnceMore := highDoc.Info.License.GoLow()
assert.Equal(t, 12, wentOnceMore.Name.ValueNode.Line)
assert.Equal(t, 11, wentOnceMore.Name.ValueNode.Column)
wentOnceMore := highDoc.Info.License.GoLow()
assert.Equal(t, 12, wentOnceMore.Name.ValueNode.Line)
assert.Equal(t, 11, wentOnceMore.Name.ValueNode.Column)
} }
func TestNewDocument_Servers(t *testing.T) { func TestNewDocument_Servers(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Servers, 2) assert.Len(t, h.Servers, 2)
assert.Equal(t, "{scheme}://api.pb33f.io", h.Servers[0].URL) assert.Equal(t, "{scheme}://api.pb33f.io", h.Servers[0].URL)
assert.Equal(t, "this is our main API server, for all fun API things.", h.Servers[0].Description) assert.Equal(t, "this is our main API server, for all fun API things.", h.Servers[0].Description)
assert.Len(t, h.Servers[0].Variables, 1) assert.Len(t, h.Servers[0].Variables, 1)
assert.Equal(t, "https", h.Servers[0].Variables["scheme"].Default) assert.Equal(t, "https", h.Servers[0].Variables["scheme"].Default)
assert.Len(t, h.Servers[0].Variables["scheme"].Enum, 2) assert.Len(t, h.Servers[0].Variables["scheme"].Enum, 2)
assert.Equal(t, "https://{domain}.{host}.com", h.Servers[1].URL) assert.Equal(t, "https://{domain}.{host}.com", h.Servers[1].URL)
assert.Equal(t, "this is our second API server, for all fun API things.", h.Servers[1].Description) assert.Equal(t, "this is our second API server, for all fun API things.", h.Servers[1].Description)
assert.Len(t, h.Servers[1].Variables, 2) assert.Len(t, h.Servers[1].Variables, 2)
assert.Equal(t, "api", h.Servers[1].Variables["domain"].Default) assert.Equal(t, "api", h.Servers[1].Variables["domain"].Default)
assert.Equal(t, "pb33f.io", h.Servers[1].Variables["host"].Default) assert.Equal(t, "pb33f.io", h.Servers[1].Variables["host"].Default)
wentLow := h.GoLow() wentLow := h.GoLow()
assert.Equal(t, 45, wentLow.Servers.Value[0].Value.Description.KeyNode.Line) assert.Equal(t, 45, wentLow.Servers.Value[0].Value.Description.KeyNode.Line)
assert.Equal(t, 5, wentLow.Servers.Value[0].Value.Description.KeyNode.Column) assert.Equal(t, 5, wentLow.Servers.Value[0].Value.Description.KeyNode.Column)
assert.Equal(t, 45, wentLow.Servers.Value[0].Value.Description.ValueNode.Line) assert.Equal(t, 45, wentLow.Servers.Value[0].Value.Description.ValueNode.Line)
assert.Equal(t, 18, wentLow.Servers.Value[0].Value.Description.ValueNode.Column) assert.Equal(t, 18, wentLow.Servers.Value[0].Value.Description.ValueNode.Column)
wentLower := h.Servers[0].GoLow() wentLower := h.Servers[0].GoLow()
assert.Equal(t, 45, wentLower.Description.ValueNode.Line) assert.Equal(t, 45, wentLower.Description.ValueNode.Line)
assert.Equal(t, 18, wentLower.Description.ValueNode.Column) assert.Equal(t, 18, wentLower.Description.ValueNode.Column)
wentLowest := h.Servers[0].Variables["scheme"].GoLow()
assert.Equal(t, 50, wentLowest.Description.ValueNode.Line)
assert.Equal(t, 22, wentLowest.Description.ValueNode.Column)
wentLowest := h.Servers[0].Variables["scheme"].GoLow()
assert.Equal(t, 50, wentLowest.Description.ValueNode.Line)
assert.Equal(t, 22, wentLowest.Description.ValueNode.Column)
} }
func TestNewDocument_Tags(t *testing.T) { func TestNewDocument_Tags(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Tags, 2) assert.Len(t, h.Tags, 2)
assert.Equal(t, "Burgers", h.Tags[0].Name) assert.Equal(t, "Burgers", h.Tags[0].Name)
assert.Equal(t, "All kinds of yummy burgers.", h.Tags[0].Description) assert.Equal(t, "All kinds of yummy burgers.", h.Tags[0].Description)
assert.Equal(t, "Find out more", h.Tags[0].ExternalDocs.Description) assert.Equal(t, "Find out more", h.Tags[0].ExternalDocs.Description)
assert.Equal(t, "https://pb33f.io", h.Tags[0].ExternalDocs.URL) assert.Equal(t, "https://pb33f.io", h.Tags[0].ExternalDocs.URL)
assert.Equal(t, "somethingSpecial", h.Tags[0].Extensions["x-internal-ting"]) assert.Equal(t, "somethingSpecial", h.Tags[0].Extensions["x-internal-ting"])
assert.Equal(t, int64(1), h.Tags[0].Extensions["x-internal-tong"]) assert.Equal(t, int64(1), h.Tags[0].Extensions["x-internal-tong"])
assert.Equal(t, 1.2, h.Tags[0].Extensions["x-internal-tang"]) assert.Equal(t, 1.2, h.Tags[0].Extensions["x-internal-tang"])
assert.True(t, h.Tags[0].Extensions["x-internal-tung"].(bool)) assert.True(t, h.Tags[0].Extensions["x-internal-tung"].(bool))
wentLow := h.Tags[1].GoLow() wentLow := h.Tags[1].GoLow()
assert.Equal(t, 39, wentLow.Description.KeyNode.Line) assert.Equal(t, 39, wentLow.Description.KeyNode.Line)
assert.Equal(t, 5, wentLow.Description.KeyNode.Column) assert.Equal(t, 5, wentLow.Description.KeyNode.Column)
wentLower := h.Tags[0].ExternalDocs.GoLow() wentLower := h.Tags[0].ExternalDocs.GoLow()
assert.Equal(t, 23, wentLower.Description.ValueNode.Line) assert.Equal(t, 23, wentLower.Description.ValueNode.Line)
assert.Equal(t, 20, wentLower.Description.ValueNode.Column) assert.Equal(t, 20, wentLower.Description.ValueNode.Column)
} }
func TestNewDocument_Webhooks(t *testing.T) { func TestNewDocument_Webhooks(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Webhooks, 1) assert.Len(t, h.Webhooks, 1)
assert.Equal(t, "Information about a new burger", h.Webhooks["someHook"].Post.RequestBody.Description) assert.Equal(t, "Information about a new burger", h.Webhooks["someHook"].Post.RequestBody.Description)
} }
func TestNewDocument_Components_Links(t *testing.T) { func TestNewDocument_Components_Links(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.Links, 2) assert.Len(t, h.Components.Links, 2)
assert.Equal(t, "locateBurger", h.Components.Links["LocateBurger"].OperationId) assert.Equal(t, "locateBurger", h.Components.Links["LocateBurger"].OperationId)
assert.Equal(t, "$response.body#/id", h.Components.Links["LocateBurger"].Parameters["burgerId"]) assert.Equal(t, "$response.body#/id", h.Components.Links["LocateBurger"].Parameters["burgerId"])
wentLow := h.Components.Links["LocateBurger"].GoLow()
assert.Equal(t, 305, wentLow.OperationId.ValueNode.Line)
assert.Equal(t, 20, wentLow.OperationId.ValueNode.Column)
wentLow := h.Components.Links["LocateBurger"].GoLow()
assert.Equal(t, 305, wentLow.OperationId.ValueNode.Line)
assert.Equal(t, 20, wentLow.OperationId.ValueNode.Column)
} }
func TestNewDocument_Components_Callbacks(t *testing.T) { func TestNewDocument_Components_Callbacks(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.Callbacks, 1) assert.Len(t, h.Components.Callbacks, 1)
assert.Equal(t, "Callback payload", assert.Equal(
h.Components.Callbacks["BurgerCallback"].Expression["{$request.query.queryUrl}"].Post.RequestBody.Description) t,
"Callback payload",
h.Components.Callbacks["BurgerCallback"].Expression["{$request.query.queryUrl}"].Post.RequestBody.Description,
)
assert.Equal(
t,
293,
h.Components.Callbacks["BurgerCallback"].GoLow().FindExpression("{$request.query.queryUrl}").ValueNode.Line,
)
assert.Equal(
t,
9,
h.Components.Callbacks["BurgerCallback"].GoLow().FindExpression("{$request.query.queryUrl}").ValueNode.Column,
)
assert.Equal(t, 293, assert.Equal(t, "please", h.Components.Callbacks["BurgerCallback"].Extensions["x-break-everything"])
h.Components.Callbacks["BurgerCallback"].GoLow().FindExpression("{$request.query.queryUrl}").ValueNode.Line)
assert.Equal(t, 9,
h.Components.Callbacks["BurgerCallback"].GoLow().FindExpression("{$request.query.queryUrl}").ValueNode.Column)
assert.Equal(t, "please", h.Components.Callbacks["BurgerCallback"].Extensions["x-break-everything"]) for k := range h.Components.GoLow().Callbacks.Value {
if k.Value == "BurgerCallback" {
for k := range h.Components.GoLow().Callbacks.Value { assert.Equal(t, 290, k.KeyNode.Line)
if k.Value == "BurgerCallback" { assert.Equal(t, 5, k.KeyNode.Column)
assert.Equal(t, 290, k.KeyNode.Line) }
assert.Equal(t, 5, k.KeyNode.Column) }
}
}
} }
func TestNewDocument_Components_Schemas(t *testing.T) { func TestNewDocument_Components_Schemas(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.Schemas, 6) assert.Len(t, h.Components.Schemas, 6)
goLow := h.Components.GoLow() goLow := h.Components.GoLow()
a := h.Components.Schemas["Error"] a := h.Components.Schemas["Error"]
abcd := a.Schema().Properties["message"].Schema().Example abcd := a.Schema().Properties["message"].Schema().Example
assert.Equal(t, "No such burger as 'Big-Whopper'", abcd) assert.Equal(t, "No such burger as 'Big-Whopper'", abcd)
assert.Equal(t, 428, goLow.Schemas.KeyNode.Line) assert.Equal(t, 428, goLow.Schemas.KeyNode.Line)
assert.Equal(t, 3, goLow.Schemas.KeyNode.Column) assert.Equal(t, 3, goLow.Schemas.KeyNode.Column)
assert.Equal(t, 431, a.Schema().GoLow().Description.KeyNode.Line) assert.Equal(t, 431, a.Schema().GoLow().Description.KeyNode.Line)
b := h.Components.Schemas["Burger"] b := h.Components.Schemas["Burger"]
assert.Len(t, b.Schema().Required, 2) assert.Len(t, b.Schema().Required, 2)
assert.Equal(t, "golden slices of happy fun joy", b.Schema().Properties["fries"].Schema().Description) assert.Equal(t, "golden slices of happy fun joy", b.Schema().Properties["fries"].Schema().Description)
assert.Equal(t, int64(2), b.Schema().Properties["numPatties"].Schema().Example) assert.Equal(t, int64(2), b.Schema().Properties["numPatties"].Schema().Example)
assert.Equal(t, 443, goLow.FindSchema("Burger").Value.Schema().Properties.KeyNode.Line) assert.Equal(t, 443, goLow.FindSchema("Burger").Value.Schema().Properties.KeyNode.Line)
assert.Equal(t, 7, goLow.FindSchema("Burger").Value.Schema().Properties.KeyNode.Column) assert.Equal(t, 7, goLow.FindSchema("Burger").Value.Schema().Properties.KeyNode.Column)
assert.Equal(t, 445, b.Schema().GoLow().FindProperty("name").ValueNode.Line) assert.Equal(t, 445, b.Schema().GoLow().FindProperty("name").ValueNode.Line)
f := h.Components.Schemas["Fries"] f := h.Components.Schemas["Fries"]
assert.Equal(t, "salt", f.Schema().Properties["seasoning"].Schema().Items.A.Schema().Example) assert.Equal(t, "salt", f.Schema().Properties["seasoning"].Schema().Items.A.Schema().Example)
assert.Len(t, f.Schema().Properties["favoriteDrink"].Schema().Properties["drinkType"].Schema().Enum, 2) assert.Len(t, f.Schema().Properties["favoriteDrink"].Schema().Properties["drinkType"].Schema().Enum, 2)
d := h.Components.Schemas["Drink"] d := h.Components.Schemas["Drink"]
assert.Len(t, d.Schema().Required, 2) assert.Len(t, d.Schema().Required, 2)
assert.True(t, d.Schema().AdditionalProperties.(bool)) assert.True(t, d.Schema().AdditionalProperties.(bool))
assert.Equal(t, "drinkType", d.Schema().Discriminator.PropertyName) assert.Equal(t, "drinkType", d.Schema().Discriminator.PropertyName)
assert.Equal(t, "some value", d.Schema().Discriminator.Mapping["drink"]) assert.Equal(t, "some value", d.Schema().Discriminator.Mapping["drink"])
assert.Equal(t, 511, d.Schema().Discriminator.GoLow().PropertyName.ValueNode.Line) assert.Equal(t, 511, d.Schema().Discriminator.GoLow().PropertyName.ValueNode.Line)
assert.Equal(t, 23, d.Schema().Discriminator.GoLow().PropertyName.ValueNode.Column) assert.Equal(t, 23, d.Schema().Discriminator.GoLow().PropertyName.ValueNode.Column)
pl := h.Components.Schemas["SomePayload"] pl := h.Components.Schemas["SomePayload"]
assert.Equal(t, "is html programming? yes.", pl.Schema().XML.Name) assert.Equal(t, "is html programming? yes.", pl.Schema().XML.Name)
assert.Equal(t, 518, pl.Schema().XML.GoLow().Name.ValueNode.Line) assert.Equal(t, 518, pl.Schema().XML.GoLow().Name.ValueNode.Line)
ext := h.Components.Extensions ext := h.Components.Extensions
assert.Equal(t, "loud", ext["x-screaming-baby"]) assert.Equal(t, "loud", ext["x-screaming-baby"])
} }
func TestNewDocument_Components_Headers(t *testing.T) { func TestNewDocument_Components_Headers(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.Headers, 1) assert.Len(t, h.Components.Headers, 1)
assert.Equal(t, "this is a header example for UseOil", h.Components.Headers["UseOil"].Description) assert.Equal(t, "this is a header example for UseOil", h.Components.Headers["UseOil"].Description)
assert.Equal(t, 318, h.Components.Headers["UseOil"].GoLow().Description.ValueNode.Line) assert.Equal(t, 318, h.Components.Headers["UseOil"].GoLow().Description.ValueNode.Line)
assert.Equal(t, 20, h.Components.Headers["UseOil"].GoLow().Description.ValueNode.Column) assert.Equal(t, 20, h.Components.Headers["UseOil"].GoLow().Description.ValueNode.Column)
} }
func TestNewDocument_Components_RequestBodies(t *testing.T) { func TestNewDocument_Components_RequestBodies(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.RequestBodies, 1) assert.Len(t, h.Components.RequestBodies, 1)
assert.Equal(t, "Give us the new burger!", h.Components.RequestBodies["BurgerRequest"].Description) assert.Equal(t, "Give us the new burger!", h.Components.RequestBodies["BurgerRequest"].Description)
assert.Equal(t, 323, h.Components.RequestBodies["BurgerRequest"].GoLow().Description.ValueNode.Line) assert.Equal(t, 323, h.Components.RequestBodies["BurgerRequest"].GoLow().Description.ValueNode.Line)
assert.Equal(t, 20, h.Components.RequestBodies["BurgerRequest"].GoLow().Description.ValueNode.Column) assert.Equal(t, 20, h.Components.RequestBodies["BurgerRequest"].GoLow().Description.ValueNode.Column)
assert.Len(t, h.Components.RequestBodies["BurgerRequest"].Content["application/json"].Examples, 2) assert.Len(t, h.Components.RequestBodies["BurgerRequest"].Content["application/json"].Examples, 2)
} }
func TestNewDocument_Components_Examples(t *testing.T) { func TestNewDocument_Components_Examples(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.Examples, 1) assert.Len(t, h.Components.Examples, 1)
assert.Equal(t, "A juicy two hander sammich", h.Components.Examples["QuarterPounder"].Summary) assert.Equal(t, "A juicy two hander sammich", h.Components.Examples["QuarterPounder"].Summary)
assert.Equal(t, 341, h.Components.Examples["QuarterPounder"].GoLow().Summary.ValueNode.Line) assert.Equal(t, 341, h.Components.Examples["QuarterPounder"].GoLow().Summary.ValueNode.Line)
assert.Equal(t, 16, h.Components.Examples["QuarterPounder"].GoLow().Summary.ValueNode.Column) assert.Equal(t, 16, h.Components.Examples["QuarterPounder"].GoLow().Summary.ValueNode.Column)
} }
func TestNewDocument_Components_Responses(t *testing.T) { func TestNewDocument_Components_Responses(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.Responses, 1) assert.Len(t, h.Components.Responses, 1)
assert.Equal(t, "all the dressings for a burger.", h.Components.Responses["DressingResponse"].Description) assert.Equal(t, "all the dressings for a burger.", h.Components.Responses["DressingResponse"].Description)
assert.Equal(t, "array", h.Components.Responses["DressingResponse"].Content["application/json"].Schema.Schema().Type[0]) assert.Equal(t, "array", h.Components.Responses["DressingResponse"].Content["application/json"].Schema.Schema().Type[0])
assert.Equal(t, 347, h.Components.Responses["DressingResponse"].GoLow().Description.KeyNode.Line) assert.Equal(t, 347, h.Components.Responses["DressingResponse"].GoLow().Description.KeyNode.Line)
assert.Equal(t, 7, h.Components.Responses["DressingResponse"].GoLow().Description.KeyNode.Column) assert.Equal(t, 7, h.Components.Responses["DressingResponse"].GoLow().Description.KeyNode.Column)
} }
func TestNewDocument_Components_SecuritySchemes(t *testing.T) { func TestNewDocument_Components_SecuritySchemes(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.SecuritySchemes, 3) assert.Len(t, h.Components.SecuritySchemes, 3)
api := h.Components.SecuritySchemes["APIKeyScheme"] api := h.Components.SecuritySchemes["APIKeyScheme"]
assert.Equal(t, "an apiKey security scheme", api.Description) assert.Equal(t, "an apiKey security scheme", api.Description)
assert.Equal(t, 359, api.GoLow().Description.ValueNode.Line) assert.Equal(t, 359, api.GoLow().Description.ValueNode.Line)
assert.Equal(t, 20, api.GoLow().Description.ValueNode.Column) assert.Equal(t, 20, api.GoLow().Description.ValueNode.Column)
jwt := h.Components.SecuritySchemes["JWTScheme"] jwt := h.Components.SecuritySchemes["JWTScheme"]
assert.Equal(t, "an JWT security scheme", jwt.Description) assert.Equal(t, "an JWT security scheme", jwt.Description)
assert.Equal(t, 364, jwt.GoLow().Description.ValueNode.Line) assert.Equal(t, 364, jwt.GoLow().Description.ValueNode.Line)
assert.Equal(t, 20, jwt.GoLow().Description.ValueNode.Column) assert.Equal(t, 20, jwt.GoLow().Description.ValueNode.Column)
oAuth := h.Components.SecuritySchemes["OAuthScheme"] oAuth := h.Components.SecuritySchemes["OAuthScheme"]
assert.Equal(t, "an oAuth security scheme", oAuth.Description) assert.Equal(t, "an oAuth security scheme", oAuth.Description)
assert.Equal(t, 370, oAuth.GoLow().Description.ValueNode.Line) assert.Equal(t, 370, oAuth.GoLow().Description.ValueNode.Line)
assert.Equal(t, 20, oAuth.GoLow().Description.ValueNode.Column) assert.Equal(t, 20, oAuth.GoLow().Description.ValueNode.Column)
assert.Len(t, oAuth.Flows.Implicit.Scopes, 2) assert.Len(t, oAuth.Flows.Implicit.Scopes, 2)
assert.Equal(t, "read all burgers", oAuth.Flows.Implicit.Scopes["read:burgers"]) assert.Equal(t, "read all burgers", oAuth.Flows.Implicit.Scopes["read:burgers"])
assert.Equal(t, "https://pb33f.io/oauth", oAuth.Flows.AuthorizationCode.AuthorizationUrl) assert.Equal(t, "https://pb33f.io/oauth", oAuth.Flows.AuthorizationCode.AuthorizationUrl)
// check the lowness is low.
assert.Equal(t, 375, oAuth.Flows.GoLow().Implicit.Value.Scopes.KeyNode.Line)
assert.Equal(t, 11, oAuth.Flows.GoLow().Implicit.Value.Scopes.KeyNode.Column)
assert.Equal(t, 375, oAuth.Flows.Implicit.GoLow().Scopes.KeyNode.Line)
assert.Equal(t, 11, oAuth.Flows.Implicit.GoLow().Scopes.KeyNode.Column)
// check the lowness is low.
assert.Equal(t, 375, oAuth.Flows.GoLow().Implicit.Value.Scopes.KeyNode.Line)
assert.Equal(t, 11, oAuth.Flows.GoLow().Implicit.Value.Scopes.KeyNode.Column)
assert.Equal(t, 375, oAuth.Flows.Implicit.GoLow().Scopes.KeyNode.Line)
assert.Equal(t, 11, oAuth.Flows.Implicit.GoLow().Scopes.KeyNode.Column)
} }
func TestNewDocument_Components_Parameters(t *testing.T) { func TestNewDocument_Components_Parameters(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Components.Parameters, 2) assert.Len(t, h.Components.Parameters, 2)
bh := h.Components.Parameters["BurgerHeader"] bh := h.Components.Parameters["BurgerHeader"]
assert.Equal(t, "burgerHeader", bh.Name) assert.Equal(t, "burgerHeader", bh.Name)
assert.Equal(t, 387, bh.GoLow().Name.KeyNode.Line) assert.Equal(t, 387, bh.GoLow().Name.KeyNode.Line)
assert.Len(t, bh.Schema.Schema().Properties, 2) assert.Len(t, bh.Schema.Schema().Properties, 2)
assert.Equal(t, "big-mac", bh.Example) assert.Equal(t, "big-mac", bh.Example)
assert.True(t, bh.Required) assert.True(t, bh.Required)
assert.Equal(t, "this is a header", assert.Equal(
bh.Content["application/json"].Encoding["burgerTheme"].Headers["someHeader"].Description) t,
assert.Len(t, bh.Content["application/json"].Schema.Schema().Properties, 2) "this is a header",
assert.Equal(t, 404, bh.Content["application/json"].Encoding["burgerTheme"].GoLow().ContentType.ValueNode.Line) bh.Content["application/json"].Encoding["burgerTheme"].Headers["someHeader"].Description,
)
assert.Len(t, bh.Content["application/json"].Schema.Schema().Properties, 2)
assert.Equal(t, 404, bh.Content["application/json"].Encoding["burgerTheme"].GoLow().ContentType.ValueNode.Line)
} }
func TestNewDocument_Paths(t *testing.T) { func TestNewDocument_Paths(t *testing.T) {
initTest() initTest()
h := NewDocument(lowDoc) h := NewDocument(lowDoc)
assert.Len(t, h.Paths.PathItems, 5) assert.Len(t, h.Paths.PathItems, 5)
burgersOp := h.Paths.PathItems["/burgers"] burgersOp := h.Paths.PathItems["/burgers"]
assert.Len(t, burgersOp.GetOperations(), 1) assert.Len(t, burgersOp.GetOperations(), 1)
assert.Equal(t, "meaty", burgersOp.Extensions["x-burger-meta"]) assert.Equal(t, "meaty", burgersOp.Extensions["x-burger-meta"])
assert.Nil(t, burgersOp.Get) assert.Nil(t, burgersOp.Get)
assert.Nil(t, burgersOp.Put) assert.Nil(t, burgersOp.Put)
assert.Nil(t, burgersOp.Patch) assert.Nil(t, burgersOp.Patch)
assert.Nil(t, burgersOp.Head) assert.Nil(t, burgersOp.Head)
assert.Nil(t, burgersOp.Options) assert.Nil(t, burgersOp.Options)
assert.Nil(t, burgersOp.Trace) assert.Nil(t, burgersOp.Trace)
assert.Equal(t, 64, burgersOp.GoLow().Post.KeyNode.Line) assert.Equal(t, 64, burgersOp.GoLow().Post.KeyNode.Line)
assert.Equal(t, "createBurger", burgersOp.Post.OperationId) assert.Equal(t, "createBurger", burgersOp.Post.OperationId)
assert.Len(t, burgersOp.Post.Tags, 1) assert.Len(t, burgersOp.Post.Tags, 1)
assert.Equal(t, "A new burger for our menu, yummy yum yum.", burgersOp.Post.Description) assert.Equal(t, "A new burger for our menu, yummy yum yum.", burgersOp.Post.Description)
assert.Equal(t, "Give us the new burger!", burgersOp.Post.RequestBody.Description) assert.Equal(t, "Give us the new burger!", burgersOp.Post.RequestBody.Description)
assert.Len(t, burgersOp.Post.Responses.Codes, 3) assert.Len(t, burgersOp.Post.Responses.Codes, 3)
assert.Equal(t, 63, h.Paths.GoLow().FindPath("/burgers").ValueNode.Line) assert.Equal(t, 63, h.Paths.GoLow().FindPath("/burgers").ValueNode.Line)
okResp := burgersOp.Post.Responses.FindResponseByCode(200) okResp := burgersOp.Post.Responses.FindResponseByCode(200)
assert.Len(t, okResp.Headers, 1) assert.Len(t, okResp.Headers, 1)
assert.Equal(t, "A tasty burger for you to eat.", okResp.Description) assert.Equal(t, "A tasty burger for you to eat.", okResp.Description)
assert.Equal(t, 69, burgersOp.Post.GoLow().Description.ValueNode.Line) assert.Equal(t, 69, burgersOp.Post.GoLow().Description.ValueNode.Line)
assert.Len(t, okResp.Content["application/json"].Examples, 2) assert.Len(t, okResp.Content["application/json"].Examples, 2)
assert.Equal(t, "a cripsy fish sammich filled with ocean goodness.", assert.Equal(
okResp.Content["application/json"].Examples["filetOFish"].Summary) t,
assert.Equal(t, 74, burgersOp.Post.Responses.GoLow().FindResponseByCode("200").ValueNode.Line) "a cripsy fish sammich filled with ocean goodness.",
okResp.Content["application/json"].Examples["filetOFish"].Summary,
)
assert.Equal(t, 74, burgersOp.Post.Responses.GoLow().FindResponseByCode("200").ValueNode.Line)
assert.Equal(t, 80, okResp.Content["application/json"].GoLow().Schema.KeyNode.Line) assert.Equal(t, 80, okResp.Content["application/json"].GoLow().Schema.KeyNode.Line)
assert.Equal(t, 15, okResp.Content["application/json"].GoLow().Schema.KeyNode.Column) assert.Equal(t, 15, okResp.Content["application/json"].GoLow().Schema.KeyNode.Column)
assert.Equal(t, 77, okResp.GoLow().Description.KeyNode.Line)
assert.Len(t, okResp.Links, 2)
assert.Equal(t, "locateBurger", okResp.Links["LocateBurger"].OperationId)
assert.Equal(t, 305, okResp.Links["LocateBurger"].GoLow().OperationId.ValueNode.Line)
assert.Len(t, burgersOp.Post.Security[0].Requirements, 1)
assert.Len(t, burgersOp.Post.Security[0].Requirements["OAuthScheme"], 2)
assert.Equal(t, "read:burgers", burgersOp.Post.Security[0].Requirements["OAuthScheme"][0])
assert.Equal(t, 118, burgersOp.Post.Security[0].GoLow().Requirements.ValueNode.Line)
assert.Len(t, burgersOp.Post.Servers, 1)
assert.Equal(t, "https://pb33f.io", burgersOp.Post.Servers[0].URL)
assert.Equal(t, 77, okResp.GoLow().Description.KeyNode.Line)
assert.Len(t, okResp.Links, 2)
assert.Equal(t, "locateBurger", okResp.Links["LocateBurger"].OperationId)
assert.Equal(t, 305, okResp.Links["LocateBurger"].GoLow().OperationId.ValueNode.Line)
assert.Len(t, burgersOp.Post.Security[0].Requirements, 1)
assert.Len(t, burgersOp.Post.Security[0].Requirements["OAuthScheme"], 2)
assert.Equal(t, "read:burgers", burgersOp.Post.Security[0].Requirements["OAuthScheme"][0])
assert.Equal(t, 118, burgersOp.Post.Security[0].GoLow().Requirements.ValueNode.Line)
assert.Len(t, burgersOp.Post.Servers, 1)
assert.Equal(t, "https://pb33f.io", burgersOp.Post.Servers[0].URL)
} }
func TestStripeAsDoc(t *testing.T) { func TestStripeAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/stripe.yaml") data, _ := ioutil.ReadFile("../../../test_specs/stripe.yaml")
info, _ := datamodel.ExtractSpecInfo(data) info, _ := datamodel.ExtractSpecInfo(data)
var err []error var err []error
lowDoc, err = lowv3.CreateDocument(info) lowDoc, err = lowv3.CreateDocument(info)
assert.Len(t, err, 23) assert.Len(t, err, 3)
d := NewDocument(lowDoc) d := NewDocument(lowDoc)
assert.NotNil(t, d) assert.NotNil(t, d)
} }
func TestK8sAsDoc(t *testing.T) { func TestK8sAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/k8s.json") data, _ := ioutil.ReadFile("../../../test_specs/k8s.json")
info, _ := datamodel.ExtractSpecInfo(data) info, _ := datamodel.ExtractSpecInfo(data)
var err []error var err []error
lowSwag, err := lowv2.CreateDocument(info) lowSwag, err := lowv2.CreateDocument(info)
d := v2.NewSwaggerDocument(lowSwag) d := v2.NewSwaggerDocument(lowSwag)
assert.Len(t, err, 1) assert.Len(t, err, 0)
assert.NotNil(t, d) assert.NotNil(t, d)
} }
func TestAsanaAsDoc(t *testing.T) { func TestAsanaAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/asana.yaml") data, _ := ioutil.ReadFile("../../../test_specs/asana.yaml")
info, _ := datamodel.ExtractSpecInfo(data) info, _ := datamodel.ExtractSpecInfo(data)
var err []error var err []error
lowDoc, err = lowv3.CreateDocument(info) lowDoc, err = lowv3.CreateDocument(info)
if err != nil { if err != nil {
panic("broken something") panic("broken something")
} }
d := NewDocument(lowDoc) d := NewDocument(lowDoc)
fmt.Println(d) fmt.Println(d)
} }
func TestPetstoreAsDoc(t *testing.T) { func TestPetstoreAsDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/petstorev3.json") data, _ := ioutil.ReadFile("../../../test_specs/petstorev3.json")
info, _ := datamodel.ExtractSpecInfo(data) info, _ := datamodel.ExtractSpecInfo(data)
var err []error var err []error
lowDoc, err = lowv3.CreateDocument(info) lowDoc, err = lowv3.CreateDocument(info)
if err != nil { if err != nil {
panic("broken something") panic("broken something")
} }
d := NewDocument(lowDoc) d := NewDocument(lowDoc)
fmt.Println(d) fmt.Println(d)
} }
func TestCircularReferencesDoc(t *testing.T) { func TestCircularReferencesDoc(t *testing.T) {
data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml") data, _ := ioutil.ReadFile("../../../test_specs/circular-tests.yaml")
info, _ := datamodel.ExtractSpecInfo(data) info, _ := datamodel.ExtractSpecInfo(data)
var err []error var err []error
lowDoc, err = lowv3.CreateDocument(info) lowDoc, err = lowv3.CreateDocument(info)
assert.Len(t, err, 3) assert.Len(t, err, 3)
d := NewDocument(lowDoc) d := NewDocument(lowDoc)
assert.Len(t, d.Components.Schemas, 9) assert.Len(t, d.Components.Schemas, 9)
assert.Len(t, d.Index.GetCircularReferences(), 3) assert.Len(t, d.Index.GetCircularReferences(), 3)
} }

View File

@@ -1154,10 +1154,15 @@ func TestExtractSchema_CheckChildPropCircular(t *testing.T) {
properties: properties:
nothing: nothing:
$ref: '#/components/schemas/Nothing' $ref: '#/components/schemas/Nothing'
required:
- nothing
Nothing: Nothing:
properties: properties:
something: something:
$ref: '#/components/schemas/Something'` $ref: '#/components/schemas/Something'
required:
- something
`
var iNode yaml.Node var iNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &iNode) mErr := yaml.Unmarshal([]byte(yml), &iNode)

View File

@@ -6,13 +6,14 @@ package low
import ( import (
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"io/ioutil"
"os"
"testing"
"github.com/pb33f/libopenapi/index" "github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/resolver" "github.com/pb33f/libopenapi/resolver"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"io/ioutil"
"os"
"testing"
) )
func TestFindItemInMap(t *testing.T) { func TestFindItemInMap(t *testing.T) {
@@ -218,7 +219,6 @@ func TestExtractObject_DoubleRef(t *testing.T) {
} }
func TestExtractObject_DoubleRef_Circular(t *testing.T) { func TestExtractObject_DoubleRef_Circular(t *testing.T) {
yml := `components: yml := `components:
schemas: schemas:
loopy: loopy:
@@ -249,7 +249,6 @@ func TestExtractObject_DoubleRef_Circular(t *testing.T) {
} }
func TestExtractObject_DoubleRef_Circular_Fail(t *testing.T) { func TestExtractObject_DoubleRef_Circular_Fail(t *testing.T) {
yml := `components: yml := `components:
schemas: schemas:
loopy: loopy:

View File

@@ -5,11 +5,12 @@ package low
import ( import (
"crypto/sha256" "crypto/sha256"
"testing"
"github.com/pb33f/libopenapi/index" "github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/resolver" "github.com/pb33f/libopenapi/resolver"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"testing"
) )
func TestNodeReference_IsEmpty(t *testing.T) { func TestNodeReference_IsEmpty(t *testing.T) {
@@ -103,10 +104,15 @@ func TestIsCircular_LookupFromJourney(t *testing.T) {
properties: properties:
nothing: nothing:
$ref: '#/components/schemas/Nothing' $ref: '#/components/schemas/Nothing'
required:
- nothing
Nothing: Nothing:
properties: properties:
something: something:
$ref: '#/components/schemas/Something'` $ref: '#/components/schemas/Something'
required:
- something
`
var iNode yaml.Node var iNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &iNode) mErr := yaml.Unmarshal([]byte(yml), &iNode)
@@ -135,10 +141,15 @@ func TestIsCircular_LookupFromLoopPoint(t *testing.T) {
properties: properties:
nothing: nothing:
$ref: '#/components/schemas/Nothing' $ref: '#/components/schemas/Nothing'
required:
- nothing
Nothing: Nothing:
properties: properties:
something: something:
$ref: '#/components/schemas/Something'` $ref: '#/components/schemas/Something'
required:
- something
`
var iNode yaml.Node var iNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &iNode) mErr := yaml.Unmarshal([]byte(yml), &iNode)
@@ -169,10 +180,15 @@ func TestIsCircular_FromRefLookup(t *testing.T) {
properties: properties:
nothing: nothing:
$ref: '#/components/schemas/Nothing' $ref: '#/components/schemas/Nothing'
required:
- nothing
Nothing: Nothing:
properties: properties:
something: something:
$ref: '#/components/schemas/Something'` $ref: '#/components/schemas/Something'
required:
- something
`
var iNode yaml.Node var iNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &iNode) mErr := yaml.Unmarshal([]byte(yml), &iNode)
@@ -211,10 +227,15 @@ func TestGetCircularReferenceResult_FromJourney(t *testing.T) {
properties: properties:
nothing: nothing:
$ref: '#/components/schemas/Nothing' $ref: '#/components/schemas/Nothing'
required:
- nothing
Nothing: Nothing:
properties: properties:
something: something:
$ref: '#/components/schemas/Something'` $ref: '#/components/schemas/Something'
required:
- something
`
var iNode yaml.Node var iNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &iNode) mErr := yaml.Unmarshal([]byte(yml), &iNode)
@@ -246,10 +267,15 @@ func TestGetCircularReferenceResult_FromLoopPoint(t *testing.T) {
properties: properties:
nothing: nothing:
$ref: '#/components/schemas/Nothing' $ref: '#/components/schemas/Nothing'
required:
- nothing
Nothing: Nothing:
properties: properties:
something: something:
$ref: '#/components/schemas/Something'` $ref: '#/components/schemas/Something'
required:
- something
`
var iNode yaml.Node var iNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &iNode) mErr := yaml.Unmarshal([]byte(yml), &iNode)
@@ -281,10 +307,15 @@ func TestGetCircularReferenceResult_FromMappedRef(t *testing.T) {
properties: properties:
nothing: nothing:
$ref: '#/components/schemas/Nothing' $ref: '#/components/schemas/Nothing'
required:
- nothing
Nothing: Nothing:
properties: properties:
something: something:
$ref: '#/components/schemas/Something'` $ref: '#/components/schemas/Something'
required:
- something
`
var iNode yaml.Node var iNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &iNode) mErr := yaml.Unmarshal([]byte(yml), &iNode)

File diff suppressed because it is too large Load Diff

View File

@@ -4,12 +4,13 @@
package v3 package v3
import ( import (
"testing"
"github.com/pb33f/libopenapi/datamodel/low" "github.com/pb33f/libopenapi/datamodel/low"
"github.com/pb33f/libopenapi/index" "github.com/pb33f/libopenapi/index"
"github.com/pb33f/libopenapi/resolver" "github.com/pb33f/libopenapi/resolver"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"testing"
) )
func TestPaths_Build(t *testing.T) { func TestPaths_Build(t *testing.T) {
@@ -374,6 +375,43 @@ func TestPath_Build_Using_CircularRef(t *testing.T) {
assert.Error(t, err) assert.Error(t, err)
} }
func TestPath_Build_Using_CircularRef_Invalid(t *testing.T) {
// first we need an index.
yml := `paths:
'/something/here':
post:
$ref: '#/paths/~1something~1there/post'
'/something/there':
post:
$ref: '#/paths/~1something~1here/post'`
var idxNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &idxNode)
assert.NoError(t, mErr)
idx := index.NewSpecIndex(&idxNode)
resolve := resolver.NewResolver(idx)
errs := resolve.CheckForCircularReferences()
assert.Len(t, errs, 1)
yml = `"/some/path":
$ref: '#/paths/~1something~1here/post'`
var rootNode yaml.Node
mErr = yaml.Unmarshal([]byte(yml), &rootNode)
assert.NoError(t, mErr)
var n Paths
err := low.BuildModel(rootNode.Content[0], &n)
assert.NoError(t, err)
err = n.Build(rootNode.Content[0], idx)
assert.Error(t, err)
}
func TestPath_Build_Using_CircularRefWithOp(t *testing.T) { func TestPath_Build_Using_CircularRefWithOp(t *testing.T) {
// first we need an index. // first we need an index.

File diff suppressed because it is too large Load Diff

View File

@@ -119,7 +119,7 @@ func TestResolver_ResolveComponents_Stripe(t *testing.T) {
assert.Len(t, circ, 3) assert.Len(t, circ, 3)
assert.Len(t, resolver.GetNonPolymorphicCircularErrors(), 3) assert.Len(t, resolver.GetNonPolymorphicCircularErrors(), 3)
assert.Len(t, resolver.GetPolymorphicCircularErrors(), 20) assert.Len(t, resolver.GetPolymorphicCircularErrors(), 0)
} }
func TestResolver_ResolveComponents_BurgerShop(t *testing.T) { func TestResolver_ResolveComponents_BurgerShop(t *testing.T) {
@@ -225,5 +225,5 @@ func ExampleNewResolver() {
// //
fmt.Printf("There are %d circular reference errors, %d of them are polymorphic errors, %d are not", fmt.Printf("There are %d circular reference errors, %d of them are polymorphic errors, %d are not",
len(circularErrors), len(resolver.GetPolymorphicCircularErrors()), len(resolver.GetNonPolymorphicCircularErrors())) len(circularErrors), len(resolver.GetPolymorphicCircularErrors()), len(resolver.GetNonPolymorphicCircularErrors()))
// Output: There are 23 circular reference errors, 20 of them are polymorphic errors, 3 are not // Output: There are 3 circular reference errors, 0 of them are polymorphic errors, 3 are not
} }