Skip to content

Commit 3c9415b

Browse files
committed
tuned test to bump coverage
Signed-off-by: quobix <[email protected]>
1 parent 96e7818 commit 3c9415b

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

datamodel/low/v3/create_document_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,64 @@ func TestCircularReferenceError(t *testing.T) {
8080
assert.Len(t, err, 3)
8181
}
8282

83+
func TestCircularReference_IgnoreArray(t *testing.T) {
84+
85+
spec := `openapi: 3.1.0
86+
components:
87+
schemas:
88+
ProductCategory:
89+
type: "object"
90+
properties:
91+
name:
92+
type: "string"
93+
children:
94+
type: "array"
95+
items:
96+
$ref: "#/components/schemas/ProductCategory"
97+
description: "Array of sub-categories in the same format."
98+
required:
99+
- "name"
100+
- "children"`
101+
102+
info, _ := datamodel.ExtractSpecInfo([]byte(spec))
103+
circDoc, err := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
104+
AllowFileReferences: false,
105+
AllowRemoteReferences: false,
106+
IgnoreArrayCircularReferences: true,
107+
})
108+
assert.NotNil(t, circDoc)
109+
assert.Len(t, err, 0)
110+
}
111+
112+
func TestCircularReference_IgnorePoly(t *testing.T) {
113+
114+
spec := `openapi: 3.1.0
115+
components:
116+
schemas:
117+
ProductCategory:
118+
type: "object"
119+
properties:
120+
name:
121+
type: "string"
122+
children:
123+
type: "object"
124+
anyOf:
125+
- $ref: "#/components/schemas/ProductCategory"
126+
description: "Array of sub-categories in the same format."
127+
required:
128+
- "name"
129+
- "children"`
130+
131+
info, _ := datamodel.ExtractSpecInfo([]byte(spec))
132+
circDoc, err := CreateDocumentFromConfig(info, &datamodel.DocumentConfiguration{
133+
AllowFileReferences: false,
134+
AllowRemoteReferences: false,
135+
IgnorePolymorphicCircularReferences: true,
136+
})
137+
assert.NotNil(t, circDoc)
138+
assert.Len(t, err, 0)
139+
}
140+
83141
func BenchmarkCreateDocument_Stripe(b *testing.B) {
84142
data, _ := os.ReadFile("../../../test_specs/stripe.yaml")
85143
info, _ := datamodel.ExtractSpecInfo(data)

0 commit comments

Comments
 (0)