Fix the dependency issue (#231)

This commit is contained in:
Robbie Zhang
2018-06-21 12:09:42 -07:00
committed by GitHub
parent 027b76651d
commit 6ec1098bb8
16629 changed files with 74837 additions and 4975021 deletions

View File

@@ -1,117 +0,0 @@
## Contribution Guidelines
### Pull requests are always welcome
We are always thrilled to receive pull requests, and do our best to
process them as fast as possible. Not sure if that typo is worth a pull
request? Do it! We will appreciate it.
If your pull request is not accepted on the first try, don't be
discouraged! If there's a problem with the implementation, hopefully you
received feedback on what to improve.
We're trying very hard to keep go-swagger lean and focused. We don't want it
to do everything for everybody. This means that we might decide against
incorporating a new feature. However, there might be a way to implement
that feature *on top of* go-swagger.
### Conventions
Fork the repo and make changes on your fork in a feature branch:
- If it's a bugfix branch, name it XXX-something where XXX is the number of the
issue
- If it's a feature branch, create an enhancement issue to announce your
intentions, and name it XXX-something where XXX is the number of the issue.
Submit unit tests for your changes. Go has a great test framework built in; use
it! Take a look at existing tests for inspiration. Run the full test suite on
your branch before submitting a pull request.
Update the documentation when creating or modifying features. Test
your documentation changes for clarity, concision, and correctness, as
well as a clean documentation build. See ``docs/README.md`` for more
information on building the docs and how docs get released.
Write clean code. Universally formatted code promotes ease of writing, reading,
and maintenance. Always run `gofmt -s -w file.go` on each changed file before
committing your changes. Most editors have plugins that do this automatically.
Pull requests descriptions should be as clear as possible and include a
reference to all the issues that they address.
Pull requests must not contain commits from other users or branches.
Commit messages must start with a capitalized and short summary (max. 50
chars) written in the imperative, followed by an optional, more detailed
explanatory text which is separated from the summary by an empty line.
Code review comments may be added to your pull request. Discuss, then make the
suggested modifications and push additional commits to your feature branch. Be
sure to post a comment after pushing. The new commits will show up in the pull
request automatically, but the reviewers will not be notified unless you
comment.
Before the pull request is merged, make sure that you squash your commits into
logical units of work using `git rebase -i` and `git push -f`. After every
commit the test suite should be passing. Include documentation changes in the
same commit so that a revert would remove all traces of the feature or fix.
Commits that fix or close an issue should include a reference like `Closes #XXX`
or `Fixes #XXX`, which will automatically close the issue when merged.
### Sign your work
The sign-off is a simple line at the end of the explanation for the
patch, which certifies that you wrote it or otherwise have the right to
pass it on as an open-source patch. The rules are pretty simple: if you
can certify the below (from
[developercertificate.org](http://developercertificate.org/)):
```
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
660 York Street, Suite 102,
San Francisco, CA 94110 USA
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```
then you just add a line to every git commit message:
Signed-off-by: Joe Smith <joe@gmail.com>
using your real name (sorry, no pseudonyms or anonymous contributions.)
You can add the sign off when creating the git commit via `git commit -s`.

View File

@@ -1,4 +0,0 @@
secrets.yml
coverage.out
*.cov
*.out

View File

@@ -1,22 +0,0 @@
language: go
go:
- 1.7
install:
- go get -u github.com/axw/gocov/gocov
- go get -u gopkg.in/matm/v1/gocov-html
- go get -u github.com/cee-dub/go-junit-report
- go get -u github.com/stretchr/testify/assert
- go get -u github.com/kr/pretty
- go get -u gopkg.in/yaml.v2
- go get -u github.com/go-openapi/analysis
- go get -u github.com/go-openapi/errors
- go get -u github.com/go-openapi/loads
- go get -u github.com/go-openapi/strfmt
- go get -u github.com/go-openapi/runtime
script:
- go test -v -race -cover -coverprofile=coverage.txt -covermode=atomic
after_success:
- bash <(curl -s https://codecov.io/bash)
notifications:
slack:
secure: EmObnQuM9Mw8J9vpFaKKHqSMN4Wsr/A9+v7ewAD5cEhA0T1P4m7MbJMiJOhxUhj/X+BFh2DamW+P2lT8mybj5wg8wnkQ2BteKA8Tawi6f9PRw2NRheO8tAi8o/npLnlmet0kc93mn+oLuqHw36w4+j5mkOl2FghkfGiUVhwrhkCP7KXQN+3TU87e+/HzQumlJ3nsE+6terVxkH3PmaUTsS5ONaODZfuxFpfb7RsoEl3skHf6d+tr+1nViLxxly7558Nc33C+W1mr0qiEvMLZ+kJ/CpGWBJ6CUJM3jm6hNe2eMuIPwEK2hxZob8c7n22VPap4K6a0bBRoydoDXaba+2sD7Ym6ivDO/DVyL44VeBBLyIiIBylDGQdZH+6SoWm90Qe/i7tnY/T5Ao5igT8f3cfQY1c3EsTfqmlDfrhmACBmwSlgkdVBLTprHL63JMY24LWmh4jhxsmMRZhCL4dze8su1w6pLN/pD1pGHtKYCEVbdTmaM3PblNRFf12XB7qosmQsgUndH4Vq3bTbU0s1pKjeDhRyLvFzvR0TBbo0pDLEoF1A/i5GVFWa7yLZNUDudQERRh7qv/xBl2excIaQ1sV4DSVm7bAE9l6Kp+yeHQJW2uN6Y3X8wu9gB9nv9l5HBze7wh8KE6PyWAOLYYqZg9/sAtsv/2GcQqXcKFF1zcA=

View File

@@ -1,74 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View File

@@ -1,3 +0,0 @@
# Validation helpers [![Build Status](https://travis-ci.org/go-openapi/validate.svg?branch=master)](https://travis-ci.org/go-openapi/validate) [![codecov](https://codecov.io/gh/go-openapi/validate/branch/master/graph/badge.svg)](https://codecov.io/gh/go-openapi/validate) [![Slack Status](https://slackin.goswagger.io/badge.svg)](https://slackin.goswagger.io)
[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/go-openapi/validate/master/LICENSE) [![GoDoc](https://godoc.org/github.com/go-openapi/validate?status.svg)](http://godoc.org/github.com/go-openapi/validate)

View File

@@ -1,197 +0,0 @@
---
swagger: '2.0'
info:
version: 0.1.0
title: 'AttendList'
description: |
AttendList service.
contact:
name: API Support
url: http://attendlist.co/support
email: contact@evecon.co
consumes:
- application/json
produces:
- application/json
definitions:
Service:
description: Service information
type: object
properties:
Name:
type: string
readOnly: true
Build:
type: string
readOnly: true
Versions:
description: Representation of Version information
type: object
properties:
Id:
type: integer
format: int64
readOnly: true
Version:
type: integer
format: int64
readOnly: true
Created:
type: integer
format: int64
readOnly: true
Updated:
type: integer
format: int64
readOnly: true
Deleted:
type: boolean
readOnly: true
Dates:
description: Representation of Date interval
type: object
properties:
StartDate:
type: string
format: date-time
EndDate:
type: string
format: date-time
Location:
description: Representation of lat-lon Location
type: object
properties:
Latitude:
type: number
format: float
Longitude:
type: number
format: float
Event:
description: Representation of an Event
allOf:
- $ref: '#/definitions/Versions'
- $ref: '#/definitions/Dates'
- $ref: '#/definitions/Location'
- type: object
properties:
Name:
type: string
URL:
type: string
Notes:
type: string
Autosearch:
type: boolean
example:
StartDate: "2015-11-01T12:00:00Z"
EndDate: "2015-11-05T12:00:00Z"
Latitude: 59.842609
Longitude: 30.319087
Name: "Bikers meeting"
URL: "http://attendlist.co"
Notes: "Yet another bikers meeting"
Autosearch: false
paths:
/services:
get:
description: Get services information.
tags:
- services
operationId: getServices
responses:
'200':
description: Successful response
schema:
title: ArrayOfServices
type: array
items:
$ref: '#/definitions/Service'
default:
description: Generic Error
/events:
get:
description: Get events.
tags:
- events
operationId: getEvents
responses:
'200':
description: Successful response
schema:
title: ArrayOfEvents
type: array
items:
$ref: '#/definitions/Event'
default:
description: Generic Error
post:
description: Create new event.
tags:
- events
operationId: postEvent
parameters:
- name: Event
in: body
description: New events
required: true
schema:
$ref: '#/definitions/Event'
responses:
'201':
description: |
Successful response.
headers:
'Location':
description: Contains link to the new Event resource
type: string
default:
description: Generic Error
/events/{id}:
parameters:
- name: id
in: path
description: Existing event id.
required: true
type: integer
format: int64
get:
description: Get event by id.
tags:
- events
operationId: getEventById
responses:
'200':
description: Successful response
schema:
title: Newly created event
$ref: '#/definitions/Event'
default:
description: Generic Error
put:
description: Update existing event.
tags:
- events
operationId: putEventById
parameters:
- name: Event
in: body
description: Existing event
required: true
schema:
$ref: '#/definitions/Event'
responses:
'204':
description: Successful response
default:
description: Generic Error
delete:
description: Delete event by id.
tags:
- events
operationId: deleteEventById
responses:
'204':
description: Successful response
default:
description: Generic Error

View File

@@ -1,27 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger invalid pattern in headers"
},
"paths": {
"/foo": {
"get": {
"responses": {
"default": {
"headers": {
"X-Foo": {
"type": "array",
"items": {
"type": "string",
"pattern": ")<-- bad pattern"
}
}
},
"description": "Generic Error"
}
}
}
}
}
}

View File

@@ -1,33 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger invalid pattern in headers"
},
"paths": {
"/foo": {
"get": {
"responses": {
"default": {
"headers": {
"X-Foo": {
"type": "string",
"pattern": ")<-- bad pattern"
}
},
"description": "Generic Error"
},
"402": {
"headers": {
"X-Foo": {
"type": "string",
"pattern": ")<-- bad pattern"
}
},
"description": "Generic Error"
}
}
}
}
}
}

View File

@@ -1,36 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger invalid pattern in items"
},
"parameters": {
"fooBody": {
"name": "user",
"in": "body",
"description": "user to add to the system",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string",
"pattern": ")<-- bad pattern"
}
}
}
},
"paths": {
"/foo": {
"parameters": [
{ "$ref": "#/parameters/fooBody" }
],
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
}
}
}

View File

@@ -1,30 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger invalid pattern in parameter"
},
"parameters": {
"userId": {
"name": "userId",
"in": "path",
"type": "string",
"pattern": ")<-- bad pattern",
"required": true
}
},
"paths": {
"/users/{userId}": {
"parameters": [
{ "$ref": "#/parameters/userId" }
],
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
}
}
}

View File

@@ -1,25 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger invalid pattern in schema"
},
"paths": {
"/foo": {
"get": {
"produces": [
"text/plain"
],
"responses": {
"200": {
"description": "Successful",
"schema": {
"type": "string",
"pattern": ")<-- bad pattern"
}
}
}
}
}
}
}

View File

@@ -1,11 +0,0 @@
{
"swagger" : "2.0",
"info" : {
"version" : "1.0",
"title" : "Hello World",
"description" : "Simple Hello World API, with Get operation to one resource path, no request parameters defined"
},
"host" : "api.tibco.com",
"basePath" : "/v1",
"schemes" : [ "http" ]
}

View File

@@ -1,14 +0,0 @@
{
"info" : {
"version" : "1.0",
"title" : "Hello World",
"description" : "Simple Hello World API, with Get operation to one resource path, no request parameters defined"
},
"host" : "api.tibco.com",
"basePath" : "/v1",
"schemes" : [ "http" ],
"paths": {
"/": {
}
}
}

View File

@@ -1,15 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger invalid no responses"
},
"paths": {
"/foo": {
"get": {
"description": "foo",
"responses": {}
}
}
}
}

View File

@@ -1,14 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger invalid no responses"
},
"paths": {
"/foo": {
"get": {
"description": "foo"
}
}
}
}

View File

@@ -1,55 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger parameters with refs"
},
"parameters": {
"userId": {
"name": "userId",
"in": "path",
"type": "string",
"required": true
},
"limit": {
"name": "limit",
"in": "query",
"type": "integer",
"format": "int64"
}
},
"paths": {
"/foo": {
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
},
"/bar": {
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
},
"/users/{userId}": {
"parameters": [{
"$ref": "#/parameters/userId"
}, {
"$ref": "#/parameters/limit"
}],
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
}
}
}

View File

@@ -1,47 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger global parameters"
},
"parameters": {
"userId": {
"name": "userId",
"in": "path",
"type": "string",
"required": true
}
},
"paths": {
"/foo": {
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
},
"/bar": {
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
},
"/users/{userId}": {
"parameters": [{
"$ref": "#/parameters/userId"
}],
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
}
}
}

View File

@@ -1,14 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger of additionalProperties in pathItem"
},
"paths": {
"/": {
"invalid-property": {
"description": "blah"
}
}
}
}

View File

@@ -1,47 +0,0 @@
{
"swagger": "2.0",
"info": {
"version": "0.0.1",
"title": "test of Swagger global parameters"
},
"parameters": {
"userId": {
"name": "userId",
"in": "path",
"type": "string",
"required": true
}
},
"paths": {
"/foo": {
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
},
"/bar": {
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
},
"/users/{userId}": {
"parameters": [
{ "$ref": "#/parameters/userId" }
],
"get": {
"responses": {
"200": {
"description": "Successful"
}
}
}
}
}
}

View File

@@ -1,82 +0,0 @@
[
{
"description": "additionalItems as schema",
"schema": {
"items": [{}],
"additionalItems": {"type": "integer"}
},
"tests": [
{
"description": "additional items match schema",
"data": [ null, 2, 3, 4 ],
"valid": true
},
{
"description": "additional items do not match schema",
"data": [ null, 2, 3, "foo" ],
"valid": false
}
]
},
{
"description": "items is schema, no additionalItems",
"schema": {
"items": {},
"additionalItems": false
},
"tests": [
{
"description": "all items match schema",
"data": [ 1, 2, 3, 4, 5 ],
"valid": true
}
]
},
{
"description": "array of items with no additionalItems",
"schema": {
"items": [{}, {}, {}],
"additionalItems": false
},
"tests": [
{
"description": "no additional items present",
"data": [ 1, 2, 3 ],
"valid": true
},
{
"description": "additional items are not permitted",
"data": [ 1, 2, 3, 4 ],
"valid": false
}
]
},
{
"description": "additionalItems as false without items",
"schema": {"additionalItems": false},
"tests": [
{
"description":
"items defaults to empty schema so everything is valid",
"data": [ 1, 2, 3, 4, 5 ],
"valid": true
},
{
"description": "ignores non-arrays",
"data": {"foo" : "bar"},
"valid": true
}
]
},
{
"description": "additionalItems are allowed by default",
"schema": {"items": [{"type": "integer"}]},
"tests": [
{
"description": "only the first item is validated",
"data": [1, "foo", false],
"valid": true
}
]
}
]

View File

@@ -1,88 +0,0 @@
[
{
"description":
"additionalProperties being false does not allow other properties",
"schema": {
"properties": {"foo": {}, "bar": {}},
"patternProperties": { "^v": {} },
"additionalProperties": false
},
"tests": [
{
"description": "no additional properties is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "an additional property is invalid",
"data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
"valid": false
},
{
"description": "ignores non-objects",
"data": [1, 2, 3],
"valid": true
},
{
"description": "patternProperties are not additional properties",
"data": {"foo":1, "vroom": 2},
"valid": true
}
]
},
{
"description":
"additionalProperties allows a schema which should validate",
"schema": {
"properties": {"foo": {}, "bar": {}},
"additionalProperties": {"type": "boolean"}
},
"tests": [
{
"description": "no additional properties is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "an additional valid property is valid",
"data": {"foo" : 1, "bar" : 2, "quux" : true},
"valid": true
},
{
"description": "an additional invalid property is invalid",
"data": {"foo" : 1, "bar" : 2, "quux" : 12},
"valid": false
}
]
},
{
"description":
"additionalProperties can exist by itself",
"schema": {
"additionalProperties": {"type": "boolean"}
},
"tests": [
{
"description": "an additional valid property is valid",
"data": {"foo" : true},
"valid": true
},
{
"description": "an additional invalid property is invalid",
"data": {"foo" : 1},
"valid": false
}
]
},
{
"description": "additionalProperties are allowed by default",
"schema": {"properties": {"foo": {}, "bar": {}}},
"tests": [
{
"description": "additional properties are allowed",
"data": {"foo": 1, "bar": 2, "quux": true},
"valid": true
}
]
}
]

View File

@@ -1,112 +0,0 @@
[
{
"description": "allOf",
"schema": {
"allOf": [
{
"properties": {
"bar": {"type": "integer"}
},
"required": ["bar"]
},
{
"properties": {
"foo": {"type": "string"}
},
"required": ["foo"]
}
]
},
"tests": [
{
"description": "allOf",
"data": {"foo": "baz", "bar": 2},
"valid": true
},
{
"description": "mismatch second",
"data": {"foo": "baz"},
"valid": false
},
{
"description": "mismatch first",
"data": {"bar": 2},
"valid": false
},
{
"description": "wrong type",
"data": {"foo": "baz", "bar": "quux"},
"valid": false
}
]
},
{
"description": "allOf with base schema",
"schema": {
"properties": {"bar": {"type": "integer"}},
"required": ["bar"],
"allOf" : [
{
"properties": {
"foo": {"type": "string"}
},
"required": ["foo"]
},
{
"properties": {
"baz": {"type": "null"}
},
"required": ["baz"]
}
]
},
"tests": [
{
"description": "valid",
"data": {"foo": "quux", "bar": 2, "baz": null},
"valid": true
},
{
"description": "mismatch base schema",
"data": {"foo": "quux", "baz": null},
"valid": false
},
{
"description": "mismatch first allOf",
"data": {"bar": 2, "baz": null},
"valid": false
},
{
"description": "mismatch second allOf",
"data": {"foo": "quux", "bar": 2},
"valid": false
},
{
"description": "mismatch both",
"data": {"bar": 2},
"valid": false
}
]
},
{
"description": "allOf simple types",
"schema": {
"allOf": [
{"maximum": 30},
{"minimum": 20}
]
},
"tests": [
{
"description": "valid",
"data": 25,
"valid": true
},
{
"description": "mismatch one",
"data": 35,
"valid": false
}
]
}
]

View File

@@ -1,68 +0,0 @@
[
{
"description": "anyOf",
"schema": {
"anyOf": [
{
"type": "integer"
},
{
"minimum": 2
}
]
},
"tests": [
{
"description": "first anyOf valid",
"data": 1,
"valid": true
},
{
"description": "second anyOf valid",
"data": 2.5,
"valid": true
},
{
"description": "both anyOf valid",
"data": 3,
"valid": true
},
{
"description": "neither anyOf valid",
"data": 1.5,
"valid": false
}
]
},
{
"description": "anyOf with base schema",
"schema": {
"type": "string",
"anyOf" : [
{
"maxLength": 2
},
{
"minLength": 4
}
]
},
"tests": [
{
"description": "mismatch base schema",
"data": 3,
"valid": false
},
{
"description": "one anyOf valid",
"data": "foobar",
"valid": true
},
{
"description": "both anyOf invalid",
"data": "foo",
"valid": false
}
]
}
]

View File

@@ -1,49 +0,0 @@
[
{
"description": "invalid type for default",
"schema": {
"properties": {
"foo": {
"type": "integer",
"default": []
}
}
},
"tests": [
{
"description": "valid when property is specified",
"data": {"foo": 13},
"valid": true
},
{
"description": "still valid when the invalid default is used",
"data": {},
"valid": true
}
]
},
{
"description": "invalid string value for default",
"schema": {
"properties": {
"bar": {
"type": "string",
"minLength": 4,
"default": "bad"
}
}
},
"tests": [
{
"description": "valid when property is specified",
"data": {"bar": "good"},
"valid": true
},
{
"description": "still valid when the invalid default is used",
"data": {},
"valid": true
}
]
}
]

View File

@@ -1,32 +0,0 @@
[
{
"description": "valid definition",
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
"tests": [
{
"description": "valid definition schema",
"data": {
"definitions": {
"foo": {"type": "integer"}
}
},
"valid": true
}
]
},
{
"description": "invalid definition",
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
"tests": [
{
"description": "invalid definition schema",
"data": {
"definitions": {
"foo": {"type": 1}
}
},
"valid": false
}
]
}
]

View File

@@ -1,113 +0,0 @@
[
{
"description": "dependencies",
"schema": {
"dependencies": {"bar": ["foo"]}
},
"tests": [
{
"description": "neither",
"data": {},
"valid": true
},
{
"description": "nondependant",
"data": {"foo": 1},
"valid": true
},
{
"description": "with dependency",
"data": {"foo": 1, "bar": 2},
"valid": true
},
{
"description": "missing dependency",
"data": {"bar": 2},
"valid": false
},
{
"description": "ignores non-objects",
"data": "foo",
"valid": true
}
]
},
{
"description": "multiple dependencies",
"schema": {
"dependencies": {"quux": ["foo", "bar"]}
},
"tests": [
{
"description": "neither",
"data": {},
"valid": true
},
{
"description": "nondependants",
"data": {"foo": 1, "bar": 2},
"valid": true
},
{
"description": "with dependencies",
"data": {"foo": 1, "bar": 2, "quux": 3},
"valid": true
},
{
"description": "missing dependency",
"data": {"foo": 1, "quux": 2},
"valid": false
},
{
"description": "missing other dependency",
"data": {"bar": 1, "quux": 2},
"valid": false
},
{
"description": "missing both dependencies",
"data": {"quux": 1},
"valid": false
}
]
},
{
"description": "multiple dependencies subschema",
"schema": {
"dependencies": {
"bar": {
"properties": {
"foo": {"type": "integer"},
"bar": {"type": "integer"}
}
}
}
},
"tests": [
{
"description": "valid",
"data": {"foo": 1, "bar": 2},
"valid": true
},
{
"description": "no dependency",
"data": {"foo": "quux"},
"valid": true
},
{
"description": "wrong type",
"data": {"foo": "quux", "bar": 2},
"valid": false
},
{
"description": "wrong type other",
"data": {"foo": 2, "bar": "quux"},
"valid": false
},
{
"description": "wrong type both",
"data": {"foo": "quux", "bar": "quux"},
"valid": false
}
]
}
]

View File

@@ -1,72 +0,0 @@
[
{
"description": "simple enum validation",
"schema": {"enum": [1, 2, 3]},
"tests": [
{
"description": "one of the enum is valid",
"data": 1,
"valid": true
},
{
"description": "something else is invalid",
"data": 4,
"valid": false
}
]
},
{
"description": "heterogeneous enum validation",
"schema": {"enum": [6, "foo", [], true, {"foo": 12}]},
"tests": [
{
"description": "one of the enum is valid",
"data": [],
"valid": true
},
{
"description": "something else is invalid",
"data": null,
"valid": false
},
{
"description": "objects are deep compared",
"data": {"foo": false},
"valid": false
}
]
},
{
"description": "enums in properties",
"schema": {
"type":"object",
"properties": {
"foo": {"enum":["foo"]},
"bar": {"enum":["bar"]}
},
"required": ["bar"]
},
"tests": [
{
"description": "both properties are valid",
"data": {"foo":"foo", "bar":"bar"},
"valid": true
},
{
"description": "missing optional property is valid",
"data": {"bar":"bar"},
"valid": true
},
{
"description": "missing required property is invalid",
"data": {"foo":"foo"},
"valid": false
},
{
"description": "missing all properties is invalid",
"data": {},
"valid": false
}
]
}
]

View File

@@ -1,143 +0,0 @@
[
{
"description": "validation of date-time strings",
"schema": {"format": "date-time"},
"tests": [
{
"description": "a valid date-time string",
"data": "1963-06-19T08:30:06.283185Z",
"valid": true
},
{
"description": "an invalid date-time string",
"data": "06/19/1963 08:30:06 PST",
"valid": false
},
{
"description": "only RFC3339 not all of ISO 8601 are valid",
"data": "2013-350T01:01:01",
"valid": false
}
]
},
{
"description": "validation of URIs",
"schema": {"format": "uri"},
"tests": [
{
"description": "a valid URI",
"data": "http://foo.bar/?baz=qux#quux",
"valid": true
},
{
"description": "an invalid URI",
"data": "\\\\WINDOWS\\fileshare",
"valid": false
},
{
"description": "an invalid URI though valid URI reference",
"data": "abc",
"valid": false
}
]
},
{
"description": "validation of e-mail addresses",
"schema": {"format": "email"},
"tests": [
{
"description": "a valid e-mail address",
"data": "joe.bloggs@example.com",
"valid": true
},
{
"description": "an invalid e-mail address",
"data": "2962",
"valid": false
}
]
},
{
"description": "validation of IP addresses",
"schema": {"format": "ipv4"},
"tests": [
{
"description": "a valid IP address",
"data": "192.168.0.1",
"valid": true
},
{
"description": "an IP address with too many components",
"data": "127.0.0.0.1",
"valid": false
},
{
"description": "an IP address with out-of-range values",
"data": "256.256.256.256",
"valid": false
},
{
"description": "an IP address without 4 components",
"data": "127.0",
"valid": false
},
{
"description": "an IP address as an integer",
"data": "0x7f000001",
"valid": false
}
]
},
{
"description": "validation of IPv6 addresses",
"schema": {"format": "ipv6"},
"tests": [
{
"description": "a valid IPv6 address",
"data": "::1",
"valid": true
},
{
"description": "an IPv6 address with out-of-range values",
"data": "12345::",
"valid": false
},
{
"description": "an IPv6 address with too many components",
"data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
"valid": false
},
{
"description": "an IPv6 address containing illegal characters",
"data": "::laptop",
"valid": false
}
]
},
{
"description": "validation of host names",
"schema": {"format": "hostname"},
"tests": [
{
"description": "a valid host name",
"data": "www.example.com",
"valid": true
},
{
"description": "a host name starting with an illegal character",
"data": "-a-host-name-that-starts-with--",
"valid": false
},
{
"description": "a host name containing illegal characters",
"data": "not_a_valid_host_name",
"valid": false
},
{
"description": "a host name with a component too long",
"data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
"valid": false
}
]
}
]

View File

@@ -1,61 +0,0 @@
[
{
"description": "a schema given for items",
"schema": {
"items": {"type": "integer"}
},
"tests": [
{
"description": "valid items",
"data": [ 1, 2, 3 ],
"valid": true
},
{
"description": "wrong type of items",
"data": [1, "x"],
"valid": false
},
{
"description": "ignores non-arrays",
"data": {"foo" : "bar"},
"valid": true
}
]
},
{
"description": "an array of schemas for items",
"schema": {
"items": [
{"type": "integer"},
{"type": "string"}
]
},
"tests": [
{
"description": "correct types",
"data": [ 1, "foo" ],
"valid": true
},
{
"description": "wrong types",
"data": [ "foo", 1 ],
"valid": false
},
{
"description": "incomplete array of items",
"data": [ 1 ],
"valid": true
},
{
"description": "array with additional items",
"data": [ 1, "foo", true ],
"valid": true
},
{
"description": "empty array",
"data": [ ],
"valid": true
}
]
}
]

View File

@@ -1,28 +0,0 @@
[
{
"description": "maxItems validation",
"schema": {"maxItems": 2},
"tests": [
{
"description": "shorter is valid",
"data": [1],
"valid": true
},
{
"description": "exact length is valid",
"data": [1, 2],
"valid": true
},
{
"description": "too long is invalid",
"data": [1, 2, 3],
"valid": false
},
{
"description": "ignores non-arrays",
"data": "foobar",
"valid": true
}
]
}
]

View File

@@ -1,33 +0,0 @@
[
{
"description": "maxLength validation",
"schema": {"maxLength": 2},
"tests": [
{
"description": "shorter is valid",
"data": "f",
"valid": true
},
{
"description": "exact length is valid",
"data": "fo",
"valid": true
},
{
"description": "too long is invalid",
"data": "foo",
"valid": false
},
{
"description": "ignores non-strings",
"data": 100,
"valid": true
},
{
"description": "two supplementary Unicode code points is long enough",
"data": "\uD83D\uDCA9\uD83D\uDCA9",
"valid": true
}
]
}
]

View File

@@ -1,28 +0,0 @@
[
{
"description": "maxProperties validation",
"schema": {"maxProperties": 2},
"tests": [
{
"description": "shorter is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "exact length is valid",
"data": {"foo": 1, "bar": 2},
"valid": true
},
{
"description": "too long is invalid",
"data": {"foo": 1, "bar": 2, "baz": 3},
"valid": false
},
{
"description": "ignores non-objects",
"data": "foobar",
"valid": true
}
]
}
]

View File

@@ -1,42 +0,0 @@
[
{
"description": "maximum validation",
"schema": {"maximum": 3.0},
"tests": [
{
"description": "below the maximum is valid",
"data": 2.6,
"valid": true
},
{
"description": "above the maximum is invalid",
"data": 3.5,
"valid": false
},
{
"description": "ignores non-numbers",
"data": "x",
"valid": true
}
]
},
{
"description": "exclusiveMaximum validation",
"schema": {
"maximum": 3.0,
"exclusiveMaximum": true
},
"tests": [
{
"description": "below the maximum is still valid",
"data": 2.2,
"valid": true
},
{
"description": "boundary point is invalid",
"data": 3.0,
"valid": false
}
]
}
]

View File

@@ -1,28 +0,0 @@
[
{
"description": "minItems validation",
"schema": {"minItems": 1},
"tests": [
{
"description": "longer is valid",
"data": [1, 2],
"valid": true
},
{
"description": "exact length is valid",
"data": [1],
"valid": true
},
{
"description": "too short is invalid",
"data": [],
"valid": false
},
{
"description": "ignores non-arrays",
"data": "",
"valid": true
}
]
}
]

View File

@@ -1,33 +0,0 @@
[
{
"description": "minLength validation",
"schema": {"minLength": 2},
"tests": [
{
"description": "longer is valid",
"data": "foo",
"valid": true
},
{
"description": "exact length is valid",
"data": "fo",
"valid": true
},
{
"description": "too short is invalid",
"data": "f",
"valid": false
},
{
"description": "ignores non-strings",
"data": 1,
"valid": true
},
{
"description": "one supplementary Unicode code point is not long enough",
"data": "\uD83D\uDCA9",
"valid": false
}
]
}
]

View File

@@ -1,28 +0,0 @@
[
{
"description": "minProperties validation",
"schema": {"minProperties": 1},
"tests": [
{
"description": "longer is valid",
"data": {"foo": 1, "bar": 2},
"valid": true
},
{
"description": "exact length is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "too short is invalid",
"data": {},
"valid": false
},
{
"description": "ignores non-objects",
"data": "",
"valid": true
}
]
}
]

View File

@@ -1,42 +0,0 @@
[
{
"description": "minimum validation",
"schema": {"minimum": 1.1},
"tests": [
{
"description": "above the minimum is valid",
"data": 2.6,
"valid": true
},
{
"description": "below the minimum is invalid",
"data": 0.6,
"valid": false
},
{
"description": "ignores non-numbers",
"data": "x",
"valid": true
}
]
},
{
"description": "exclusiveMinimum validation",
"schema": {
"minimum": 1.1,
"exclusiveMinimum": true
},
"tests": [
{
"description": "above the minimum is still valid",
"data": 1.2,
"valid": true
},
{
"description": "boundary point is invalid",
"data": 1.1,
"valid": false
}
]
}
]

View File

@@ -1,60 +0,0 @@
[
{
"description": "by int",
"schema": {"multipleOf": 2},
"tests": [
{
"description": "int by int",
"data": 10,
"valid": true
},
{
"description": "int by int fail",
"data": 7,
"valid": false
},
{
"description": "ignores non-numbers",
"data": "foo",
"valid": true
}
]
},
{
"description": "by number",
"schema": {"multipleOf": 1.5},
"tests": [
{
"description": "zero is multiple of anything",
"data": 0,
"valid": true
},
{
"description": "4.5 is multiple of 1.5",
"data": 4.5,
"valid": true
},
{
"description": "35 is not multiple of 1.5",
"data": 35,
"valid": false
}
]
},
{
"description": "by small number",
"schema": {"multipleOf": 0.0001},
"tests": [
{
"description": "0.0075 is multiple of 0.0001",
"data": 0.0075,
"valid": true
},
{
"description": "0.00751 is not multiple of 0.0001",
"data": 0.00751,
"valid": false
}
]
}
]

View File

@@ -1,96 +0,0 @@
[
{
"description": "not",
"schema": {
"not": {"type": "integer"}
},
"tests": [
{
"description": "allowed",
"data": "foo",
"valid": true
},
{
"description": "disallowed",
"data": 1,
"valid": false
}
]
},
{
"description": "not multiple types",
"schema": {
"not": {"type": ["integer", "boolean"]}
},
"tests": [
{
"description": "valid",
"data": "foo",
"valid": true
},
{
"description": "mismatch",
"data": 1,
"valid": false
},
{
"description": "other mismatch",
"data": true,
"valid": false
}
]
},
{
"description": "not more complex schema",
"schema": {
"not": {
"type": "object",
"properties": {
"foo": {
"type": "string"
}
}
}
},
"tests": [
{
"description": "match",
"data": 1,
"valid": true
},
{
"description": "other match",
"data": {"foo": 1},
"valid": true
},
{
"description": "mismatch",
"data": {"foo": "bar"},
"valid": false
}
]
},
{
"description": "forbidden property",
"schema": {
"properties": {
"foo": {
"not": {}
}
}
},
"tests": [
{
"description": "property present",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "property absent",
"data": {"bar": 1, "baz": 2},
"valid": true
}
]
}
]

View File

@@ -1,68 +0,0 @@
[
{
"description": "oneOf",
"schema": {
"oneOf": [
{
"type": "integer"
},
{
"minimum": 2
}
]
},
"tests": [
{
"description": "first oneOf valid",
"data": 1,
"valid": true
},
{
"description": "second oneOf valid",
"data": 2.5,
"valid": true
},
{
"description": "both oneOf valid",
"data": 3,
"valid": false
},
{
"description": "neither oneOf valid",
"data": 1.5,
"valid": false
}
]
},
{
"description": "oneOf with base schema",
"schema": {
"type": "string",
"oneOf" : [
{
"minLength": 2
},
{
"maxLength": 4
}
]
},
"tests": [
{
"description": "mismatch base schema",
"data": 3,
"valid": false
},
{
"description": "one oneOf valid",
"data": "foobar",
"valid": true
},
{
"description": "both oneOf valid",
"data": "foo",
"valid": false
}
]
}
]

View File

@@ -1,107 +0,0 @@
[
{
"description": "integer",
"schema": {"type": "integer"},
"tests": [
{
"description": "a bignum is an integer",
"data": 12345678910111213141516171819202122232425262728293031,
"valid": true
}
]
},
{
"description": "number",
"schema": {"type": "number"},
"tests": [
{
"description": "a bignum is a number",
"data": 98249283749234923498293171823948729348710298301928331,
"valid": true
}
]
},
{
"description": "integer",
"schema": {"type": "integer"},
"tests": [
{
"description": "a negative bignum is an integer",
"data": -12345678910111213141516171819202122232425262728293031,
"valid": true
}
]
},
{
"description": "number",
"schema": {"type": "number"},
"tests": [
{
"description": "a negative bignum is a number",
"data": -98249283749234923498293171823948729348710298301928331,
"valid": true
}
]
},
{
"description": "string",
"schema": {"type": "string"},
"tests": [
{
"description": "a bignum is not a string",
"data": 98249283749234923498293171823948729348710298301928331,
"valid": false
}
]
},
{
"description": "integer comparison",
"schema": {"maximum": 18446744073709551615},
"tests": [
{
"description": "comparison works for high numbers",
"data": 18446744073709551600,
"valid": true
}
]
},
{
"description": "float comparison with high precision",
"schema": {
"maximum": 972783798187987123879878123.18878137,
"exclusiveMaximum": true
},
"tests": [
{
"description": "comparison works for high numbers",
"data": 972783798187987123879878123.188781371,
"valid": false
}
]
},
{
"description": "integer comparison",
"schema": {"minimum": -18446744073709551615},
"tests": [
{
"description": "comparison works for very negative numbers",
"data": -18446744073709551600,
"valid": true
}
]
},
{
"description": "float comparison with high precision on negative numbers",
"schema": {
"minimum": -972783798187987123879878123.18878137,
"exclusiveMinimum": true
},
"tests": [
{
"description": "comparison works for very negative numbers",
"data": -972783798187987123879878123.188781371,
"valid": false
}
]
}
]

View File

@@ -1,13 +0,0 @@
[
{
"description": "ECMA 262 regex non-compliance",
"schema": { "format": "regex" },
"tests": [
{
"description": "ECMA 262 has no support for \\Z anchor from .NET",
"data": "^\\S(|(.|\\n)*\\S)\\Z",
"valid": false
}
]
}
]

View File

@@ -1,148 +0,0 @@
[
{
"description": "validation of date-time strings",
"schema": {"format": "date-time"},
"tests": [
{
"description": "a valid date-time string",
"data": "1963-06-19T08:30:06.283185Z",
"valid": true
},
{
"description": "an invalid date-time string",
"data": "06/19/1963 08:30:06 PST",
"valid": false
},
{
"description": "only RFC3339 not all of ISO 8601 are valid",
"data": "2013-350T01:01:01",
"valid": false
}
]
},
{
"description": "validation of URIs",
"schema": {"format": "uri"},
"tests": [
{
"description": "a valid URI",
"data": "http://foo.bar/?baz=qux#quux",
"valid": true
},
{
"description": "a valid protocol-relative URI",
"data": "//foo.bar/?baz=qux#quux",
"valid": true
},
{
"description": "an invalid URI",
"data": "\\\\WINDOWS\\fileshare",
"valid": false
},
{
"description": "an invalid URI though valid URI reference",
"data": "abc",
"valid": false
}
]
},
{
"description": "validation of e-mail addresses",
"schema": {"format": "email"},
"tests": [
{
"description": "a valid e-mail address",
"data": "joe.bloggs@example.com",
"valid": true
},
{
"description": "an invalid e-mail address",
"data": "2962",
"valid": false
}
]
},
{
"description": "validation of IP addresses",
"schema": {"format": "ipv4"},
"tests": [
{
"description": "a valid IP address",
"data": "192.168.0.1",
"valid": true
},
{
"description": "an IP address with too many components",
"data": "127.0.0.0.1",
"valid": false
},
{
"description": "an IP address with out-of-range values",
"data": "256.256.256.256",
"valid": false
},
{
"description": "an IP address without 4 components",
"data": "127.0",
"valid": false
},
{
"description": "an IP address as an integer",
"data": "0x7f000001",
"valid": false
}
]
},
{
"description": "validation of IPv6 addresses",
"schema": {"format": "ipv6"},
"tests": [
{
"description": "a valid IPv6 address",
"data": "::1",
"valid": true
},
{
"description": "an IPv6 address with out-of-range values",
"data": "12345::",
"valid": false
},
{
"description": "an IPv6 address with too many components",
"data": "1:1:1:1:1:1:1:1:1:1:1:1:1:1:1:1",
"valid": false
},
{
"description": "an IPv6 address containing illegal characters",
"data": "::laptop",
"valid": false
}
]
},
{
"description": "validation of host names",
"schema": {"format": "hostname"},
"tests": [
{
"description": "a valid host name",
"data": "www.example.com",
"valid": true
},
{
"description": "a host name starting with an illegal character",
"data": "-a-host-name-that-starts-with--",
"valid": false
},
{
"description": "a host name containing illegal characters",
"data": "not_a_valid_host_name",
"valid": false
},
{
"description": "a host name with a component too long",
"data": "a-vvvvvvvvvvvvvvvveeeeeeeeeeeeeeeerrrrrrrrrrrrrrrryyyyyyyyyyyyyyyy-long-host-name-component",
"valid": false
}
]
}
]

View File

@@ -1,15 +0,0 @@
[
{
"description": "some languages do not distinguish between different types of numeric value",
"schema": {
"type": "integer"
},
"tests": [
{
"description": "a float is not an integer even without fractional part",
"data": 1.0,
"valid": false
}
]
}
]

View File

@@ -1,34 +0,0 @@
[
{
"description": "pattern validation",
"schema": {"pattern": "^a*$"},
"tests": [
{
"description": "a matching pattern is valid",
"data": "aaa",
"valid": true
},
{
"description": "a non-matching pattern is invalid",
"data": "abc",
"valid": false
},
{
"description": "ignores non-strings",
"data": true,
"valid": true
}
]
},
{
"description": "pattern is not anchored",
"schema": {"pattern": "a+"},
"tests": [
{
"description": "matches a substring",
"data": "xxaayy",
"valid": true
}
]
}
]

View File

@@ -1,110 +0,0 @@
[
{
"description":
"patternProperties validates properties matching a regex",
"schema": {
"patternProperties": {
"f.*o": {"type": "integer"}
}
},
"tests": [
{
"description": "a single valid match is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "multiple valid matches is valid",
"data": {"foo": 1, "foooooo" : 2},
"valid": true
},
{
"description": "a single invalid match is invalid",
"data": {"foo": "bar", "fooooo": 2},
"valid": false
},
{
"description": "multiple invalid matches is invalid",
"data": {"foo": "bar", "foooooo" : "baz"},
"valid": false
},
{
"description": "ignores non-objects",
"data": 12,
"valid": true
}
]
},
{
"description": "multiple simultaneous patternProperties are validated",
"schema": {
"patternProperties": {
"a*": {"type": "integer"},
"aaa*": {"maximum": 20}
}
},
"tests": [
{
"description": "a single valid match is valid",
"data": {"a": 21},
"valid": true
},
{
"description": "a simultaneous match is valid",
"data": {"aaaa": 18},
"valid": true
},
{
"description": "multiple matches is valid",
"data": {"a": 21, "aaaa": 18},
"valid": true
},
{
"description": "an invalid due to one is invalid",
"data": {"a": "bar"},
"valid": false
},
{
"description": "an invalid due to the other is invalid",
"data": {"aaaa": 31},
"valid": false
},
{
"description": "an invalid due to both is invalid",
"data": {"aaa": "foo", "aaaa": 31},
"valid": false
}
]
},
{
"description": "regexes are not anchored by default and are case sensitive",
"schema": {
"patternProperties": {
"[0-9]{2,}": { "type": "boolean" },
"X_": { "type": "string" }
}
},
"tests": [
{
"description": "non recognized members are ignored",
"data": { "answer 1": "42" },
"valid": true
},
{
"description": "recognized members are accounted for",
"data": { "a31b": null },
"valid": false
},
{
"description": "regexes are case sensitive",
"data": { "a_x_3": 3 },
"valid": true
},
{
"description": "regexes are case sensitive, 2",
"data": { "a_X_3": 3 },
"valid": false
}
]
}
]

View File

@@ -1,92 +0,0 @@
[
{
"description": "object properties validation",
"schema": {
"properties": {
"foo": {"type": "integer"},
"bar": {"type": "string"}
}
},
"tests": [
{
"description": "both properties present and valid is valid",
"data": {"foo": 1, "bar": "baz"},
"valid": true
},
{
"description": "one property invalid is invalid",
"data": {"foo": 1, "bar": {}},
"valid": false
},
{
"description": "both properties invalid is invalid",
"data": {"foo": [], "bar": {}},
"valid": false
},
{
"description": "doesn't invalidate other properties",
"data": {"quux": []},
"valid": true
},
{
"description": "ignores non-objects",
"data": [],
"valid": true
}
]
},
{
"description":
"properties, patternProperties, additionalProperties interaction",
"schema": {
"properties": {
"foo": {"type": "array", "maxItems": 3},
"bar": {"type": "array"}
},
"patternProperties": {"f.o": {"minItems": 2}},
"additionalProperties": {"type": "integer"}
},
"tests": [
{
"description": "property validates property",
"data": {"foo": [1, 2]},
"valid": true
},
{
"description": "property invalidates property",
"data": {"foo": [1, 2, 3, 4]},
"valid": false
},
{
"description": "patternProperty invalidates property",
"data": {"foo": []},
"valid": false
},
{
"description": "patternProperty validates nonproperty",
"data": {"fxo": [1, 2]},
"valid": true
},
{
"description": "patternProperty invalidates nonproperty",
"data": {"fxo": []},
"valid": false
},
{
"description": "additionalProperty ignores property",
"data": {"bar": []},
"valid": true
},
{
"description": "additionalProperty validates others",
"data": {"quux": 3},
"valid": true
},
{
"description": "additionalProperty invalidates others",
"data": {"quux": "foo"},
"valid": false
}
]
}
]

View File

@@ -1,212 +0,0 @@
[
{
"description": "root pointer ref",
"schema": {
"properties": {
"foo": {"$ref": "#"}
},
"additionalProperties": false
},
"tests": [
{
"description": "match",
"data": {"foo": false},
"valid": true
},
{
"description": "recursive match",
"data": {"foo": {"foo": false}},
"valid": true
},
{
"description": "mismatch",
"data": {"bar": false},
"valid": false
},
{
"description": "recursive mismatch",
"data": {"foo": {"bar": false}},
"valid": false
}
]
},
{
"description": "relative pointer ref to object",
"schema": {
"properties": {
"foo": {"type": "integer"},
"bar": {"$ref": "#/properties/foo"}
}
},
"tests": [
{
"description": "match",
"data": {"bar": 3},
"valid": true
},
{
"description": "mismatch",
"data": {"bar": true},
"valid": false
}
]
},
{
"description": "relative pointer ref to array",
"schema": {
"items": [
{"type": "integer"},
{"$ref": "#/items/0"}
]
},
"tests": [
{
"description": "match array",
"data": [1, 2],
"valid": true
},
{
"description": "mismatch array",
"data": [1, "foo"],
"valid": false
}
]
},
{
"description": "escaped pointer ref",
"schema": {
"tilda~field": {"type": "integer"},
"slash/field": {"type": "integer"},
"percent%field": {"type": "integer"},
"properties": {
"tilda": {"$ref": "#/tilda~0field"},
"slash": {"$ref": "#/slash~1field"},
"percent": {"$ref": "#/percent%25field"}
}
},
"tests": [
{
"description": "slash invalid",
"data": {"slash": "aoeu"},
"valid": false
},
{
"description": "tilda invalid",
"data": {"tilda": "aoeu"},
"valid": false
},
{
"description": "percent invalid",
"data": {"percent": "aoeu"},
"valid": false
},
{
"description": "slash valid",
"data": {"slash": 123},
"valid": true
},
{
"description": "tilda valid",
"data": {"tilda": 123},
"valid": true
},
{
"description": "percent valid",
"data": {"percent": 123},
"valid": true
}
]
},
{
"description": "nested refs",
"schema": {
"definitions": {
"a": {"type": "integer"},
"b": {"$ref": "#/definitions/a"},
"c": {"$ref": "#/definitions/b"}
},
"$ref": "#/definitions/c"
},
"tests": [
{
"description": "nested ref valid",
"data": 5,
"valid": true
},
{
"description": "nested ref invalid",
"data": "a",
"valid": false
}
]
},
{
"description": "ref overrides any sibling keywords",
"schema": {
"definitions": {
"reffed": {
"type": "array"
}
},
"properties": {
"foo": {
"$ref": "#/definitions/reffed",
"maxItems": 2
}
}
},
"tests": [
{
"description": "ref valid",
"data": { "foo": [] },
"valid": true
},
{
"description": "ref valid, maxItems ignored",
"data": { "foo": [ 1, 2, 3] },
"valid": true
},
{
"description": "ref invalid",
"data": { "foo": "string" },
"valid": false
}
]
},
{
"description": "remote ref, containing refs itself",
"schema": {"$ref": "http://json-schema.org/draft-04/schema#"},
"tests": [
{
"description": "remote ref valid",
"data": {"minLength": 1},
"valid": true
},
{
"description": "remote ref invalid",
"data": {"minLength": -1},
"valid": false
}
]
},
{
"description": "property named $ref that is not a reference",
"schema": {
"properties": {
"$ref": {"type": "string"}
}
},
"tests": [
{
"description": "property named $ref valid",
"data": {"$ref": "a"},
"valid": true
},
{
"description": "property named $ref invalid",
"data": {"$ref": 2},
"valid": false
}
]
}
]

View File

@@ -1,74 +0,0 @@
[
{
"description": "remote ref",
"schema": {"$ref": "http://localhost:1234/integer.json"},
"tests": [
{
"description": "remote ref valid",
"data": 1,
"valid": true
},
{
"description": "remote ref invalid",
"data": "a",
"valid": false
}
]
},
{
"description": "fragment within remote ref",
"schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"},
"tests": [
{
"description": "remote fragment valid",
"data": 1,
"valid": true
},
{
"description": "remote fragment invalid",
"data": "a",
"valid": false
}
]
},
{
"description": "ref within remote ref",
"schema": {
"$ref": "http://localhost:1234/subSchemas.json#/refToInteger"
},
"tests": [
{
"description": "ref within ref valid",
"data": 1,
"valid": true
},
{
"description": "ref within ref invalid",
"data": "a",
"valid": false
}
]
},
{
"description": "change resolution scope",
"schema": {
"id": "http://localhost:1234/",
"items": {
"id": "folder/",
"items": {"$ref": "folderInteger.json"}
}
},
"tests": [
{
"description": "changed scope ref valid",
"data": [[1]],
"valid": true
},
{
"description": "changed scope ref invalid",
"data": [["a"]],
"valid": false
}
]
}
]

View File

@@ -1,3 +0,0 @@
{
"type": "integer"
}

View File

@@ -1,3 +0,0 @@
{
"type": "integer"
}

View File

@@ -1,8 +0,0 @@
{
"integer": {
"type": "integer"
},
"refToInteger": {
"$ref": "#/integer"
}
}

View File

@@ -1,44 +0,0 @@
[
{
"description": "required validation",
"schema": {
"properties": {
"foo": {},
"bar": {}
},
"required": ["foo"]
},
"tests": [
{
"description": "present required property is valid",
"data": {"foo": 1},
"valid": true
},
{
"description": "non-present required property is invalid",
"data": {"bar": 1},
"valid": false
},
{
"description": "ignores non-objects",
"data": 12,
"valid": true
}
]
},
{
"description": "required default validation",
"schema": {
"properties": {
"foo": {}
}
},
"tests": [
{
"description": "not required by default",
"data": {},
"valid": true
}
]
}
]

View File

@@ -1,345 +0,0 @@
[
{
"description": "integer type matches integers",
"schema": {"type": "integer"},
"tests": [
{
"description": "an integer is an integer",
"data": 1,
"valid": true
},
{
"description": "a float is not an integer",
"data": 1.1,
"valid": false
},
{
"description": "a string is not an integer",
"data": "foo",
"valid": false
},
{
"description": "a string is still not an integer, even if it looks like one",
"data": "1",
"valid": false
},
{
"description": "an object is not an integer",
"data": {},
"valid": false
},
{
"description": "an array is not an integer",
"data": [],
"valid": false
},
{
"description": "a boolean is not an integer",
"data": true,
"valid": false
},
{
"description": "null is not an integer",
"data": null,
"valid": false
}
]
},
{
"description": "number type matches numbers",
"schema": {"type": "number"},
"tests": [
{
"description": "an integer is a number",
"data": 1,
"valid": true
},
{
"description": "a float is a number",
"data": 1.1,
"valid": true
},
{
"description": "a string is not a number",
"data": "foo",
"valid": false
},
{
"description": "a string is still not a number, even if it looks like one",
"data": "1",
"valid": false
},
{
"description": "an object is not a number",
"data": {},
"valid": false
},
{
"description": "an array is not a number",
"data": [],
"valid": false
},
{
"description": "a boolean is not a number",
"data": true,
"valid": false
},
{
"description": "null is not a number",
"data": null,
"valid": false
}
]
},
{
"description": "string type matches strings",
"schema": {"type": "string"},
"tests": [
{
"description": "1 is not a string",
"data": 1,
"valid": false
},
{
"description": "a float is not a string",
"data": 1.1,
"valid": false
},
{
"description": "a string is a string",
"data": "foo",
"valid": true
},
{
"description": "a string is still a string, even if it looks like a number",
"data": "1",
"valid": true
},
{
"description": "an object is not a string",
"data": {},
"valid": false
},
{
"description": "an array is not a string",
"data": [],
"valid": false
},
{
"description": "a boolean is not a string",
"data": true,
"valid": false
},
{
"description": "null is not a string",
"data": null,
"valid": false
}
]
},
{
"description": "object type matches objects",
"schema": {"type": "object"},
"tests": [
{
"description": "an integer is not an object",
"data": 1,
"valid": false
},
{
"description": "a float is not an object",
"data": 1.1,
"valid": false
},
{
"description": "a string is not an object",
"data": "foo",
"valid": false
},
{
"description": "an object is an object",
"data": {},
"valid": true
},
{
"description": "an array is not an object",
"data": [],
"valid": false
},
{
"description": "a boolean is not an object",
"data": true,
"valid": false
},
{
"description": "null is not an object",
"data": null,
"valid": false
}
]
},
{
"description": "array type matches arrays",
"schema": {"type": "array"},
"tests": [
{
"description": "an integer is not an array",
"data": 1,
"valid": false
},
{
"description": "a float is not an array",
"data": 1.1,
"valid": false
},
{
"description": "a string is not an array",
"data": "foo",
"valid": false
},
{
"description": "an object is not an array",
"data": {},
"valid": false
},
{
"description": "an array is an array",
"data": [],
"valid": true
},
{
"description": "a boolean is not an array",
"data": true,
"valid": false
},
{
"description": "null is not an array",
"data": null,
"valid": false
}
]
},
{
"description": "boolean type matches booleans",
"schema": {"type": "boolean"},
"tests": [
{
"description": "an integer is not a boolean",
"data": 1,
"valid": false
},
{
"description": "a float is not a boolean",
"data": 1.1,
"valid": false
},
{
"description": "a string is not a boolean",
"data": "foo",
"valid": false
},
{
"description": "an object is not a boolean",
"data": {},
"valid": false
},
{
"description": "an array is not a boolean",
"data": [],
"valid": false
},
{
"description": "a boolean is a boolean",
"data": true,
"valid": true
},
{
"description": "null is not a boolean",
"data": null,
"valid": false
}
]
},
{
"description": "null type matches only the null object",
"schema": {"type": "null"},
"tests": [
{
"description": "an integer is not null",
"data": 1,
"valid": false
},
{
"description": "a float is not null",
"data": 1.1,
"valid": false
},
{
"description": "a string is not null",
"data": "foo",
"valid": false
},
{
"description": "an object is not null",
"data": {},
"valid": false
},
{
"description": "an array is not null",
"data": [],
"valid": false
},
{
"description": "a boolean is not null",
"data": true,
"valid": false
},
{
"description": "null is null",
"data": null,
"valid": true
}
]
},
{
"description": "multiple types can be specified in an array",
"schema": {"type": ["integer", "string"]},
"tests": [
{
"description": "an integer is valid",
"data": 1,
"valid": true
},
{
"description": "a string is valid",
"data": "foo",
"valid": true
},
{
"description": "a float is invalid",
"data": 1.1,
"valid": false
},
{
"description": "an object is invalid",
"data": {},
"valid": false
},
{
"description": "an array is invalid",
"data": [],
"valid": false
},
{
"description": "a boolean is invalid",
"data": true,
"valid": false
},
{
"description": "null is invalid",
"data": null,
"valid": false
}
]
}
]

View File

@@ -1,79 +0,0 @@
[
{
"description": "uniqueItems validation",
"schema": {"uniqueItems": true},
"tests": [
{
"description": "unique array of integers is valid",
"data": [1, 2],
"valid": true
},
{
"description": "non-unique array of integers is invalid",
"data": [1, 1],
"valid": false
},
{
"description": "numbers are unique if mathematically unequal",
"data": [1.0, 1.00, 1],
"valid": false
},
{
"description": "unique array of objects is valid",
"data": [{"foo": "bar"}, {"foo": "baz"}],
"valid": true
},
{
"description": "non-unique array of objects is invalid",
"data": [{"foo": "bar"}, {"foo": "bar"}],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
{"foo": {"bar" : {"baz" : true}}},
{"foo": {"bar" : {"baz" : false}}}
],
"valid": true
},
{
"description": "non-unique array of nested objects is invalid",
"data": [
{"foo": {"bar" : {"baz" : true}}},
{"foo": {"bar" : {"baz" : true}}}
],
"valid": false
},
{
"description": "unique array of arrays is valid",
"data": [["foo"], ["bar"]],
"valid": true
},
{
"description": "non-unique array of arrays is invalid",
"data": [["foo"], ["foo"]],
"valid": false
},
{
"description": "1 and true are unique",
"data": [1, true],
"valid": true
},
{
"description": "0 and false are unique",
"data": [0, false],
"valid": true
},
{
"description": "unique heterogeneous types are valid",
"data": [{}, [1], true, null, 1],
"valid": true
},
{
"description": "non-unique heterogeneous types are invalid",
"data": [{}, [1], true, null, {}, 1],
"valid": false
}
]
}
]

View File

@@ -1,12 +0,0 @@
type: object
required:
- title
properties:
id:
type: integer
format: uint64
readOnly: true
title:
type: string
minLength: 2
maxLength: 80

View File

@@ -1,30 +0,0 @@
---
swagger: "2.0"
info:
title: Item API
description: Item API
version: "1.0.0"
host: item.api.local
basePath: /v1
securityDefinitions:
key:
type: apiKey
name: x-item-token
in: header
security:
- key: []
consumes:
- application/json
produces:
- application/json
schemes:
- http
paths:
/item:
get:
operationId: GetItem
responses:
200:
description: item detail response
schema:
"$ref": "item.yaml"

View File

@@ -1,15 +0,0 @@
item:
type: object
required:
- title
properties:
id:
type: integer
format: uint64
readOnly: true
title:
type: string
minLength: 2
maxLength: 80
subitem:
$ref: "item.yaml#/item"

View File

@@ -1,38 +0,0 @@
---
swagger: "2.0"
info:
title: Item API
description: Item API
version: "1.0.0"
host: item.api.local
basePath: /v1
securityDefinitions:
key:
type: apiKey
name: x-item-token
in: header
security:
- key: []
consumes:
- application/json
produces:
- application/json
schemes:
- http
responses:
itemResponse:
description: Item
schema:
$ref: "item.yaml#/item"
paths:
/item:
get:
operationId: GetItem
responses:
200:
description: item detail response
schema:
$ref: "item.yaml#/item"
default:
$ref: "#/responses/itemResponse"

View File

@@ -1,39 +0,0 @@
{
"schema": {
"type": "object",
"properties": {
"sizes": {
"type": "object",
"properties": {
"first": {
"type": "object",
"properties": {
"count": {
"type": "integer",
"default": 3,
"enum": [3, 5, 7]
}
},
"required": ["count"]
}
},
"required": ["first"]
}
},
"required": ["sizes"]
},
"valid": {
"sizes": {
"first": {
"count": 3
}
}
},
"invalid": {
"sizes": {
"first": {
"count": 2
}
}
}
}

View File

@@ -1,138 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Circular1": {
"allOf": [{
"$ref": "#/definitions/Circular2"
}, {
"properties": {
"age": {
"type": "integer",
"format": "int32"
}
}
}]
},
"Circular2": {
"allOf": [{
"$ref": "#/definitions/Circular1"
}, {
"properties": {
"createdAt": {
"type": "string",
"format": "date-time"
}
}
}]
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,137 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"ValidChild": {
"allOf": [{
"$ref": "#/definitions/Parent"
}, {
"properties": {
"age": {
"type": "integer",
"format": "int32"
}
}
}]
},
"InvalidChild": {
"allOf": [{
"$ref": "#/definitions/Parent"
}, {
"properties": {
"name": {
"type": "string"
}
}
}]
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,119 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets/{}": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [{
"name": "limit",
"in": "query",
"description": "number of items to return in the result",
"type": "array",
"collectionFormat": "csv",
"items": {
"type": "integer",
"format": "int32",
"default": "20"
}
}],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,132 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Circular2": {
"allOf": [{
"$ref": "#/definitions/Circular1"
}, {
"properties": {
"createdAt": {
"type": "string",
"format": "date-time"
}
}
}]
},
"Parent": {
"allOf": [{
"$ref": "#/definitions/Circular2"
}]
},
"Circular1": {
"allOf": [{
"$ref": "#/definitions/Parent"
}, {
"properties": {
"age": {
"type": "integer",
"format": "int32"
}
}
}]
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,117 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"headers": {
"X-Rate-Limit": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"default": "20"
}
}
},
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,114 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"headers": {
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"default": "20"
}
},
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,119 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [{
"name": "limit",
"in": "query",
"description": "number of items to return in the result",
"type": "array",
"collectionFormat": "csv",
"items": {
"type": "integer",
"format": "int32",
"default": "20"
}
}],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,119 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"parameters": {
"limit": {
"name": "limit",
"in": "query",
"description": "number of items to return in the result",
"type": "integer",
"format": "int32",
"default": "20"
}
},
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [{
"$ref": "#/parameters/limit"
}],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,117 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [
{
"name": "limit",
"in": "query",
"description": "number of items to return in the result",
"type": "integer",
"format": "int32",
"default": "20"
}
],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,111 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"additionalProperties": {
"type": "integer",
"format": "int32",
"default": "20"
}
}
}
}

View File

@@ -1,118 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"allOf": [
{
"properties": {
"id": {
"type": "integer",
"format": "int64",
"default": "20"
},
"name": {
"type": "string"
}
}
},
{
"properties": {
"notes": {
"type": "string"
}
}
}
]
}
}
}

View File

@@ -1,114 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"extra": {
"type": "array",
"items": {
"type": "integer",
"format": "int64",
"default": "20"
}
}
}
}
}
}

View File

@@ -1,113 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"patternProperties": {
"nb-.*": {
"type": "integer",
"format": "int64",
"default": "20"
}
}
}
}
}

View File

@@ -1,108 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64",
"default": "20"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,107 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64",
"default": "20"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,119 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"$ref": "#/responses/petListResponse"
}
}
}
}
},
"responses": {
"petListResponse": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"examples": {
"application/json": [{
"id": 123,
"photoUrls": [
"https://cloud.githubusercontent.com/assets/987686/9987390/24bd7be0-607a-11e5-9c3a-e0c6f333a764.png"
]
}]
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,114 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"examples": {
"application/json": [{
"id": 123,
"photoUrls": [
"https://cloud.githubusercontent.com/assets/987686/9987390/24bd7be0-607a-11e5-9c3a-e0c6f333a764.png"
]
}]
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,128 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [{
"name": "limit",
"in": "formData",
"description": "number of items to return in the result",
"type": "array",
"collectionFormat": "csv",
"items": {
"type": "integer",
"format": "int32",
"default": 20
}
}, {
"name": "bodyParam",
"in": "body",
"description": "number of items to return in the result",
"schema": {
"type": "integer",
"format": "int32",
"default": 20
}
}],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,107 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/DoesNotExist"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,31 +0,0 @@
---
swagger: "2.0"
info:
version: "0.1.0"
title: referenced validation invalid
paths:
/:
get:
responses:
default:
description: the record
parameters:
rateLimit:
name: X-Rate-Limit
in: header
type: integer
format: int32
responses:
notFound:
description: Not found
definitions:
record:
type: object
properties:
createdAt:
type: string
format: date-time

View File

@@ -1,137 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"ValidChild": {
"allOf": [{
"$ref": "#/definitions/Parent"
}, {
"properties": {
"age": {
"type": "integer",
"format": "int32"
}
}
}]
},
"InvalidChild": {
"allOf": [{
"$ref": "#/definitions/ValidChild"
}, {
"properties": {
"name": {
"type": "string"
}
}
}]
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,130 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Circular2": {
"allOf": [{
"$ref": "#/definitions/Circular1"
}, {
"properties": {
"createdAt": {
"type": "string",
"format": "date-time"
}
}
}]
},
"Parent": {
"$ref": "#/definitions/Circular2"
},
"Circular1": {
"allOf": [{
"$ref": "#/definitions/Parent"
}, {
"properties": {
"age": {
"type": "integer",
"format": "int32"
}
}
}]
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,117 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"headers": {
"X-Rate-Limit": {
"type": "array",
"items": {
"type": "integer",
"format": "int32",
"default": 20
}
}
},
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,114 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"headers": {
"X-Rate-Limit": {
"type": "integer",
"format": "int32",
"default": 20
}
},
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,119 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [{
"name": "limit",
"in": "query",
"description": "number of items to return in the result",
"type": "array",
"collectionFormat": "csv",
"items": {
"type": "integer",
"format": "int32",
"default": 20
}
}],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,119 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"parameters": {
"limit": {
"name": "limit",
"in": "query",
"description": "number of items to return in the result",
"type": "integer",
"format": "int32",
"default": 20
}
},
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [{
"$ref": "#/parameters/limit"
}],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,116 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"parameters": [
{
"name": "limit",
"in": "query",
"description": "number of items to return in the result",
"type": "integer",
"format": "int32",
"default": 20
}
],
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,111 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"additionalProperties": {
"type": "integer",
"format": "int32",
"default": 20
}
}
}
}

View File

@@ -1,118 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"allOf": [
{
"properties": {
"id": {
"type": "integer",
"format": "int64",
"default": 20
},
"name": {
"type": "string"
}
}
},
{
"properties": {
"notes": {
"type": "string"
}
}
}
]
}
}
}

View File

@@ -1,107 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,114 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"patternProperties": {
"nb-.*": {
"type": "integer",
"format": "int64",
"default": 20
}
}
}
}
}

View File

@@ -1,107 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64",
"default": 20
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,115 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64",
"default": 20
},
"name": {
"type": "string"
},
"extra": {
"type": "array",
"items": {
"type": "integer",
"format": "int64",
"default": 20
}
}
}
}
}
}

View File

@@ -1,120 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"$ref": "#/responses/petListResponse"
}
}
}
}
},
"responses": {
"petListResponse": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"examples": {
"application/json": [{
"id": 123,
"photoUrls": [
"https://cloud.githubusercontent.com/assets/987686/9987390/24bd7be0-607a-11e5-9c3a-e0c6f333a764.png"
],
"name": "issue 63 response ref example"
}]
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,115 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
},
"examples": {
"application/json": [{
"id": 123,
"photoUrls": [
"https://cloud.githubusercontent.com/assets/987686/9987390/24bd7be0-607a-11e5-9c3a-e0c6f333a764.png"
],
"name": "issue 63 response ref example"
}]
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,107 +0,0 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.wordnik.com) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
"version": "1.0.0",
"title": "Swagger Petstore",
"termsOfService": "http://helloreverb.com/terms/",
"contact": {
"name": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/v2",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"tags": ["pet"],
"summary": "list the pets",
"operationId": "getPets",
"responses": {
"default": {
"description": "Generic Error"
},
"200": {
"description": "Pets list",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
}
}
}
}
},
"definitions": {
"Parent": {
"$ref": "#/definitions/Category"
},
"Category": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"required": [
"name",
"photoUrls"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"$ref": "#/definitions/Category"
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/Tag"
}
},
"status": {
"type": "string",
"description": "pet status in the store"
}
}
},
"Tag": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
}
}

View File

@@ -1,39 +0,0 @@
---
swagger: "2.0"
info:
version: "0.1.0"
title: referenced validation
paths:
/:
get:
parameters:
- $ref: "#/parameters/rateLimit"
responses:
default:
description: the record
schema:
$ref: "#/definitions/record"
404:
$ref: "#/responses/notFound"
parameters:
rateLimit:
name: X-Rate-Limit
in: header
type: integer
format: int32
responses:
notFound:
description: Not found
schema:
$ref: "#/definitions/record"
definitions:
record:
type: object
properties:
createdAt:
type: string
format: date-time

View File

@@ -1,517 +0,0 @@
// Copyright 2015 go-swagger maintainers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package validate
import (
"encoding/json"
"fmt"
"testing"
"github.com/go-openapi/errors"
"github.com/go-openapi/spec"
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
)
type email struct {
Address string
}
type paramFactory func(string) *spec.Parameter
var paramFactories = []paramFactory{
spec.QueryParam,
spec.HeaderParam,
spec.PathParam,
spec.FormDataParam,
}
var stringItems = new(spec.Items)
func init() {
stringItems.Type = "string"
}
func requiredError(param *spec.Parameter) *errors.Validation {
return errors.Required(param.Name, param.In)
}
func maxErrorItems(path, in string, items *spec.Items) *errors.Validation {
return errors.ExceedsMaximum(path, in, *items.Maximum, items.ExclusiveMaximum)
}
func minErrorItems(path, in string, items *spec.Items) *errors.Validation {
return errors.ExceedsMinimum(path, in, *items.Minimum, items.ExclusiveMinimum)
}
func multipleOfErrorItems(path, in string, items *spec.Items) *errors.Validation {
return errors.NotMultipleOf(path, in, *items.MultipleOf)
}
func requiredErrorItems(path, in string) *errors.Validation {
return errors.Required(path, in)
}
func maxLengthErrorItems(path, in string, items *spec.Items) *errors.Validation {
return errors.TooLong(path, in, *items.MaxLength)
}
func minLengthErrorItems(path, in string, items *spec.Items) *errors.Validation {
return errors.TooShort(path, in, *items.MinLength)
}
func patternFailItems(path, in string, items *spec.Items) *errors.Validation {
return errors.FailedPattern(path, in, items.Pattern)
}
func enumFailItems(path, in string, items *spec.Items, data interface{}) *errors.Validation {
return errors.EnumFail(path, in, data, items.Enum)
}
func minItemsErrorItems(path, in string, items *spec.Items) *errors.Validation {
return errors.TooFewItems(path, in, *items.MinItems)
}
func maxItemsErrorItems(path, in string, items *spec.Items) *errors.Validation {
return errors.TooManyItems(path, in, *items.MaxItems)
}
func duplicatesErrorItems(path, in string) *errors.Validation {
return errors.DuplicateItems(path, in)
}
func TestNumberItemsValidation(t *testing.T) {
values := [][]interface{}{
[]interface{}{23, 49, 56, 21, 14, 35, 28, 7, 42},
[]interface{}{uint(23), uint(49), uint(56), uint(21), uint(14), uint(35), uint(28), uint(7), uint(42)},
[]interface{}{float64(23), float64(49), float64(56), float64(21), float64(14), float64(35), float64(28), float64(7), float64(42)},
}
for i, v := range values {
items := spec.NewItems()
items.WithMaximum(makeFloat(v[1]), false)
items.WithMinimum(makeFloat(v[3]), false)
items.WithMultipleOf(makeFloat(v[7]))
items.WithEnum(v[3], v[6], v[8], v[1])
items.Typed("integer", "int32")
parent := spec.QueryParam("factors").CollectionOf(items, "")
path := fmt.Sprintf("factors.%d", i)
validator := newItemsValidator(parent.Name, parent.In, items, parent, strfmt.Default)
// MultipleOf
err := validator.Validate(i, v[0])
assert.True(t, err.HasErrors())
assert.EqualError(t, multipleOfErrorItems(path, validator.in, items), err.Errors[0].Error())
// Maximum
err = validator.Validate(i, v[1])
assert.True(t, err == nil || err.IsValid())
err = validator.Validate(i, v[2])
assert.True(t, err.HasErrors())
assert.EqualError(t, maxErrorItems(path, validator.in, items), err.Errors[0].Error())
// ExclusiveMaximum
items.ExclusiveMaximum = true
// requires a new items validator because this is set a creation time
validator = newItemsValidator(parent.Name, parent.In, items, parent, strfmt.Default)
err = validator.Validate(i, v[1])
assert.True(t, err.HasErrors())
assert.EqualError(t, maxErrorItems(path, validator.in, items), err.Errors[0].Error())
// Minimum
err = validator.Validate(i, v[3])
assert.True(t, err == nil || err.IsValid())
err = validator.Validate(i, v[4])
assert.True(t, err.HasErrors())
assert.EqualError(t, minErrorItems(path, validator.in, items), err.Errors[0].Error())
// ExclusiveMinimum
items.ExclusiveMinimum = true
// requires a new items validator because this is set a creation time
validator = newItemsValidator(parent.Name, parent.In, items, parent, strfmt.Default)
err = validator.Validate(i, v[3])
assert.True(t, err.HasErrors())
assert.EqualError(t, minErrorItems(path, validator.in, items), err.Errors[0].Error())
// Enum
err = validator.Validate(i, v[5])
assert.True(t, err.HasErrors())
assert.EqualError(t, enumFailItems(path, validator.in, items, v[5]), err.Errors[0].Error())
// Valid passes
err = validator.Validate(i, v[6])
assert.True(t, err == nil || err.IsValid())
}
}
func TestStringItemsValidation(t *testing.T) {
items := spec.NewItems().WithMinLength(3).WithMaxLength(5).WithPattern(`^[a-z]+$`).Typed("string", "")
items.WithEnum("aaa", "bbb", "ccc")
parent := spec.QueryParam("tags").CollectionOf(items, "")
path := parent.Name + ".1"
validator := newItemsValidator(parent.Name, parent.In, items, parent, strfmt.Default)
// required
err := validator.Validate(1, "")
assert.True(t, err.HasErrors())
assert.EqualError(t, minLengthErrorItems(path, validator.in, items), err.Errors[0].Error())
// MaxLength
err = validator.Validate(1, "abcdef")
assert.True(t, err.HasErrors())
assert.EqualError(t, maxLengthErrorItems(path, validator.in, items), err.Errors[0].Error())
// MinLength
err = validator.Validate(1, "a")
assert.True(t, err.HasErrors())
assert.EqualError(t, minLengthErrorItems(path, validator.in, items), err.Errors[0].Error())
// Pattern
err = validator.Validate(1, "a394")
assert.True(t, err.HasErrors())
assert.EqualError(t, patternFailItems(path, validator.in, items), err.Errors[0].Error())
// Enum
err = validator.Validate(1, "abcde")
assert.True(t, err.HasErrors())
assert.EqualError(t, enumFailItems(path, validator.in, items, "abcde"), err.Errors[0].Error())
// Valid passes
err = validator.Validate(1, "bbb")
assert.True(t, err == nil || err.IsValid())
}
func TestArrayItemsValidation(t *testing.T) {
items := spec.NewItems().CollectionOf(stringItems, "").WithMinItems(1).WithMaxItems(5).UniqueValues()
items.WithEnum("aaa", "bbb", "ccc")
parent := spec.QueryParam("tags").CollectionOf(items, "")
path := parent.Name + ".1"
validator := newItemsValidator(parent.Name, parent.In, items, parent, strfmt.Default)
// MinItems
err := validator.Validate(1, []string{})
assert.True(t, err.HasErrors())
assert.EqualError(t, minItemsErrorItems(path, validator.in, items), err.Errors[0].Error())
// MaxItems
err = validator.Validate(1, []string{"a", "b", "c", "d", "e", "f"})
assert.True(t, err.HasErrors())
assert.EqualError(t, maxItemsErrorItems(path, validator.in, items), err.Errors[0].Error())
// UniqueItems
err = validator.Validate(1, []string{"a", "a"})
assert.True(t, err.HasErrors())
assert.EqualError(t, duplicatesErrorItems(path, validator.in), err.Errors[0].Error())
// Enum
err = validator.Validate(1, []string{"a", "b", "c"})
assert.True(t, err.HasErrors())
assert.EqualError(t, enumFailItems(path, validator.in, items, []string{"a", "b", "c"}), err.Errors[0].Error())
// Items
strItems := spec.NewItems().WithMinLength(3).WithMaxLength(5).WithPattern(`^[a-z]+$`).Typed("string", "")
items = spec.NewItems().CollectionOf(strItems, "").WithMinItems(1).WithMaxItems(5).UniqueValues()
validator = newItemsValidator(parent.Name, parent.In, items, parent, strfmt.Default)
err = validator.Validate(1, []string{"aa", "bbb", "ccc"})
assert.True(t, err.HasErrors())
assert.EqualError(t, minLengthErrorItems(path+".0", parent.In, strItems), err.Errors[0].Error())
}
// PetStoreJSONMessage json raw message for Petstore20
var PetStoreJSONMessage = json.RawMessage([]byte(PetStore20))
// PetStore20 json doc for swagger 2.0 pet store
const PetStore20 = `{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Swagger Petstore",
"contact": {
"name": "Wordnik API Team",
"url": "http://developer.wordnik.com"
},
"license": {
"name": "Creative Commons 4.0 International",
"url": "http://creativecommons.org/licenses/by/4.0/"
}
},
"host": "petstore.swagger.wordnik.com",
"basePath": "/api",
"schemes": [
"http"
],
"paths": {
"/pets": {
"get": {
"security": [
{
"basic": []
}
],
"tags": [ "Pet Operations" ],
"operationId": "getAllPets",
"parameters": [
{
"name": "status",
"in": "query",
"description": "The status to filter by",
"type": "string"
},
{
"name": "limit",
"in": "query",
"description": "The maximum number of results to return",
"type": "integer",
"format": "int64"
}
],
"summary": "Finds all pets in the system",
"responses": {
"200": {
"description": "Pet response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"post": {
"security": [
{
"basic": []
}
],
"tags": [ "Pet Operations" ],
"operationId": "createPet",
"summary": "Creates a new pet",
"consumes": ["application/x-yaml"],
"produces": ["application/x-yaml"],
"parameters": [
{
"name": "pet",
"in": "body",
"description": "The Pet to create",
"required": true,
"schema": {
"$ref": "#/definitions/newPet"
}
}
],
"responses": {
"200": {
"description": "Created Pet response",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/pets/{id}": {
"delete": {
"security": [
{
"apiKey": []
}
],
"description": "Deletes the Pet by id",
"operationId": "deletePet",
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet to delete",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"204": {
"description": "pet deleted"
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"get": {
"tags": [ "Pet Operations" ],
"operationId": "getPetById",
"summary": "Finds the pet by id",
"responses": {
"200": {
"description": "Pet response",
"schema": {
"$ref": "#/definitions/Pet"
}
},
"default": {
"description": "Unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"description": "ID of pet",
"required": true,
"type": "integer",
"format": "int64"
}
]
}
},
"definitions": {
"Category": {
"id": "Category",
"properties": {
"id": {
"format": "int64",
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"Pet": {
"id": "Pet",
"properties": {
"category": {
"$ref": "#/definitions/Category"
},
"id": {
"description": "unique identifier for the pet",
"format": "int64",
"maximum": 100.0,
"minimum": 0.0,
"type": "integer"
},
"name": {
"type": "string"
},
"photoUrls": {
"items": {
"type": "string"
},
"type": "array"
},
"status": {
"description": "pet status in the store",
"enum": [
"available",
"pending",
"sold"
],
"type": "string"
},
"tags": {
"items": {
"$ref": "#/definitions/Tag"
},
"type": "array"
}
},
"required": [
"id",
"name"
]
},
"newPet": {
"anyOf": [
{
"$ref": "#/definitions/Pet"
},
{
"required": [
"name"
]
}
]
},
"Tag": {
"id": "Tag",
"properties": {
"id": {
"format": "int64",
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"Error": {
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
},
"consumes": [
"application/json",
"application/xml"
],
"produces": [
"application/json",
"application/xml",
"text/plain",
"text/html"
],
"securityDefinitions": {
"basic": {
"type": "basic"
},
"apiKey": {
"type": "apiKey",
"in": "header",
"name": "X-API-KEY"
}
}
}
`

