-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Carmine DiMascio
committed
Apr 26, 2020
1 parent
a375e5f
commit d6d2d02
Showing
7 changed files
with
5,668 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# example | ||
|
||
simple example using express-openapi-validator | ||
|
||
## Install | ||
|
||
```shell | ||
npm i && npm run deps | ||
``` | ||
|
||
## Run | ||
|
||
From this `4-standard-multi-version` directory, run: | ||
|
||
```shell | ||
npm start | ||
``` | ||
|
||
## Try | ||
|
||
```shell | ||
## call ping | ||
curl http://localhost:3000/v1/ping | ||
|
||
## call pets | ||
## the call below should return 400 since it requires additional parameters | ||
curl http://localhost:3000/v1/pets | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
openapi: '3.0.0' | ||
info: | ||
version: 1.0.0 | ||
title: Swagger Petstore | ||
description: A sample API | ||
termsOfService: http://swagger.io/terms/ | ||
license: | ||
name: Apache 2.0 | ||
url: https://www.apache.org/licenses/LICENSE-2.0.html | ||
servers: | ||
- url: /v1 | ||
paths: | ||
/pets: | ||
get: | ||
description: | | ||
Returns all pets | ||
operationId: findPets | ||
parameters: | ||
- name: type | ||
in: query | ||
description: maximum number of results to return | ||
required: true | ||
schema: | ||
type: string | ||
enum: | ||
- dog | ||
- cat | ||
- name: tags | ||
in: query | ||
description: tags to filter by | ||
required: false | ||
style: form | ||
schema: | ||
type: array | ||
items: | ||
type: string | ||
- name: limit | ||
in: query | ||
description: maximum number of results to return | ||
required: true | ||
schema: | ||
type: integer | ||
format: int32 | ||
minimum: 1 | ||
maximum: 20 | ||
responses: | ||
'200': | ||
description: pet response | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Pet' | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
|
||
post: | ||
description: Creates a new pet in the store. | ||
operationId: addPet | ||
security: | ||
- ApiKeyAuth: [] | ||
requestBody: | ||
description: Pet to add to the store | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
responses: | ||
'200': | ||
description: pet response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
|
||
/pets/{id}: | ||
get: | ||
description: Returns a user based on a single ID, if the user does not have access to the pet | ||
operationId: find pet by id | ||
parameters: | ||
- name: id | ||
in: path | ||
description: ID of pet to fetch | ||
required: true | ||
schema: | ||
type: integer | ||
format: int64 | ||
responses: | ||
'200': | ||
description: pet response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
delete: | ||
description: deletes a single pet based on the ID supplied | ||
operationId: deletePet | ||
parameters: | ||
- name: id | ||
in: path | ||
description: ID of pet to delete | ||
required: true | ||
schema: | ||
type: integer | ||
format: int64 | ||
responses: | ||
'204': | ||
description: pet deleted | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
|
||
components: | ||
schemas: | ||
Pet: | ||
required: | ||
- id | ||
- name | ||
- type | ||
properties: | ||
id: | ||
readOnly: true | ||
type: number | ||
name: | ||
type: string | ||
tag: | ||
type: string | ||
type: | ||
$ref: '#/components/schemas/PetType' | ||
|
||
PetType: | ||
type: string | ||
enum: | ||
- dog | ||
- cat | ||
|
||
Error: | ||
required: | ||
- code | ||
- message | ||
properties: | ||
code: | ||
type: integer | ||
format: int32 | ||
message: | ||
type: string | ||
|
||
securitySchemes: | ||
ApiKeyAuth: | ||
type: apiKey | ||
in: header | ||
name: X-API-Key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
openapi: '3.0.0' | ||
info: | ||
version: 1.0.0 | ||
title: Swagger Petstore | ||
description: A sample API | ||
termsOfService: http://swagger.io/terms/ | ||
license: | ||
name: Apache 2.0 | ||
url: https://www.apache.org/licenses/LICENSE-2.0.html | ||
servers: | ||
- url: /v2 | ||
paths: | ||
/pets: | ||
get: | ||
description: | | ||
Returns all pets | ||
operationId: findPets | ||
parameters: | ||
- name: pet_type | ||
in: query | ||
description: maximum number of results to return | ||
required: true | ||
schema: | ||
type: string | ||
enum: | ||
- doggy | ||
- kitty | ||
responses: | ||
'200': | ||
description: pet response | ||
content: | ||
application/json: | ||
schema: | ||
type: array | ||
items: | ||
$ref: '#/components/schemas/Pet' | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
|
||
post: | ||
description: Creates a new pet in the store. | ||
operationId: addPet | ||
security: | ||
- ApiKeyAuth: [] | ||
requestBody: | ||
description: Pet to add to the store | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
responses: | ||
'200': | ||
description: pet response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
|
||
/pets/{id}: | ||
get: | ||
description: Returns a user based on a single ID, if the user does not have access to the pet | ||
operationId: find pet by id | ||
parameters: | ||
- name: id | ||
in: path | ||
description: ID of pet to fetch | ||
required: true | ||
schema: | ||
type: integer | ||
format: int64 | ||
responses: | ||
'200': | ||
description: pet response | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Pet' | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
delete: | ||
description: deletes a single pet based on the ID supplied | ||
operationId: deletePet | ||
parameters: | ||
- name: id | ||
in: path | ||
description: ID of pet to delete | ||
required: true | ||
schema: | ||
type: integer | ||
format: int64 | ||
responses: | ||
'204': | ||
description: pet deleted | ||
default: | ||
description: unexpected error | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/Error' | ||
|
||
components: | ||
schemas: | ||
Pet: | ||
required: | ||
- id | ||
- name | ||
- type | ||
properties: | ||
pet_id: | ||
readOnly: true | ||
type: number | ||
pet_name: | ||
type: string | ||
pet_tag: | ||
type: string | ||
-pet_type: | ||
$ref: '#/components/schemas/PetType' | ||
|
||
PetType: | ||
type: string | ||
enum: | ||
- doggy | ||
- kitty | ||
|
||
Error: | ||
required: | ||
- code | ||
- message | ||
properties: | ||
code: | ||
type: integer | ||
format: int32 | ||
message: | ||
type: string | ||
|
||
securitySchemes: | ||
ApiKeyAuth: | ||
type: apiKey | ||
in: header | ||
name: X-API-Key |
Oops, something went wrong.