Created
January 12, 2024 09:50
-
-
Save pmutua/399fe8fe82613eb3a7e4c1aabf080d83 to your computer and use it in GitHub Desktop.
Example Swagger 2.0 JSON file for a Currency Conversion 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": "Currency Conversion API", | |
"description": "Convert between different currencies at real-time rates.", | |
"version": "1.0.0" | |
}, | |
"basePath": "/api", | |
"schemes": ["http", "https"], | |
"paths": { | |
"/currencies": { | |
"get": { | |
"summary": "Get Available Currencies", | |
"description": "Endpoint to get a list of available currencies for conversion.", | |
"produces": ["application/json"], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/CurrencyList" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
}, | |
"/convert": { | |
"post": { | |
"summary": "Currency Conversion", | |
"description": "Endpoint to convert between different currencies.", | |
"consumes": ["application/json"], | |
"produces": ["application/json"], | |
"parameters": [ | |
{ | |
"in": "body", | |
"name": "conversionData", | |
"description": "Currency conversion data", | |
"schema": { | |
"$ref": "#/definitions/CurrencyConversionData" | |
} | |
} | |
], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/CurrencyConversionResult" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
}, | |
"/exchange-rates": { | |
"get": { | |
"summary": "Get Real-Time Exchange Rates", | |
"description": "Endpoint to get real-time exchange rates between different currencies.", | |
"produces": ["application/json"], | |
"responses": { | |
"200": { | |
"description": "Successful response", | |
"schema": { | |
"$ref": "#/definitions/ExchangeRates" | |
} | |
}, | |
"400": { | |
"description": "Bad request", | |
"schema": { | |
"$ref": "#/definitions/ErrorModel" | |
} | |
} | |
} | |
} | |
} | |
}, | |
"definitions": { | |
"ErrorModel": { | |
"type": "object", | |
"properties": { | |
"error": { | |
"type": "string", | |
"description": "Error message." | |
} | |
} | |
}, | |
"CurrencyList": { | |
"type": "object", | |
"properties": { | |
"currencies": { | |
"type": "array", | |
"items": { | |
"type": "string" | |
}, | |
"description": "List of available currencies for conversion." | |
} | |
} | |
}, | |
"CurrencyConversionData": { | |
"type": "object", | |
"properties": { | |
"fromCurrency": { | |
"type": "string", | |
"description": "Currency code of the currency to convert from." | |
}, | |
"toCurrency": { | |
"type": "string", | |
"description": "Currency code of the currency to convert to." | |
}, | |
"amount": { | |
"type": "number", | |
"description": "Amount to convert." | |
} | |
}, | |
"required": ["fromCurrency", "toCurrency", "amount"] | |
}, | |
"CurrencyConversionResult": { | |
"type": "object", | |
"properties": { | |
"fromCurrency": { | |
"type": "string", | |
"description": "Currency code of the original currency." | |
}, | |
"toCurrency": { | |
"type": "string", | |
"description": "Currency code of the converted currency." | |
}, | |
"originalAmount": { | |
"type": "number", | |
"description": "Original amount before conversion." | |
}, | |
"convertedAmount": { | |
"type": "number", | |
"description": "Amount after conversion." | |
} | |
} | |
}, | |
"ExchangeRates": { | |
"type": "object", | |
"properties": { | |
"rates": { | |
"type": "object", | |
"description": "Real-time exchange rates between different currencies." | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment