Created
January 12, 2024 09:43
-
-
Save pmutua/c44827ec92f238ec537d5f2428eca9a7 to your computer and use it in GitHub Desktop.
Example Swagger 2.0 JSON file for a Branch Locator API with 10 entries (endpoints):
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": { | |
"title": "Branch Locator API", | |
"description": "Locate nearby bank branches and their operating hours.", | |
"version": "1.0.0" | |
}, | |
"basePath": "/api", | |
"schemes": ["http", "https"], | |
"paths": { | |
"/branches/nearby": { | |
"get": { | |
"summary": "Find Nearby Branches", | |
"description": "Endpoint to find nearby bank branches.", | |
"produces": ["application/json"], | |
"parameters": [ | |
{ | |
"in": "query", | |
"name": "latitude", | |
"type": "number", | |
"description": "Latitude of the user's location." | |
}, | |
{ | |
"in": "query", | |
"name": "longitude", | |
"type": "number", | |
"description": "Longitude of the user's location." | |
}, | |
{ | |
"in": "query", | |
"name": "radius", | |
"type": "number", | |
"description": "Search radius in kilometers." | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/BranchList" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
}, | |
"/branches/details/{branchId}": { | |
"get": { | |
"summary": "Get Branch Details", | |
"description": "Endpoint to get details of a specific bank branch.", | |
"produces": ["application/json"], | |
"parameters": [ | |
{ | |
"in": "path", | |
"name": "branchId", | |
"type": "string", | |
"description": "ID of the bank branch." | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/BranchDetails" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
}, | |
"404": { | |
"description": "Not found", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
}, | |
"/branches/services/{branchId}": { | |
"get": { | |
"summary": "Get Branch Services", | |
"description": "Endpoint to get services offered by a specific bank branch.", | |
"produces": ["application/json"], | |
"parameters": [ | |
{ | |
"in": "path", | |
"name": "branchId", | |
"type": "string", | |
"description": "ID of the bank branch." | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/BranchServices" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
}, | |
"404": { | |
"description": "Not found", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"definitions": { | |
"ErrorModel": { | |
"type": "object", | |
"properties": { | |
"error": { | |
"type": "string", | |
"description": "Error message." | |
} | |
} | |
}, | |
"Branch": { | |
"type": "object", | |
"properties": { | |
"branchId": { | |
"type": "string", | |
"description": "ID of the bank branch." | |
}, | |
"name": { | |
"type": "string", | |
"description": "Name of the bank branch." | |
}, | |
"address": { | |
"type": "string", | |
"description": "Address of the bank branch." | |
}, | |
"latitude": { | |
"type": "number", | |
"description": "Latitude of the bank branch location." | |
}, | |
"longitude": { | |
"type": "number", | |
"description": "Longitude of the bank branch location." | |
} | |
} | |
}, | |
"BranchList": { | |
"type": "object", | |
"properties": { | |
"branches": { | |
"type": "array", | |
"items": { | |
"$ref": "#/definitions/Branch" | |
}, | |
"description": "List of nearby bank branches." | |
} | |
} | |
}, | |
"BranchDetails": { | |
"type": "object", | |
"properties": { | |
"branchId": { | |
"type": "string", | |
"description": "ID of the bank branch." | |
}, | |
"name": { | |
"type": "string", | |
"description": "Name of the bank branch." | |
}, | |
"address": { | |
"type": "string", | |
"description": "Address of the bank branch." | |
}, | |
"latitude": { | |
"type": "number", | |
"description": "Latitude of the bank branch location." | |
}, | |
"longitude": { | |
"type": "number", | |
"description": "Longitude of the bank branch location." | |
}, | |
"operatingHours": { | |
"type": "string", | |
"description": "Operating hours of the bank branch." | |
} | |
} | |
}, | |
"BranchServices": { | |
"type": "object", | |
"properties": { | |
"branchId": { | |
"type": "string", | |
"description": "ID of the bank branch." | |
}, | |
"services": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
}, | |
"description": "List of services offered by the bank branch." | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment