Skip to content

Commit

Permalink
try reproducing getkin#447
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
  • Loading branch information
fenollp committed Nov 15, 2021
1 parent 1cb0303 commit 98a84a8
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions openapi3/loader_recursive_ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,39 @@ func TestLoaderSupportsRecursiveReference(t *testing.T) {
loader.IsExternalRefsAllowed = true
doc, err := loader.LoadFromFile("testdata/recursiveRef/openapi.yml")
require.NoError(t, err)
require.NotNil(t, doc)
require.NoError(t, doc.Validate(loader.Context))
err = doc.Validate(loader.Context)
require.NoError(t, err)
require.Equal(t, "bar", doc.Paths["/foo"].Get.Responses.Get(200).Value.Content.Get("application/json").Schema.Value.Properties["foo2"].Value.Properties["foo"].Value.Properties["bar"].Value.Example)
}

func TestIssue447(t *testing.T) {
loader := NewLoader()
doc, err := loader.LoadFromData([]byte(`
openapi: 3.0.1
info:
title: Recursive refs example
version: "1.0"
paths: {}
components:
schemas:
Complex:
type: object
properties:
parent:
$ref: '#/components/schemas/Complex'
`))
require.NoError(t, err)
err = doc.Validate(loader.Context)
require.NoError(t, err)
require.Equal(t, "object", doc.Components.
// Complex
Schemas["Complex"].
// parent
Value.Properties["parent"].
// parent
Value.Properties["parent"].
// parent
Value.Properties["parent"].
// type
Value.Type)
}

0 comments on commit 98a84a8

Please sign in to comment.