Skip to content

Instantly share code, notes, and snippets.

@pmutua
Created January 12, 2024 09:34
Show Gist options
  • Save pmutua/ec547343e71de8ca14e1ed420064527e to your computer and use it in GitHub Desktop.
Save pmutua/ec547343e71de8ca14e1ed420064527e to your computer and use it in GitHub Desktop.
Example Swagger 2.0 JSON file for a Budgeting and Savings API with 10 entries (endpoints):
{
"swagger": "2.0",
"info": {
"title": "Budgeting and Savings API",
"description": "Assist customers in budgeting, goal setting, and saving strategies.",
"version": "1.0.0"
},
"basePath": "/api",
"schemes": ["http", "https"],
"paths": {
"/budgets/create": {
"post": {
"summary": "Create Budget",
"description": "Endpoint to create a new budget for a customer.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "budgetData",
"description": "Budget data for creation",
"schema": {
"$ref": "#/definitions/BudgetData"
}
}
],
"responses": {
"200": {
"description": "Budget created successfully",
"schema": {
"$ref": "#/definitions/BudgetInfo"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/budgets/update": {
"put": {
"summary": "Update Budget",
"description": "Endpoint to update an existing budget for a customer.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "budgetData",
"description": "Updated budget data",
"schema": {
"$ref": "#/definitions/BudgetData"
}
}
],
"responses": {
"200": {
"description": "Budget updated successfully",
"schema": {
"$ref": "#/definitions/BudgetInfo"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
},
"404": {
"description": "Not found",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/budgets/list/{customerId}": {
"get": {
"summary": "List Budgets",
"description": "Endpoint to get the list of budgets for a specific customer.",
"produces": ["application/json"],
"parameters": [
{
"in": "path",
"name": "customerId",
"type": "string",
"description": "ID of the customer for budget retrieval."
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/BudgetList"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
},
"404": {
"description": "Not found",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/savings/goals/create": {
"post": {
"summary": "Create Savings Goal",
"description": "Endpoint to create a new savings goal for a customer.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "savingsGoalData",
"description": "Savings goal data for creation",
"schema": {
"$ref": "#/definitions/SavingsGoalData"
}
}
],
"responses": {
"200": {
"description": "Savings goal created successfully",
"schema": {
"$ref": "#/definitions/SavingsGoalInfo"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/savings/goals/update": {
"put": {
"summary": "Update Savings Goal",
"description": "Endpoint to update an existing savings goal for a customer.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "savingsGoalData",
"description": "Updated savings goal data",
"schema": {
"$ref": "#/definitions/SavingsGoalData"
}
}
],
"responses": {
"200": {
"description": "Savings goal updated successfully",
"schema": {
"$ref": "#/definitions/SavingsGoalInfo"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
},
"404": {
"description": "Not found",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/savings/goals/list/{customerId}": {
"get": {
"summary": "List Savings Goals",
"description": "Endpoint to get the list of savings goals for a specific customer.",
"produces": ["application/json"],
"parameters": [
{
"in": "path",
"name": "customerId",
"type": "string",
"description": "ID of the customer for savings goal retrieval."
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/SavingsGoalList"
}
},
"400": {
"description": "Bad requ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment