forked from getkin/kin-openapi
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pierre Fenoll <[email protected]>
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 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,22 @@ | ||
package openapi3 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLoadOutsideRefs(t *testing.T) { | ||
loader := NewSwaggerLoader() | ||
loader.IsExternalRefsAllowed = true | ||
doc, err := loader.LoadSwaggerFromFile("testdata/303bis/service.yaml") | ||
require.NoError(t, err) | ||
require.NotNil(t, doc) | ||
|
||
err = doc.Validate(loader.Context) | ||
require.NoError(t, err) | ||
|
||
props := doc.Paths["/service"].Get.Responses["200"].Value.Content["application/json"].Schema.Value.Items.Value.Properties | ||
require.NotNil(t, props) | ||
require.Equal(t, "string", props["created_at"].Value.Type) | ||
} |
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,16 @@ | ||
timestamp: | ||
type: string | ||
description: Date and time in ISO 8601 format. | ||
example: "2020-04-09T18:14:30Z" | ||
readOnly: true | ||
nullable: true | ||
|
||
timestamps: | ||
type: object | ||
properties: | ||
created_at: | ||
$ref: "#/timestamp" | ||
deleted_at: | ||
$ref: "#/timestamp" | ||
updated_at: | ||
$ref: "#/timestamp" |
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,28 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: 'some service spec' | ||
version: 1.2.3 | ||
|
||
paths: | ||
/service: | ||
get: | ||
tags: | ||
- services/service | ||
summary: List services | ||
description: List services. | ||
operationId: list-services | ||
responses: | ||
"200": | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/model_service" | ||
|
||
components: | ||
schemas: | ||
model_service: | ||
allOf: | ||
- $ref: "common/properties.yaml#/timestamps" |