forked from go-openapi/spec
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Percona-Lab/PMM-5645-0.19.8-percona
PMM-5645 0.19.8 percona
- Loading branch information
Showing
18 changed files
with
315 additions
and
89 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 |
---|---|---|
|
@@ -21,3 +21,8 @@ linters: | |
- lll | ||
- gochecknoinits | ||
- gochecknoglobals | ||
- funlen | ||
- godox | ||
- gocognit | ||
- whitespace | ||
- wsl |
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
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 |
---|---|---|
|
@@ -15,24 +15,34 @@ | |
package spec | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
const contactInfoJSON = `{"name":"wordnik api team","url":"http://developer.wordnik.com","email":"[email protected]"}` | ||
const contactInfoYAML = `name: wordnik api team | ||
url: http://developer.wordnik.com | ||
email: [email protected] | ||
` | ||
const contactInfoJSON = `{ | ||
"name": "wordnik api team", | ||
"url": "http://developer.wordnik.com", | ||
"email": "[email protected]", | ||
"x-teams": "test team" | ||
}` | ||
|
||
var contactInfo = ContactInfo{ | ||
var contactInfo = ContactInfo{ContactInfoProps: ContactInfoProps{ | ||
Name: "wordnik api team", | ||
URL: "http://developer.wordnik.com", | ||
Email: "[email protected]", | ||
} | ||
}, VendorExtensible: VendorExtensible{Extensions: map[string]interface{}{"x-teams": "test team"}}} | ||
|
||
func TestIntegrationContactInfo(t *testing.T) { | ||
assertSerializeJSON(t, contactInfo, contactInfoJSON) | ||
assertSerializeYAML(t, contactInfo, contactInfoYAML) | ||
assertParsesJSON(t, contactInfoJSON, contactInfo) | ||
assertParsesYAML(t, contactInfoYAML, contactInfo) | ||
b, err := json.MarshalIndent(contactInfo, "", "\t") | ||
if assert.NoError(t, err) { | ||
assert.Equal(t, contactInfoJSON, string(b)) | ||
} | ||
|
||
actual := ContactInfo{} | ||
err = json.Unmarshal([]byte(contactInfoJSON), &actual) | ||
if assert.NoError(t, err) { | ||
assert.EqualValues(t, contactInfo, actual) | ||
} | ||
} |
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
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,9 @@ | ||
swagger: "2.0" | ||
info: | ||
version: "1" | ||
title: "nested $ref fixture" | ||
paths: | ||
/dummy: | ||
$ref: ./schemas/api/api.yaml#/paths/~1dummy | ||
/example: | ||
$ref: ./schemas/api/api.yaml#/paths/~1example |
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,19 @@ | ||
swagger: "2.0" | ||
info: | ||
version: "1" | ||
title: "sub api" | ||
paths: | ||
/dummy: | ||
get: | ||
responses: | ||
200: | ||
description: OK | ||
schema: | ||
$ref: ../dummy/dummy.yaml | ||
/example: | ||
get: | ||
responses: | ||
200: | ||
description: OK | ||
schema: | ||
$ref: ../example/example.yaml |
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,5 @@ | ||
required: | ||
- dummyPayload | ||
properties: | ||
dummyPayload: | ||
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,6 @@ | ||
$schema: http://json-schema.org/draft-07/schema# | ||
required: | ||
- payload | ||
properties: | ||
payload: | ||
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
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,51 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "TestSwagger", | ||
"version": "1.0", | ||
"title": "Test" | ||
}, | ||
"host": "127.0.0.1:8443", | ||
"basePath": "/", | ||
"schemes": [ | ||
"https" | ||
], | ||
"paths": { | ||
"/api/v1/getx": { | ||
"post": { | ||
"operationId": "getx", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "Operation successful", | ||
"schema": { | ||
"$ref": "#/definitions/MyObj" | ||
} | ||
} | ||
}, | ||
"security": [] | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"MyObj": { | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string" | ||
}, | ||
"child-objects": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/MyObj" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.