Created
April 12, 2016 21:41
-
-
Save pleasedontbelong/121fba72b0321c11f4c0646e0b865ae4 to your computer and use it in GitHub Desktop.
Swagger example for the meetup slides
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
{ | |
"swagger": "2.0", | |
"info": { | |
"description": "This is a sample server API server", | |
"version": "1.0.0", | |
"title": "Swagger Sample Api", | |
"contact": { | |
"name": "API Team", | |
"url": "http://wordnik.com", | |
"email": "apiteam@wordnik.com" | |
} | |
}, | |
"host": "api.example.com:80", | |
"basePath": "/", | |
"tags": [ | |
{ | |
"name": "User", | |
"description": "Operations about user" | |
} | |
], | |
"schemes": [ | |
"https" | |
], | |
"paths": { | |
"/user": { | |
"post": { | |
"tags": [ | |
"User" | |
], | |
"summary": "Add a new user", | |
"description": "Add a new user", | |
"operationId": "addUser", | |
"parameters": [ | |
{ | |
"in": "body", | |
"name": "body", | |
"required": false, | |
"schema": { | |
"$ref": "#/definitions/User" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Success" | |
}, | |
"405": { | |
"description": "Error 405" | |
} | |
} | |
} | |
}, | |
"/user/{user_id}": { | |
"get": { | |
"tags": [ | |
"User" | |
], | |
"summary": "Find user by ID", | |
"description": "Find user by ID", | |
"operationId": "getUserById", | |
"parameters": [ | |
{ | |
"name": "userId", | |
"in": "path", | |
"description": "ID of user that needs to be fetched", | |
"required": true, | |
"type": "integer", | |
"format": "int64" | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Success", | |
"schema": { | |
"$ref": "#/definitions/User" | |
} | |
}, | |
"400": { | |
"description": "Error 400" | |
}, | |
"404": { | |
"description": "Error 404" | |
} | |
} | |
}, | |
"put": { | |
"tags": [ | |
"User" | |
], | |
"summary": "Updates a user with form data", | |
"description": "Updates a user with form data", | |
"operationId": "updateUserWithForm", | |
"consumes": [], | |
"produces": [], | |
"parameters": [ | |
{ | |
"name": "userId", | |
"in": "path", | |
"description": "ID of user that needs to be fetched", | |
"required": true, | |
"type": "integer", | |
"format": "int64" | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Success" | |
}, | |
"405": { | |
"description": "Error 405" | |
} | |
} | |
}, | |
"delete": { | |
"tags": [ | |
"User" | |
], | |
"summary": "Deletes a user", | |
"description": "Deletes a user", | |
"operationId": "deleteUser", | |
"consumes": [], | |
"produces": [], | |
"parameters": [ | |
{ | |
"name": "userId", | |
"in": "path", | |
"description": "ID of user that needs to be fetched", | |
"required": true, | |
"type": "integer", | |
"format": "int64" | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Success" | |
}, | |
"400": { | |
"description": "Error 400" | |
} | |
} | |
} | |
} | |
}, | |
"definitions": { | |
"User": { | |
"type": "object", | |
"properties": { | |
"email": { | |
"type": "string" | |
}, | |
"firstName": { | |
"type": "string" | |
}, | |
"id": { | |
"type": "integer", | |
"format": "int32" | |
}, | |
"lastName": { | |
"type": "string" | |
}, | |
"password": { | |
"type": "string" | |
}, | |
"phone": { | |
"type": "string" | |
}, | |
"userStatus": { | |
"type": "integer", | |
"format": "int32", | |
"description": "User Status" | |
}, | |
"userlogin": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment