Created
April 14, 2019 21:08
-
-
Save Sean-Bradley/774cdc17d754daafc5b076f0baa93840 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"openapi": "3.0.0", | |
"info": { | |
"version": "1.0.0", | |
"title": "Seans-TypeScript-NodeJS-CRUD-REST-API-Boilerplate", | |
"description": "A minimal and easy to follow example of what you need to create a CRUD style API in NodeJs using TypeScript", | |
"license": { | |
"name": "MIT", | |
"url": "https://opensource.org/licenses/MIT" | |
} | |
}, | |
"servers": [ | |
{ | |
"url": "/", | |
"description": "Local Dev, or from Heroku" | |
}, | |
{ | |
"url": "/api/", | |
"description": "With docker-compose and nginx proxy" | |
} | |
], | |
"tags": [ | |
{ | |
"name": "Cats", | |
"description": "API for cats in the system" | |
} | |
], | |
"consumes": [ | |
"application/json" | |
], | |
"produces": [ | |
"application/json" | |
], | |
"paths": { | |
"/cats": { | |
"get": { | |
"tags": [ | |
"Cats" | |
], | |
"summary": "Get all cats in system", | |
"responses": { | |
"200": { | |
"description": "OK", | |
"schema": { | |
"$ref": "#/definitions/Cats" | |
} | |
} | |
} | |
}, | |
"post": { | |
"tags": [ | |
"Cats" | |
], | |
"summary": "Create a new cat in system", | |
"requestBody": { | |
"description": "Cat Object", | |
"required": true, | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/definitions/Cat" | |
} | |
} | |
} | |
}, | |
"produces": [ | |
"application/json" | |
], | |
"responses": { | |
"200": { | |
"description": "OK", | |
"schema": { | |
"$ref": "#/definitions/id" | |
} | |
}, | |
"400": { | |
"description": "Failed. Bad post data." | |
} | |
} | |
} | |
}, | |
"/cats/{id}": { | |
"parameters": [ | |
{ | |
"name": "id", | |
"in": "path", | |
"required": true, | |
"description": "ID of the cat that we want to match", | |
"type": "string" | |
} | |
], | |
"get": { | |
"tags": [ | |
"Cats" | |
], | |
"summary": "Get cat with given ID", | |
"parameters": [ | |
{ | |
"in": "path", | |
"name": "id", | |
"required": true, | |
"description": "Cat with id", | |
"schema": { | |
"$ref": "#/definitions/id" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "OK", | |
"schema": { | |
"$ref": "#/definitions/Cat" | |
} | |
}, | |
"404": { | |
"description": "Failed. Cat not found." | |
} | |
} | |
}, | |
"put": { | |
"summary": "Update cat with given ID", | |
"tags": [ | |
"Cats" | |
], | |
"requestBody": { | |
"description": "Cat Object", | |
"required": true, | |
"content": { | |
"application/json": { | |
"schema": { | |
"$ref": "#/definitions/Cat" | |
} | |
} | |
} | |
}, | |
"parameters": [ | |
{ | |
"in": "path", | |
"name": "id", | |
"required": true, | |
"description": "Cat with new values of properties", | |
"schema": { | |
"$ref": "#/definitions/id" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "OK", | |
"schema": { | |
"$ref": "#/definitions/Cat" | |
} | |
}, | |
"400": { | |
"description": "Failed. Bad post data." | |
}, | |
"404": { | |
"description": "Failed. Cat not found." | |
} | |
} | |
}, | |
"delete": { | |
"summary": "Delete cat with given ID", | |
"tags": [ | |
"Cats" | |
], | |
"parameters": [ | |
{ | |
"in": "path", | |
"name": "id", | |
"required": true, | |
"description": "Delete Cat with id", | |
"schema": { | |
"$ref": "#/definitions/id" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "OK", | |
"schema": { | |
"$ref": "#/definitions/id" | |
} | |
}, | |
"404": { | |
"description": "Failed. Cat not found." | |
} | |
} | |
} | |
} | |
}, | |
"definitions": { | |
"id": { | |
"properties": { | |
"uuid": { | |
"type": "string" | |
} | |
} | |
}, | |
"Cat": { | |
"type": "object", | |
"properties": { | |
"genus": { | |
"type": "string" | |
}, | |
"name": { | |
"type": "string" | |
}, | |
"isHungry": { | |
"type": "boolean" | |
}, | |
"lastFedDate": { | |
"type": "string" | |
} | |
} | |
}, | |
"Cats": { | |
"type": "object", | |
"properties": { | |
"cats": { | |
"type": "object", | |
"additionalProperties": { | |
"$ref": "#/definitions/Cat" | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment