Created
January 12, 2024 09:49
-
-
Save pmutua/82490ceec6e895d56872203ffc82b5d4 to your computer and use it in GitHub Desktop.
Example Swagger 2.0 JSON file for a Loan Eligibility API with 10 entries (endpoints):
This file contains hidden or 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": "Loan Eligibility API", | |
"description": "Check customer eligibility for different loan products.", | |
"version": "1.0.0" | |
}, | |
"basePath": "/api", | |
"schemes": ["http", "https"], | |
"paths": { | |
"/eligibility/check": { | |
"post": { | |
"summary": "Check Loan Eligibility", | |
"description": "Endpoint to check customer eligibility for a specific loan product.", | |
"consumes": ["application/json"], | |
"produces": ["application/json"], | |
"parameters": [ | |
{ | |
"in": "body", | |
"name": "eligibilityCheckData", | |
"description": "Loan eligibility check data", | |
"schema": { | |
"$ref": "#/definitions/EligibilityCheckData" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/EligibilityCheckResult" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
}, | |
"/eligibility/criteria/{loanType}": { | |
"get": { | |
"summary": "Get Eligibility Criteria", | |
"description": "Endpoint to get the eligibility criteria for a specific loan type.", | |
"produces": ["application/json"], | |
"parameters": [ | |
{ | |
"in": "path", | |
"name": "loanType", | |
"type": "string", | |
"description": "Type of the loan (e.g., personal loan, home loan)." | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/EligibilityCriteria" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
}, | |
"404": { | |
"description": "Loan type not found", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
}, | |
"/loan/types": { | |
"get": { | |
"summary": "Get Loan Types", | |
"description": "Endpoint to get a list of available loan types.", | |
"produces": ["application/json"], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/LoanTypeList" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
}, | |
"/loan/application/requirements/{loanType}": { | |
"get": { | |
"summary": "Get Loan Application Requirements", | |
"description": "Endpoint to get the requirements for loan application for a specific loan type.", | |
"produces": ["application/json"], | |
"parameters": [ | |
{ | |
"in": "path", | |
"name": "loanType", | |
"type": "string", | |
"description": "Type of the loan (e.g., personal loan, home loan)." | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/LoanApplicationRequirements" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
}, | |
"404": { | |
"description": "Loan type not found", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"definitions": { | |
"ErrorModel": { | |
"type": "object", | |
"properties": { | |
"error": { | |
"type": "string", | |
"description": "Error message." | |
} | |
} | |
}, | |
"EligibilityCheckData": { | |
"type": "object", | |
"properties": { | |
"customerId": { | |
"type": "string", | |
"description": "ID of the customer for whom eligibility is being checked." | |
}, | |
"loanType": { | |
"type": "string", | |
"description": "Type of the loan for which eligibility is being checked." | |
}, | |
"loanAmount": { | |
"type": "number", | |
"description": "Requested loan amount." | |
} | |
}, | |
"required": ["customerId", "loanType", "loanAmount"] | |
}, | |
"EligibilityCheckResult": { | |
"type": "object", | |
"properties": { | |
"customerId": { | |
"type": "string", | |
"description": "ID of the customer for whom eligibility is checked." | |
}, | |
"loanType": { | |
"type": "string", | |
"description": "Type of the loan for which eligibility is checked." | |
}, | |
"eligible": { | |
"type": "boolean", | |
"description": "Flag indicating whether the customer is eligible for the loan." | |
} | |
} | |
}, | |
"EligibilityCriteria": { | |
"type": "object", | |
"properties": { | |
"loanType": { | |
"type": "string", | |
"description": "Type of the loan (e.g., personal loan, home loan)." | |
}, | |
"criteria": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
}, | |
"description": "List of eligibility criteria for the loan." | |
} | |
} | |
}, | |
"LoanTypeList": { | |
"type": "object", | |
"properties": { | |
"loanTypes": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
}, | |
"description": "List of available loan types." | |
} | |
} | |
}, | |
"LoanApplicationRequirements": { | |
"type": "object", | |
"properties": { | |
"loanType": { | |
"type": "string", | |
"description": "Type of the loan (e.g., personal loan, home loan)." | |
}, | |
"requirements": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
}, | |
"description": "List of requirements for loan application." | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment