added more coverage and resolved param ref issue

Signed-off-by: quobix <dave@quobix.com>
This commit is contained in:
quobix
2023-11-03 18:25:27 -04:00
parent fde5a9972d
commit 7d8762fdd9
7 changed files with 76 additions and 22 deletions

View File

@@ -915,6 +915,29 @@ func TestExtractArray_BadBuild(t *testing.T) {
assert.Len(t, things, 0)
}
func TestExtractArray_BadRefPropsTupe(t *testing.T) {
yml := `components:
parameters:
cakes:
limes: cake`
var idxNode yaml.Node
mErr := yaml.Unmarshal([]byte(yml), &idxNode)
assert.NoError(t, mErr)
idx := index.NewSpecIndexWithConfig(&idxNode, index.CreateClosedAPIIndexConfig())
yml = `limes:
$ref: '#/components/parameters/cakes'`
var cNode yaml.Node
e := yaml.Unmarshal([]byte(yml), &cNode)
assert.NoError(t, e)
things, _, _, err := ExtractArray[*test_noGood](context.Background(), "limes", cNode.Content[0], idx)
assert.Error(t, err)
assert.Len(t, things, 0)
}
func TestExtractExample_String(t *testing.T) {
yml := `hi`
var e yaml.Node
@@ -1573,6 +1596,17 @@ func TestExtractMapFlat_Ref_Bad(t *testing.T) {
assert.Len(t, things, 0)
}
/*
'/companies/{companyId}/data/payments/{paymentId}':
parameters:
- $ref: '#/components/parameters/companyId'
get:
tags:
- Accounts receivable
parameters:
- $ref: '#/paths/~1companies~1%7BcompanyId%7D~1connections~1%7BconnectionId%7D~1data~1commerce-payments~1%7BpaymentId%7D/parameters/2'
*/
func TestExtractExtensions(t *testing.T) {
yml := `x-bing: ding