From f0e3b3fa0a8980561eedd4cb9bf24e1da8efea25 Mon Sep 17 00:00:00 2001 From: Anatoly Rugalev Date: Wed, 10 Jul 2024 17:45:50 +0200 Subject: [PATCH 1/2] test: add a test for #499 --- openapi3/issue499_test.go | 13 +++++++++++++ openapi3/testdata/issue499/foo.yml | 1 + openapi3/testdata/issue499/main.yml | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 openapi3/issue499_test.go create mode 100644 openapi3/testdata/issue499/foo.yml create mode 100644 openapi3/testdata/issue499/main.yml diff --git a/openapi3/issue499_test.go b/openapi3/issue499_test.go new file mode 100644 index 000000000..3dc980a89 --- /dev/null +++ b/openapi3/issue499_test.go @@ -0,0 +1,13 @@ +package openapi3 + +import ( + "github.com/stretchr/testify/require" + "testing" +) + +func TestIssue499(t *testing.T) { + loader := NewLoader() + loader.IsExternalRefsAllowed = true + _, err := loader.LoadFromFile("testdata/issue499/main.yml") + require.NoError(t, err) +} diff --git a/openapi3/testdata/issue499/foo.yml b/openapi3/testdata/issue499/foo.yml new file mode 100644 index 000000000..2d8bb0e0f --- /dev/null +++ b/openapi3/testdata/issue499/foo.yml @@ -0,0 +1 @@ +type: string \ No newline at end of file diff --git a/openapi3/testdata/issue499/main.yml b/openapi3/testdata/issue499/main.yml new file mode 100644 index 000000000..da1a97256 --- /dev/null +++ b/openapi3/testdata/issue499/main.yml @@ -0,0 +1,24 @@ +openapi: 3.0.0 +info: + title: 'spec' + version: 1.2.3 + +paths: + /foo: + get: + summary: get foo + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/Foo" + +components: + schemas: + Foo: + type: object + properties: + id: + $ref: "./foo.yml" \ No newline at end of file From 727dfc116161169be8a7b94845a06576ae67e895 Mon Sep 17 00:00:00 2001 From: Anatoly Rugalev Date: Wed, 10 Jul 2024 17:46:42 +0200 Subject: [PATCH 2/2] fix imports --- openapi3/issue499_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openapi3/issue499_test.go b/openapi3/issue499_test.go index 3dc980a89..dfbafa9dc 100644 --- a/openapi3/issue499_test.go +++ b/openapi3/issue499_test.go @@ -1,8 +1,9 @@ package openapi3 import ( - "github.com/stretchr/testify/require" "testing" + + "github.com/stretchr/testify/require" ) func TestIssue499(t *testing.T) {