View File

@@ -1,230 +0,0 @@
// Copyright 2015 go-swagger maintainers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package validate
import (
"reflect"
"testing"
"github.com/go-openapi/errors"
"github.com/go-openapi/spec"
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
)
// common validations: enum, allOf, anyOf, oneOf, not, definitions
func maxError(param *spec.Parameter) *errors.Validation {
return errors.ExceedsMaximum(param.Name, param.In, *param.Maximum, param.ExclusiveMaximum)
}
func minError(param *spec.Parameter) *errors.Validation {
return errors.ExceedsMinimum(param.Name, param.In, *param.Minimum, param.ExclusiveMinimum)
}
func multipleOfError(param *spec.Parameter) *errors.Validation {
return errors.NotMultipleOf(param.Name, param.In, *param.MultipleOf)
}
func makeFloat(data interface{}) float64 {
val := reflect.ValueOf(data)
knd := val.Kind()
switch {
case knd >= reflect.Int && knd <= reflect.Int64:
return float64(val.Int())
case knd >= reflect.Uint && knd <= reflect.Uint64:
return float64(val.Uint())
default:
return val.Float()
}
}
func TestNumberParameterValidation(t *testing.T) {
values := [][]interface{}{
[]interface{}{23, 49, 56, 21, 14, 35, 28, 7, 42},
[]interface{}{uint(23), uint(49), uint(56), uint(21), uint(14), uint(35), uint(28), uint(7), uint(42)},
[]interface{}{float64(23), float64(49), float64(56), float64(21), float64(14), float64(35), float64(28), float64(7), float64(42)},
}
for _, v := range values {
factorParam := spec.QueryParam("factor")
factorParam.WithMaximum(makeFloat(v[1]), false)
factorParam.WithMinimum(makeFloat(v[3]), false)
factorParam.WithMultipleOf(makeFloat(v[7]))
factorParam.WithEnum(v[3], v[6], v[8], v[1])
factorParam.Typed("number", "double")
validator := NewParamValidator(factorParam, strfmt.Default)
// MultipleOf
err := validator.Validate(v[0])
assert.True(t, err.HasErrors())
assert.EqualError(t, multipleOfError(factorParam), err.Errors[0].Error())
// Maximum
err = validator.Validate(v[1])
assert.True(t, err == nil || err.IsValid())
if err != nil {
assert.Empty(t, err.Errors)
}
err = validator.Validate(v[2])
assert.True(t, err.HasErrors())
assert.EqualError(t, maxError(factorParam), err.Errors[0].Error())
// ExclusiveMaximum
factorParam.ExclusiveMaximum = true
// requires a new items validator because this is set a creation time
validator = NewParamValidator(factorParam, strfmt.Default)
err = validator.Validate(v[1])
assert.True(t, err.HasErrors())
assert.EqualError(t, maxError(factorParam), err.Errors[0].Error())
// Minimum
err = validator.Validate(v[3])
assert.True(t, err == nil || err.IsValid())
err = validator.Validate(v[4])
assert.True(t, err.HasErrors())
assert.EqualError(t, minError(factorParam), err.Errors[0].Error())
// ExclusiveMinimum
factorParam.ExclusiveMinimum = true
// requires a new items validator because this is set a creation time
validator = NewParamValidator(factorParam, strfmt.Default)
err = validator.Validate(v[3])
assert.True(t, err.HasErrors())
assert.EqualError(t, minError(factorParam), err.Errors[0].Error())
// Enum
err = validator.Validate(v[5])
assert.True(t, err.HasErrors())
assert.EqualError(t, enumFail(factorParam, v[5]), err.Errors[0].Error())
err = validator.Validate(v[6])
assert.True(t, err == nil || err.IsValid())
}
// Not required in a parameter or items
// AllOf
// AnyOf
// OneOf
// Not
// Definitions
}
func maxLengthError(param *spec.Parameter) *errors.Validation {
return errors.TooLong(param.Name, param.In, *param.MaxLength)
}
func minLengthError(param *spec.Parameter) *errors.Validation {
return errors.TooShort(param.Name, param.In, *param.MinLength)
}
func patternFail(param *spec.Parameter) *errors.Validation {
return errors.FailedPattern(param.Name, param.In, param.Pattern)
}
func enumFail(param *spec.Parameter, data interface{}) *errors.Validation {
return errors.EnumFail(param.Name, param.In, data, param.Enum)
}
func TestStringParameterValidation(t *testing.T) {
nameParam := spec.QueryParam("name").AsRequired().WithMinLength(3).WithMaxLength(5).WithPattern(`^[a-z]+$`).Typed("string", "")
nameParam.WithEnum("aaa", "bbb", "ccc")
validator := NewParamValidator(nameParam, strfmt.Default)
// required
err := validator.Validate("")
assert.True(t, err.HasErrors())
assert.EqualError(t, requiredError(nameParam), err.Errors[0].Error())
// MaxLength
err = validator.Validate("abcdef")
assert.True(t, err.HasErrors())
assert.EqualError(t, maxLengthError(nameParam), err.Errors[0].Error())
// MinLength
err = validator.Validate("a")
assert.True(t, err.HasErrors())
assert.EqualError(t, minLengthError(nameParam), err.Errors[0].Error())
// Pattern
err = validator.Validate("a394")
assert.True(t, err.HasErrors())
assert.EqualError(t, patternFail(nameParam), err.Errors[0].Error())
// Enum
err = validator.Validate("abcde")
assert.True(t, err.HasErrors())
assert.EqualError(t, enumFail(nameParam, "abcde"), err.Errors[0].Error())
// Valid passes
err = validator.Validate("bbb")
assert.True(t, err == nil || err.IsValid())
// Not required in a parameter or items
// AllOf
// AnyOf
// OneOf
// Not
// Definitions
}
func minItemsError(param *spec.Parameter) *errors.Validation {
return errors.TooFewItems(param.Name, param.In, *param.MinItems)
}
func maxItemsError(param *spec.Parameter) *errors.Validation {
return errors.TooManyItems(param.Name, param.In, *param.MaxItems)
}
func duplicatesError(param *spec.Parameter) *errors.Validation {
return errors.DuplicateItems(param.Name, param.In)
}
func TestArrayParameterValidation(t *testing.T) {
tagsParam := spec.QueryParam("tags").CollectionOf(stringItems, "").WithMinItems(1).WithMaxItems(5).UniqueValues()
tagsParam.WithEnum([]string{"a", "a", "a"}, []string{"b", "b", "b"}, []string{"c", "c", "c"})
validator := NewParamValidator(tagsParam, strfmt.Default)
// MinItems
err := validator.Validate([]string{})
assert.True(t, err.HasErrors())
assert.EqualError(t, minItemsError(tagsParam), err.Errors[0].Error())
// MaxItems
err = validator.Validate([]string{"a", "b", "c", "d", "e", "f"})
assert.True(t, err.HasErrors())
assert.EqualError(t, maxItemsError(tagsParam), err.Errors[0].Error())
// UniqueItems
err = validator.Validate([]string{"a", "a"})
assert.True(t, err.HasErrors())
assert.EqualError(t, duplicatesError(tagsParam), err.Errors[0].Error())
// Enum
err = validator.Validate([]string{"a", "b", "c"})
assert.True(t, err.HasErrors())
assert.EqualError(t, enumFail(tagsParam, []string{"a", "b", "c"}), err.Errors[0].Error())
// Items
strItems := spec.NewItems().WithMinLength(3).WithMaxLength(5).WithPattern(`^[a-z]+$`).Typed("string", "")
tagsParam = spec.QueryParam("tags").CollectionOf(strItems, "").WithMinItems(1).WithMaxItems(5).UniqueValues()
validator = NewParamValidator(tagsParam, strfmt.Default)
err = validator.Validate([]string{"aa", "bbb", "ccc"})
assert.True(t, err.HasErrors())
assert.EqualError(t, minLengthErrorItems("tags.0", tagsParam.In, strItems), err.Errors[0].Error())
// Not required in a parameter or items
// Additional items
// AllOf
// AnyOf
// OneOf
// Not
// Definitions
}

View File

