forked from getkin/kin-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix panic slice out of range error getkin#652
Fixes panic from the issue getkin#652, that occurs when trying to load specification from file that contains reference to the file insed of parent directory.
- Loading branch information
Showing
4 changed files
with
46 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package openapi3_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/getkin/kin-openapi/openapi3" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIssue652(t *testing.T) { | ||
loader := openapi3.NewLoader() | ||
loader.IsExternalRefsAllowed = true | ||
|
||
// Test checks that no slice bounds out of range error occurs while loading | ||
// from file that contains reference to file in the parent directory. | ||
require.NotPanics(t, func() { | ||
_, err := loader.LoadFromFile("testdata/issue652/nested/schema.yml") | ||
require.NoError(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
components: | ||
schemas: | ||
TestSchema: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
components: | ||
schemas: | ||
TestObject: | ||
type: object | ||
properties: | ||
reference_to_parent_directory: | ||
$ref: "../definitions.yml#/components/schemas/TestSchema" |