-
-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add couple tests around multiple file-specs (one needs fixing) + some…
… code reuse (#236)
- Loading branch information
Showing
6 changed files
with
106 additions
and
14 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
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,25 @@ | ||
package openapi3 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIssue235OK(t *testing.T) { | ||
loader := NewSwaggerLoader() | ||
loader.IsExternalRefsAllowed = true | ||
doc, err := loader.LoadSwaggerFromFile("testdata/issue235.spec0.yml") | ||
require.NoError(t, err) | ||
err = doc.Validate(loader.Context) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestIssue235CircularDep(t *testing.T) { | ||
t.Skip("TODO: return an error on circular dependencies between external files of a spec") | ||
loader := NewSwaggerLoader() | ||
loader.IsExternalRefsAllowed = true | ||
doc, err := loader.LoadSwaggerFromFile("testdata/issue235.spec0-typo.yml") | ||
require.Nil(t, doc) | ||
require.Error(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: 'OAI Specification in YAML' | ||
version: 0.0.1 | ||
paths: | ||
/test: | ||
get: | ||
responses: | ||
"200": | ||
$ref: '#/components/responses/GetTestOK' | ||
components: | ||
responses: | ||
GetTestOK: | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ObjectA' | ||
schemas: | ||
ObjectA: | ||
type: object | ||
properties: | ||
object_b: | ||
$ref: 'issue235.spec0-typo.yml#/components/schemas/ObjectD' |
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,24 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: 'OAI Specification in YAML' | ||
version: 0.0.1 | ||
paths: | ||
/test: | ||
get: | ||
responses: | ||
"200": | ||
$ref: '#/components/responses/GetTestOK' | ||
components: | ||
responses: | ||
GetTestOK: | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/ObjectA' | ||
schemas: | ||
ObjectA: | ||
type: object | ||
properties: | ||
object_b: | ||
$ref: 'issue235.spec1.yml#/components/schemas/ObjectD' |
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,12 @@ | ||
components: | ||
schemas: | ||
ObjectD: | ||
type: object | ||
properties: | ||
result: | ||
$ref: '#/components/schemas/ObjectE' | ||
|
||
ObjectE: | ||
properties: | ||
name: | ||
$ref: issue235.spec2.yml#/components/schemas/ObjectX |
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: | ||
ObjectX: | ||
type: object | ||
properties: | ||
name: | ||
type: string |