@@ -1,607 +0,0 @@
// Copyright 2015 go-swagger maintainers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package validate
import (
"encoding/json"
"io/ioutil"
"log"
"path/filepath"
"testing"
"github.com/go-openapi/analysis"
"github.com/go-openapi/loads"
"github.com/go-openapi/loads/fmts"
"github.com/go-openapi/spec"
"github.com/go-openapi/strfmt"
"github.com/stretchr/testify/assert"
)
func init() {
loads.AddLoader(fmts.YAMLMatcher, fmts.YAMLDoc)
}
func TestExpandResponseLocalFile(t *testing.T) {
fp := filepath.Join("fixtures", "local_expansion", "spec.yaml")
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
if assert.NotNil(t, doc) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
assert.True(t, res.IsValid())
assert.Empty(t, res.Errors)
}
}
}
func TestExpandResponseRecursive(t *testing.T) {
fp := filepath.Join("fixtures", "recursive_expansion", "spec.yaml")
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
if assert.NotNil(t, doc) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
assert.True(t, res.IsValid())
assert.Empty(t, res.Errors)
}
}
}
func TestIssue52(t *testing.T) {
fp := filepath.Join("fixtures", "bugs", "52", "swagger.json")
jstext, _ := ioutil.ReadFile(fp)
// as json schema
var sch spec.Schema
if assert.NoError(t, json.Unmarshal(jstext, &sch)) {
validator := NewSchemaValidator(spec.MustLoadSwagger20Schema(), nil, "", strfmt.Default)
res := validator.Validate(&sch)
assert.False(t, res.IsValid())
assert.EqualError(t, res.Errors[0], ".paths in body is required")
}
// as swagger spec
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
assert.False(t, res.IsValid())
assert.EqualError(t, res.Errors[0], ".paths in body is required")
}
}
func TestIssue53(t *testing.T) {
fp := filepath.Join("fixtures", "bugs", "53", "noswagger.json")
jstext, _ := ioutil.ReadFile(fp)
// as json schema
var sch spec.Schema
if assert.NoError(t, json.Unmarshal(jstext, &sch)) {
validator := NewSchemaValidator(spec.MustLoadSwagger20Schema(), nil, "", strfmt.Default)
res := validator.Validate(&sch)
assert.False(t, res.IsValid())
assert.EqualError(t, res.Errors[0], ".swagger in body is required")
}
// as swagger spec
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
if assert.False(t, res.IsValid()) {
assert.EqualError(t, res.Errors[0], ".swagger in body is required")
}
}
}
func TestIssue62(t *testing.T) {
t.SkipNow()
fp := filepath.Join("fixtures", "bugs", "62", "swagger.json")
// as swagger spec
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
assert.NotEmpty(t, res.Errors)
assert.True(t, res.HasErrors())
}
}
func TestIssue63(t *testing.T) {
fp := filepath.Join("fixtures", "bugs", "63", "swagger.json")
// as swagger spec
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
assert.True(t, res.IsValid())
}
}
func TestIssue61_MultipleRefs(t *testing.T) {
fp := filepath.Join("fixtures", "bugs", "61", "multiple-refs.json")
// as swagger spec
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
assert.Empty(t, res.Errors)
assert.True(t, res.IsValid())
}
}
func TestIssue61_ResolvedRef(t *testing.T) {
fp := filepath.Join("fixtures", "bugs", "61", "unresolved-ref-for-name.json")
// as swagger spec
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
assert.Empty(t, res.Errors)
assert.True(t, res.IsValid())
}
}
func TestIssue123(t *testing.T) {
fp := filepath.Join("fixtures", "bugs", "123", "swagger.yml")
// as swagger spec
doc, err := loads.Spec(fp)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
for _, e := range res.Errors {
log.Println(e)
}
assert.True(t, res.IsValid())
}
}
func TestIssue6(t *testing.T) {
files, _ := filepath.Glob(filepath.Join("fixtures", "bugs", "6", "*.json"))
for _, path := range files {
doc, err := loads.Spec(path)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
for _, e := range res.Errors {
log.Println(e)
}
assert.False(t, res.IsValid())
}
}
}
// check if invalid patterns are indeed invalidated
func TestIssue18(t *testing.T) {
files, _ := filepath.Glob(filepath.Join("fixtures", "bugs", "18", "*.json"))
for _, path := range files {
doc, err := loads.Spec(path)
if assert.NoError(t, err) {
validator := NewSpecValidator(doc.Schema(), strfmt.Default)
res, _ := validator.Validate(doc)
for _, e := range res.Errors {
log.Println(e)
}
assert.False(t, res.IsValid())
}
}
}
func TestValidateDuplicatePropertyNames(t *testing.T) {
// simple allOf
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "duplicateprops.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
res := validator.validateDuplicatePropertyNames()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
// nested allOf
doc, err = loads.Spec(filepath.Join("fixtures", "validation", "nestedduplicateprops.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
res := validator.validateDuplicatePropertyNames()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
}
func TestValidateNonEmptyPathParameterNames(t *testing.T) {
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "empty-path-param-name.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
res := validator.validateNonEmptyPathParamNames()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
}
func TestValidateCircularAncestry(t *testing.T) {
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "direct-circular-ancestor.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
res := validator.validateDuplicatePropertyNames()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
doc, err = loads.Spec(filepath.Join("fixtures", "validation", "indirect-circular-ancestor.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
res := validator.validateDuplicatePropertyNames()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
doc, err = loads.Spec(filepath.Join("fixtures", "validation", "recursive-circular-ancestor.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
res := validator.validateDuplicatePropertyNames()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
}
func TestValidateUniqueSecurityScopes(t *testing.T) {
}
func TestValidateReferenced(t *testing.T) {
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "valid-referenced.yml"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateReferenced()
assert.Empty(t, res.Errors)
}
doc, err = loads.Spec(filepath.Join("fixtures", "validation", "invalid-referenced.yml"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateReferenced()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 3)
}
}
func TestValidateBodyFormDataParams(t *testing.T) {
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "invalid-formdata-body-params.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateDefaultValueValidAgainstSchema()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
}
func TestValidateReferencesValid(t *testing.T) {
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "valid-ref.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateReferencesValid()
assert.Empty(t, res.Errors)
}
doc, err = loads.Spec(filepath.Join("fixtures", "validation", "invalid-ref.json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateReferencesValid()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
}
}
func TestValidatesExamplesAgainstSchema(t *testing.T) {
tests := []string{
"response",
"response-ref",
}
for _, tt := range tests {
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "valid-example-"+tt+".json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateExamplesValidAgainstSchema()
assert.Empty(t, res.Errors, tt+" should not have errors")
}
doc, err = loads.Spec(filepath.Join("fixtures", "validation", "invalid-example-"+tt+".json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateExamplesValidAgainstSchema()
assert.NotEmpty(t, res.Errors, tt+" should have errors")
assert.Len(t, res.Errors, 1, tt+" should have 1 error")
}
}
}
func TestValidateDefaultValueAgainstSchema(t *testing.T) {
doc, _ := loads.Analyzed(PetStoreJSONMessage, "")
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateDefaultValueValidAgainstSchema()
assert.Empty(t, res.Errors)
tests := []string{
"parameter",
"parameter-ref",
"parameter-items",
"header",
"header-items",
"schema",
"schema-ref",
"schema-additionalProperties",
"schema-patternProperties",
"schema-items",
"schema-allOf",
}
for _, tt := range tests {
doc, err := loads.Spec(filepath.Join("fixtures", "validation", "valid-default-value-"+tt+".json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateDefaultValueValidAgainstSchema()
assert.Empty(t, res.Errors, tt+" should not have errors")
}
doc, err = loads.Spec(filepath.Join("fixtures", "validation", "invalid-default-value-"+tt+".json"))
if assert.NoError(t, err) {
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateDefaultValueValidAgainstSchema()
assert.NotEmpty(t, res.Errors, tt+" should have errors")
assert.Len(t, res.Errors, 1, tt+" should have 1 error")
}
}
}
func TestValidateRequiredDefinitions(t *testing.T) {
doc, _ := loads.Analyzed(PetStoreJSONMessage, "")
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateRequiredDefinitions()
assert.Empty(t, res.Errors)
// properties
sw := doc.Spec()
def := sw.Definitions["Tag"]
def.Required = append(def.Required, "type")
sw.Definitions["Tag"] = def
res = validator.validateRequiredDefinitions()
assert.NotEmpty(t, res.Errors)
// pattern properties
def.PatternProperties = make(map[string]spec.Schema)
def.PatternProperties["ty.*"] = *spec.StringProperty()
sw.Definitions["Tag"] = def
res = validator.validateRequiredDefinitions()
assert.Empty(t, res.Errors)
def.PatternProperties = make(map[string]spec.Schema)
def.PatternProperties["^ty.$"] = *spec.StringProperty()
sw.Definitions["Tag"] = def
res = validator.validateRequiredDefinitions()
assert.NotEmpty(t, res.Errors)
// additional properties
def.PatternProperties = nil
def.AdditionalProperties = &spec.SchemaOrBool{Allows: true}
sw.Definitions["Tag"] = def
res = validator.validateRequiredDefinitions()
assert.Empty(t, res.Errors)
def.AdditionalProperties = &spec.SchemaOrBool{Allows: false}
sw.Definitions["Tag"] = def
res = validator.validateRequiredDefinitions()
assert.NotEmpty(t, res.Errors)
}
func TestValidateParameters(t *testing.T) {
doc, _ := loads.Analyzed(PetStoreJSONMessage, "")
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateParameters()
assert.Empty(t, res.Errors)
sw := doc.Spec()
sw.Paths.Paths["/pets"].Get.Parameters = append(sw.Paths.Paths["/pets"].Get.Parameters, *spec.QueryParam("limit").Typed("string", ""))
res = validator.validateParameters()
assert.NotEmpty(t, res.Errors)
doc, _ = loads.Analyzed(PetStoreJSONMessage, "")
sw = doc.Spec()
sw.Paths.Paths["/pets"].Post.Parameters = append(sw.Paths.Paths["/pets"].Post.Parameters, *spec.BodyParam("fake", spec.RefProperty("#/definitions/Pet")))
validator = NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res = validator.validateParameters()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
assert.Contains(t, res.Errors[0].Error(), "has more than 1 body param")
doc, _ = loads.Analyzed(PetStoreJSONMessage, "")
sw = doc.Spec()
pp := sw.Paths.Paths["/pets/{id}"]
pp.Delete = nil
var nameParams []spec.Parameter
for _, p := range pp.Parameters {
if p.Name == "id" {
p.Name = "name"
nameParams = append(nameParams, p)
}
}
pp.Parameters = nameParams
sw.Paths.Paths["/pets/{name}"] = pp
validator = NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res = validator.validateParameters()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 1)
assert.Contains(t, res.Errors[0].Error(), "overlaps with")
doc, _ = loads.Analyzed(PetStoreJSONMessage, "")
validator = NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
sw = doc.Spec()
pp = sw.Paths.Paths["/pets/{id}"]
pp.Delete = nil
pp.Get.Parameters = nameParams
pp.Parameters = nil
sw.Paths.Paths["/pets/{id}"] = pp
res = validator.validateParameters()
assert.NotEmpty(t, res.Errors)
assert.Len(t, res.Errors, 2)
assert.Contains(t, res.Errors[1].Error(), "is not present in path \"/pets/{id}\"")
assert.Contains(t, res.Errors[0].Error(), "has no parameter definition")
}
func TestValidateItems(t *testing.T) {
doc, _ := loads.Analyzed(PetStoreJSONMessage, "")
validator := NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
res := validator.validateItems()
assert.Empty(t, res.Errors)
// in operation parameters
sw := doc.Spec()
sw.Paths.Paths["/pets"].Get.Parameters[0].Type = "array"
res = validator.validateItems()
assert.NotEmpty(t, res.Errors)
sw.Paths.Paths["/pets"].Get.Parameters[0].Items = spec.NewItems().Typed("string", "")
res = validator.validateItems()
assert.Empty(t, res.Errors)
sw.Paths.Paths["/pets"].Get.Parameters[0].Items = spec.NewItems().Typed("array", "")
res = validator.validateItems()
assert.NotEmpty(t, res.Errors)
sw.Paths.Paths["/pets"].Get.Parameters[0].Items.Items = spec.NewItems().Typed("string", "")
res = validator.validateItems()
assert.Empty(t, res.Errors)
// in global parameters
sw.Parameters = make(map[string]spec.Parameter)
sw.Parameters["other"] = *spec.SimpleArrayParam("other", "array", "csv")
res = validator.validateItems()
assert.Empty(t, res.Errors)
//pp := spec.SimpleArrayParam("other", "array", "")
//pp.Items = nil
//sw.Parameters["other"] = *pp
//res = validator.validateItems()
//assert.NotEmpty(t, res.Errors)
// in shared path object parameters
doc, _ = loads.Analyzed(PetStoreJSONMessage, "")
validator = NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
sw = doc.Spec()
pa := sw.Paths.Paths["/pets"]
pa.Parameters = []spec.Parameter{*spec.SimpleArrayParam("another", "array", "csv")}
sw.Paths.Paths["/pets"] = pa
res = validator.validateItems()
assert.Empty(t, res.Errors)
pa = sw.Paths.Paths["/pets"]
pp := spec.SimpleArrayParam("other", "array", "")
pp.Items = nil
pa.Parameters = []spec.Parameter{*pp}
sw.Paths.Paths["/pets"] = pa
res = validator.validateItems()
assert.NotEmpty(t, res.Errors)
// in body param schema
doc, _ = loads.Analyzed(PetStoreJSONMessage, "")
validator = NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
sw = doc.Spec()
pa = sw.Paths.Paths["/pets"]
pa.Post.Parameters[0].Schema = spec.ArrayProperty(nil)
res = validator.validateItems()
assert.NotEmpty(t, res.Errors)
// in response headers
doc, _ = loads.Analyzed(PetStoreJSONMessage, "")
validator = NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
sw = doc.Spec()
pa = sw.Paths.Paths["/pets"]
rp := pa.Post.Responses.StatusCodeResponses[200]
var hdr spec.Header
hdr.Type = "array"
rp.Headers = make(map[string]spec.Header)
rp.Headers["X-YADA"] = hdr
pa.Post.Responses.StatusCodeResponses[200] = rp
res = validator.validateItems()
assert.NotEmpty(t, res.Errors)
// in response schema
doc, _ = loads.Analyzed(PetStoreJSONMessage, "")
validator = NewSpecValidator(spec.MustLoadSwagger20Schema(), strfmt.Default)
validator.spec = doc
validator.analyzer = analysis.New(doc.Spec())
sw = doc.Spec()
pa = sw.Paths.Paths["/pets"]
rp = pa.Post.Responses.StatusCodeResponses[200]
rp.Schema = spec.ArrayProperty(nil)
pa.Post.Responses.StatusCodeResponses[200] = rp
res = validator.validateItems()
assert.NotEmpty(t, res.Errors)
}

Some files were not shown because too many files have changed in this diff Show More