Created
August 21, 2019 02:58
-
-
Save FikriRNurhidayat/7987aadb1f7654632ecf30c1ea4c1ab5 to your computer and use it in GitHub Desktop.
Example of Swagger JSON file
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 API Documentation.", | |
"version": "1.0.0", | |
"title": "Express Auth", | |
"contact": { | |
"email": "[email protected]" | |
}, | |
"license": { | |
"name": "Apache 2.0", | |
"url": "http://www.apache.org/licenses/LICENSE-2.0.html" | |
} | |
}, | |
"host": "api-auth-training.herokuapp.com", | |
"basePath": "/api", | |
"tags": [ | |
{ | |
"name": "User Operation", | |
"description": "Operations about user", | |
"externalDocs": { | |
"description": "Find out more about our store", | |
"url": "http://swagger.io" | |
} | |
} | |
], | |
"schemes": [ | |
"https", | |
"http" | |
], | |
"paths": { | |
"/users": { | |
"post": { | |
"tags": [ | |
"User Operation" | |
], | |
"summary": "Register User", | |
"description": "", | |
"operationId": "addUser", | |
"consumes": [ | |
"application/json", | |
"application/xml" | |
], | |
"produces": [ | |
"application/xml", | |
"application/json" | |
], | |
"parameters": [ | |
{ | |
"in": "body", | |
"name": "body", | |
"description": "Users that will be registered on database", | |
"required": true, | |
"schema": { | |
"$ref": "#/definitions/UserRegister" | |
} | |
} | |
], | |
"responses": { | |
"405": { | |
"description": "Invalid input" | |
} | |
} | |
}, | |
"get": { | |
"tags": [ | |
"User Operation" | |
], | |
"summary": "Finding out who current is.", | |
"description": "", | |
"consumes": [ | |
"application/json" | |
], | |
"produces": [ | |
"application/xml", | |
"application/json" | |
], | |
"responses": { | |
"200": { | |
"description": "User exist and token verified!" | |
} | |
}, | |
"security": [ | |
{ | |
"Authorization": [] | |
} | |
] | |
} | |
}, | |
"/auth/login": { | |
"post": { | |
"tags": [ | |
"Login" | |
], | |
"summary": "Login User", | |
"description": "User login", | |
"consumes": [ | |
"application/json", | |
"application/xml" | |
], | |
"produces": [ | |
"application/xml", | |
"application/json" | |
], | |
"parameters": [ | |
{ | |
"in": "body", | |
"name": "body", | |
"description": "Will post email and password to database and database will check if it's true or not.", | |
"required": true, | |
"schema": { | |
"$ref": "#/definitions/UserLogin" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "If user exist, and the password is matched. It will response token object." | |
} | |
} | |
} | |
} | |
}, | |
"securityDefinitions": { | |
"Authorization": { | |
"type": "apiKey", | |
"name": "Authorization", | |
"in": "header" | |
} | |
}, | |
"definitions": { | |
"UserRegister": { | |
"type": "object", | |
"required": [ | |
"name", | |
"email", | |
"password", | |
"password_confirmation" | |
], | |
"properties": { | |
"name": { | |
"type": "string", | |
"example": "Fikri" | |
}, | |
"email": { | |
"type": "string", | |
"example": "[email protected]" | |
}, | |
"password": { | |
"type": "string", | |
"example": "123456" | |
}, | |
"password_confirmation": { | |
"type": "string", | |
"example": "123456" | |
} | |
} | |
}, | |
"UserLogin": { | |
"type": "object", | |
"required": [ | |
"email", | |
"password" | |
], | |
"properties": { | |
"email": { | |
"type": "string", | |
"example": "[email protected]" | |
}, | |
"password": { | |
"type": "string", | |
"example": "123456" | |
} | |
} | |
} | |
}, | |
"externalDocs": { | |
"description": "Find out more about Swagger", | |
"url": "http://swagger.io" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment