tests: add failing test case for recursive callback reference

This commit is contained in:
Tristan Cartledge
2023-12-04 10:15:31 +00:00
parent 69ba5b875a
commit 2ff7c59585
4 changed files with 49 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
package libopenapi package libopenapi
import ( import (
"bytes"
"fmt" "fmt"
"log/slog" "log/slog"
"os" "os"
@@ -1170,3 +1171,23 @@ func TestDocument_Render_PreserveOrder(t *testing.T) {
}) })
}) })
} }
func TestDocument_AdvanceCallbackReferences(t *testing.T) {
bs, _ := os.ReadFile("test_specs/advancecallbackreferences/min-openapi.yaml")
buf := bytes.NewBuffer([]byte{})
config := datamodel.NewDocumentConfiguration()
config.AllowRemoteReferences = true
config.AllowFileReferences = true
config.BasePath = "test_specs/advancecallbackreferences"
config.Logger = slog.New(slog.NewJSONHandler(buf, &slog.HandlerOptions{Level: slog.LevelError}))
doc, err := NewDocumentWithConfiguration(bs, config)
require.NoError(t, err)
_, errs := doc.BuildV3Model()
require.Empty(t, errs)
assert.Empty(t, buf.String())
}

View File

@@ -0,0 +1,3 @@
test-callback:
"/test-callback":
$ref: "./min-components.yaml#/components/pathItems/test-callback"

View File

@@ -0,0 +1,9 @@
components:
pathItems:
test-callback:
$ref: "#/components/pathItems/test-callback-2"
test-callback-2:
get:
responses:
"200":
description: OK

View File

@@ -0,0 +1,16 @@
openapi: 3.1.0
info:
title: Test
version: 0.0.1
servers:
- url: https://test.com
paths:
/test:
get:
operationId: test
responses:
"200":
description: OK
callbacks:
test:
$ref: "./min-callbacks.yaml#/test-callback"