mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 12:37:49 +00:00
tests: add failing test case for recursive callback reference
This commit is contained in:
@@ -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())
|
||||||
|
}
|
||||||
|
|||||||
3
test_specs/advancecallbackreferences/min-callbacks.yaml
Normal file
3
test_specs/advancecallbackreferences/min-callbacks.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
test-callback:
|
||||||
|
"/test-callback":
|
||||||
|
$ref: "./min-components.yaml#/components/pathItems/test-callback"
|
||||||
9
test_specs/advancecallbackreferences/min-components.yaml
Normal file
9
test_specs/advancecallbackreferences/min-components.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
components:
|
||||||
|
pathItems:
|
||||||
|
test-callback:
|
||||||
|
$ref: "#/components/pathItems/test-callback-2"
|
||||||
|
test-callback-2:
|
||||||
|
get:
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
16
test_specs/advancecallbackreferences/min-openapi.yaml
Normal file
16
test_specs/advancecallbackreferences/min-openapi.yaml
Normal 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"
|
||||||
Reference in New Issue
Block a user