Skip to content

Instantly share code, notes, and snippets.

@pmutua
Created January 12, 2024 09:33
Show Gist options
  • Save pmutua/aa8a11ecc449f233e9bbe469ccce2d1b to your computer and use it in GitHub Desktop.
Save pmutua/aa8a11ecc449f233e9bbe469ccce2d1b to your computer and use it in GitHub Desktop.
Example Swagger 2.0 JSON file for a Fraud Detection API with 10 entries (endpoints):
{
"swagger": "2.0",
"info": {
"title": "Fraud Detection API",
"description": "Detect and prevent fraudulent activities in banking transactions.",
"version": "1.0.0"
},
"basePath": "/api",
"schemes": ["http", "https"],
"paths": {
"/fraud-detection/analyze": {
"post": {
"summary": "Analyze Transaction for Fraud",
"description": "Endpoint to analyze a banking transaction for potential fraud.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "transactionData",
"description": "Transaction data for fraud analysis",
"schema": {
"$ref": "#/definitions/TransactionData"
}
}
],
"responses": {
"200": {
"description": "Fraud analysis result",
"schema": {
"$ref": "#/definitions/FraudAnalysisResult"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/fraud-detection/report": {
"post": {
"summary": "Report Fraudulent Transaction",
"description": "Endpoint to report a transaction as fraudulent.",
"consumes": ["application/json"],
"produces": ["application/json"],
"parameters": [
{
"in": "body",
"name": "fraudReport",
"description": "Fraud report data",
"schema": {
"$ref": "#/definitions/FraudReport"
}
}
],
"responses": {
"200": {
"description": "Fraud report submitted successfully",
"schema": {
"$ref": "#/definitions/SuccessResponse"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/fraud-detection/history/{customerId}": {
"get": {
"summary": "Get Fraud History",
"description": "Endpoint to get the fraud history for a specific customer.",
"produces": ["application/json"],
"parameters": [
{
"in": "path",
"name": "customerId",
"type": "string",
"description": "ID of the customer for fraud history retrieval."
}
],
"responses": {
"200": {
"description": "Successful response",
"schema": {
"$ref": "#/definitions/FraudHistory"
}
},
"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."
}
}
},
"TransactionData": {
"type": "object",
"properties": {
"transactionId": {
"type": "string",
"description":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment