Skip to content

Commit 64b75e2

Browse files
committed
reproduce issue #220
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
1 parent 751a395 commit 64b75e2

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package openapi3
2+
3+
import (
4+
"path/filepath"
5+
"testing"
6+
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
func TestIssue220(t *testing.T) {
11+
specPath := filepath.FromSlash("testdata/my-openapi.json")
12+
13+
loader := NewSwaggerLoader()
14+
loader.IsExternalRefsAllowed = true
15+
doc, err := loader.LoadSwaggerFromFile(specPath)
16+
require.NoError(t, err)
17+
18+
err = doc.Validate(loader.Context)
19+
require.NoError(t, err)
20+
}

openapi3/testdata/my-openapi.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"openapi": "3.0.2",
3+
"info": {
4+
"title": "My API",
5+
"version": "0.1.0"
6+
},
7+
"paths": {
8+
"/foo": {
9+
"get": {
10+
"responses": {
11+
"200": {
12+
"$ref": "my-other-openapi.json#/components/responses/DefaultResponse"
13+
}
14+
}
15+
}
16+
}
17+
}
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"openapi": "3.0.2",
3+
"info": {
4+
"title": "My other API",
5+
"version": "0.1.0"
6+
},
7+
"components": {
8+
"schemas": {
9+
"DefaultObject": {
10+
"type": "object",
11+
"properties": {
12+
"foo": {
13+
"type": "string"
14+
},
15+
"bar": {
16+
"type": "string"
17+
}
18+
}
19+
}
20+
},
21+
"responses": {
22+
"DefaultResponse": {
23+
"description": "",
24+
"content": {
25+
"application/json": {
26+
"schema": {
27+
"$ref": "#/components/schemas/DefaultObject"
28+
}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)