-
-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
211 additions
and
1 deletion.
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,28 @@ | ||
package openapi3 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIssue301(t *testing.T) { | ||
sl := NewSwaggerLoader() | ||
sl.IsExternalRefsAllowed = true | ||
|
||
doc, err := sl.LoadSwaggerFromFile("testdata/callbacks.yml") | ||
require.NoError(t, err) | ||
|
||
err = doc.Validate(sl.Context) | ||
require.NoError(t, err) | ||
|
||
transCallbacks := doc.Paths["/trans"].Post.Callbacks["transactionCallback"].Value | ||
require.Equal(t, "object", (*transCallbacks)["http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}"].Post.RequestBody. | ||
Value.Content["application/json"].Schema. | ||
Value.Type) | ||
|
||
otherCallbacks := doc.Paths["/other"].Post.Callbacks["myEvent"].Value | ||
require.Equal(t, "boolean", (*otherCallbacks)["{$request.query.queryUrl}"].Post.RequestBody. | ||
Value.Content["application/json"].Schema. | ||
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
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,10 @@ | ||
post: | ||
requestBody: | ||
description: Callback payload | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: 'callbacks.yml#/components/schemas/SomePayload' | ||
responses: | ||
'200': | ||
description: callback successfully processed |
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,71 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: Callback refd | ||
version: 1.2.3 | ||
paths: | ||
/trans: | ||
post: | ||
description: '' | ||
requestBody: | ||
description: '' | ||
content: | ||
'application/json': | ||
schema: | ||
properties: | ||
id: {type: string} | ||
email: {format: email} | ||
responses: | ||
'201': | ||
description: subscription successfully created | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
callbacks: | ||
transactionCallback: | ||
'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}': | ||
$ref: callback-transactioned.yml | ||
|
||
/other: | ||
post: | ||
description: '' | ||
parameters: | ||
- name: queryUrl | ||
in: query | ||
required: true | ||
description: | | ||
bla | ||
bla | ||
bla | ||
schema: | ||
type: string | ||
format: uri | ||
example: https://example.com | ||
responses: | ||
'201': | ||
description: '' | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
callbacks: | ||
myEvent: | ||
$ref: '#/components/callbacks/MyCallbackEvent' | ||
|
||
components: | ||
schemas: | ||
SomePayload: {type: object} | ||
SomeOtherPayload: {type: boolean} | ||
callbacks: | ||
MyCallbackEvent: | ||
'{$request.query.queryUrl}': | ||
post: | ||
requestBody: | ||
description: Callback payload | ||
content: | ||
'application/json': | ||
schema: | ||
$ref: '#/components/schemas/SomeOtherPayload' | ||
responses: | ||
'200': | ||
description: callback successfully processed |