diff --git a/.swagger-codegen-ignore b/.swagger-codegen-ignore new file mode 100644 index 0000000..c5fa491 --- /dev/null +++ b/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/.swagger-codegen/VERSION b/.swagger-codegen/VERSION new file mode 100644 index 0000000..1617617 --- /dev/null +++ b/.swagger-codegen/VERSION @@ -0,0 +1 @@ +3.0.46 \ No newline at end of file diff --git a/IO.Swagger.sln b/IO.Swagger.sln new file mode 100644 index 0000000..b815e98 --- /dev/null +++ b/IO.Swagger.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34003.232 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{DE0790AC-036E-402C-BB2D-6FF54543B851}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DE0790AC-036E-402C-BB2D-6FF54543B851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DE0790AC-036E-402C-BB2D-6FF54543B851}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DE0790AC-036E-402C-BB2D-6FF54543B851}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DE0790AC-036E-402C-BB2D-6FF54543B851}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C5D6DB47-4B18-4926-A927-0313EB9C300D} + EndGlobalSection +EndGlobal diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000..5db080c --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/README.md b/README.md index 4e75b2b..ecaec9a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,25 @@ -# bank-backend +# IO.Swagger - ASP.NET Core 2.0 Server +API documentation for T&J Central Bank's digital wallets + +## Run + +Linux/OS X: + +``` +sh build.sh +``` + +Windows: + +``` +build.bat +``` + +## Run in Docker + +``` +cd src/IO.Swagger +docker build -t io.swagger . +docker run -p 5000:5000 io.swagger +``` diff --git a/aspnetcore-server-generated.zip b/aspnetcore-server-generated.zip new file mode 100644 index 0000000..56bc5d5 Binary files /dev/null and b/aspnetcore-server-generated.zip differ diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..2e04123 --- /dev/null +++ b/build.bat @@ -0,0 +1,9 @@ +:: Generated by: https://github.com/swagger-api/swagger-codegen.git +:: + +@echo off + +dotnet restore src\IO.Swagger +dotnet build src\IO.Swagger +echo Now, run the following to start the project: dotnet run -p src\IO.Swagger\IO.Swagger.csproj --launch-profile web. +echo. diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..ce6063a --- /dev/null +++ b/build.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# +# Generated by: https://github.com/swagger-api/swagger-codegen.git +# + +dotnet restore src/IO.Swagger/ && \ + dotnet build src/IO.Swagger/ && \ + echo "Now, run the following to start the project: dotnet run -p src/IO.Swagger/IO.Swagger.csproj --launch-profile web" diff --git a/src/IO.Swagger/.gitignore b/src/IO.Swagger/.gitignore new file mode 100644 index 0000000..cd9b840 --- /dev/null +++ b/src/IO.Swagger/.gitignore @@ -0,0 +1,208 @@ +PID + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +bower_components/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt diff --git a/src/IO.Swagger/Attributes/ValidateModelStateAttribute.cs b/src/IO.Swagger/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 0000000..07cfabe --- /dev/null +++ b/src/IO.Swagger/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,61 @@ +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace IO.Swagger.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + var descriptor = context.ActionDescriptor as ControllerActionDescriptor; + if (descriptor != null) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object args = null; + if (context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + var validationAttribute = attributeInstance as ValidationAttribute; + if (validationAttribute != null) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/src/IO.Swagger/Controllers/AuthApi.cs b/src/IO.Swagger/Controllers/AuthApi.cs new file mode 100644 index 0000000..d7766cb --- /dev/null +++ b/src/IO.Swagger/Controllers/AuthApi.cs @@ -0,0 +1,97 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations; +using IO.Swagger.Attributes; +using IO.Swagger.Security; +using Microsoft.AspNetCore.Authorization; +using IO.Swagger.Models; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class AuthApiController : ControllerBase + { + /// + /// Get user details + /// + /// Successful response + /// Unauthorized + [HttpGet] + [Route("/v1/api/auth/details")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("GetUserDetails")] + public virtual IActionResult GetUserDetails() + { + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + + /// + /// Log in with email and password + /// + /// + /// Logged in successfully + /// Unauthorized + [HttpPost] + [Route("/v1/api/auth/login")] + [ValidateModelState] + [SwaggerOperation("LoginUser")] + public virtual IActionResult LoginUser([FromBody]AuthLoginBody body) + { + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + + /// + /// Register a new user + /// + /// + /// User registered successfully + /// Bad Request + /// Conflict (user with provided email already exists) + [HttpPost] + [Route("/v1/api/auth/register")] + [ValidateModelState] + [SwaggerOperation("RegisterUser")] + public virtual IActionResult RegisterUser([FromBody]AuthRegisterBody body) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201); + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + //TODO: Uncomment the next line to return response 409 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(409); + + throw new NotImplementedException(); + } + } +} diff --git a/src/IO.Swagger/Controllers/CurrencyApi.cs b/src/IO.Swagger/Controllers/CurrencyApi.cs new file mode 100644 index 0000000..1279c00 --- /dev/null +++ b/src/IO.Swagger/Controllers/CurrencyApi.cs @@ -0,0 +1,134 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations; +using IO.Swagger.Attributes; +using IO.Swagger.Security; +using Microsoft.AspNetCore.Authorization; +using IO.Swagger.Models; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class CurrencyApiController : ControllerBase + { + /// + /// Add a digital asset to the user's collection + /// + /// + /// Successful asset addition + /// Bad Request + /// Unauthorized + [HttpPost] + [Route("/v1/api/currency/addAsset")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("AddDigitalAssetToCollection")] + public virtual IActionResult AddDigitalAssetToCollection([FromBody]CurrencyAddAssetBody body) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201); + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + + /// + /// Create a new collection of digital assets owned by the user + /// + /// + /// Successful collection creation + /// Bad Request + /// Unauthorized + [HttpPost] + [Route("/v1/api/currency/createCollection")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("CreateAssetCollection")] + public virtual IActionResult CreateAssetCollection([FromBody]CurrencyCreateCollectionBody body) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201); + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + + /// + /// Create a new currency type + /// + /// + /// Currency type created successfully + /// Bad Request + /// Unauthorized + [HttpPost] + [Route("/v1/api/currency/create")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("CreateCurrency")] + public virtual IActionResult CreateCurrency([FromBody]CurrencyCreateBody body) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201); + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + + /// + /// Mint additional units of a currency + /// + /// + /// Successful minting + /// Bad Request + /// Unauthorized + [HttpPost] + [Route("/v1/api/currency/mint")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("MintCurrency")] + public virtual IActionResult MintCurrency([FromBody]CurrencyMintBody body) + { + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + } +} diff --git a/src/IO.Swagger/Controllers/WalletApi.cs b/src/IO.Swagger/Controllers/WalletApi.cs new file mode 100644 index 0000000..6c8c07e --- /dev/null +++ b/src/IO.Swagger/Controllers/WalletApi.cs @@ -0,0 +1,103 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations; +using IO.Swagger.Attributes; +using IO.Swagger.Security; +using Microsoft.AspNetCore.Authorization; +using IO.Swagger.Models; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class WalletApiController : ControllerBase + { + /// + /// Get user's wallet + /// + /// Successful response + /// Unauthorized + [HttpGet] + [Route("/v1/api/wallet")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("GetUserWallet")] + public virtual IActionResult GetUserWallet() + { + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + + /// + /// Transfer digital asset to another user + /// + /// + /// Successful transfer + /// Bad Request + /// Unauthorized + [HttpPost] + [Route("/v1/api/wallet/transferDigital")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("TransferDigitalAsset")] + public virtual IActionResult TransferDigitalAsset([FromBody]WalletTransferDigitalBody body) + { + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + + /// + /// Transfer physical currency to another user + /// + /// + /// Successful transfer + /// Bad Request + /// Unauthorized + [HttpPost] + [Route("/v1/api/wallet/transferPhysical")] + [Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)] + [ValidateModelState] + [SwaggerOperation("TransferPhysicalCurrency")] + public virtual IActionResult TransferPhysicalCurrency([FromBody]WalletTransferPhysicalBody body) + { + //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(200); + + //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(400); + + //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(401); + + throw new NotImplementedException(); + } + } +} diff --git a/src/IO.Swagger/Dockerfile b/src/IO.Swagger/Dockerfile new file mode 100644 index 0000000..a22c4e1 --- /dev/null +++ b/src/IO.Swagger/Dockerfile @@ -0,0 +1,19 @@ +FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env +WORKDIR /app + +ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 + +# copy csproj and restore as distinct layers +COPY *.csproj ./ +RUN dotnet restore + +# copy everything else and build +COPY . ./ +RUN dotnet publish -c Release -o out + +# build runtime image +FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 +WORKDIR /app +COPY --from=build-env /app/out . + +ENTRYPOINT ["dotnet", "IO.Swagger.dll"] diff --git a/src/IO.Swagger/Filters/BasePathFilter.cs b/src/IO.Swagger/Filters/BasePathFilter.cs new file mode 100644 index 0000000..c9d95d6 --- /dev/null +++ b/src/IO.Swagger/Filters/BasePathFilter.cs @@ -0,0 +1,51 @@ +using System.Linq; +using System.Text.RegularExpressions; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; +using Microsoft.OpenApi.Models; + +namespace IO.Swagger.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of Swagger and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the Swagger Doc + /// + /// The BasePath of the Swagger Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) + { + swaggerDoc.Servers.Add(new OpenApiServer() { Url = this.BasePath }); + + var pathsToModify = swaggerDoc.Paths.Where(p => p.Key.StartsWith(this.BasePath)).ToList(); + + foreach (var path in pathsToModify) + { + if (path.Key.StartsWith(this.BasePath)) + { + string newKey = Regex.Replace(path.Key, $"^{this.BasePath}", string.Empty); + swaggerDoc.Paths.Remove(path.Key); + swaggerDoc.Paths.Add(newKey, path.Value); + } + } + } + } +} diff --git a/src/IO.Swagger/Filters/GeneratePathParamsValidationFilter.cs b/src/IO.Swagger/Filters/GeneratePathParamsValidationFilter.cs new file mode 100644 index 0000000..1845e56 --- /dev/null +++ b/src/IO.Swagger/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,96 @@ +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace IO.Swagger.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var swaggerParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes; + + if (attributes != null && attributes.Count() > 0 && swaggerParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + swaggerParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + string regex = (string)regexAttr.ConstructorArguments[0].Value; + if (swaggerParam is OpenApiParameter) + { + ((OpenApiParameter)swaggerParam).Schema.Pattern = regex; + } + } + + // String Length [StringLength] + int? minLenght = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLenght = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLenght = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (swaggerParam is OpenApiParameter) + { + ((OpenApiParameter)swaggerParam).Schema.MinLength = minLenght; + ((OpenApiParameter)swaggerParam).Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + int rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + int rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + if (swaggerParam is OpenApiParameter) + { + ((OpenApiParameter)swaggerParam).Schema.Minimum = rangeMin; + ((OpenApiParameter)swaggerParam).Schema.Maximum = rangeMax; + } + } + } + } + } + } +} diff --git a/src/IO.Swagger/IO.Swagger.csproj b/src/IO.Swagger/IO.Swagger.csproj new file mode 100644 index 0000000..77cf8af --- /dev/null +++ b/src/IO.Swagger/IO.Swagger.csproj @@ -0,0 +1,21 @@ + + + IO.Swagger + IO.Swagger + net7.0 + true + true + IO.Swagger + IO.Swagger + + + + + + + + + + + + diff --git a/src/IO.Swagger/Models/AuthLoginBody.cs b/src/IO.Swagger/Models/AuthLoginBody.cs new file mode 100644 index 0000000..f821de0 --- /dev/null +++ b/src/IO.Swagger/Models/AuthLoginBody.cs @@ -0,0 +1,135 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class AuthLoginBody : IEquatable + { + /// + /// Gets or Sets Email + /// + + [DataMember(Name="email")] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + + [DataMember(Name="password")] + public string Password { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class AuthLoginBody {\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((AuthLoginBody)obj); + } + + /// + /// Returns true if AuthLoginBody instances are equal + /// + /// Instance of AuthLoginBody to be compared + /// Boolean + public bool Equals(AuthLoginBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Password == other.Password || + Password != null && + Password.Equals(other.Password) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Password != null) + hashCode = hashCode * 59 + Password.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(AuthLoginBody left, AuthLoginBody right) + { + return Equals(left, right); + } + + public static bool operator !=(AuthLoginBody left, AuthLoginBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Models/AuthRegisterBody.cs b/src/IO.Swagger/Models/AuthRegisterBody.cs new file mode 100644 index 0000000..1374ecf --- /dev/null +++ b/src/IO.Swagger/Models/AuthRegisterBody.cs @@ -0,0 +1,167 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class AuthRegisterBody : IEquatable + { + /// + /// Gets or Sets FirstName + /// + + [StringLength(32, MinimumLength=3)] + [DataMember(Name="firstName")] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + + [StringLength(32, MinimumLength=3)] + [DataMember(Name="lastName")] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + + [DataMember(Name="email")] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + + [DataMember(Name="password")] + public string Password { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class AuthRegisterBody {\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((AuthRegisterBody)obj); + } + + /// + /// Returns true if AuthRegisterBody instances are equal + /// + /// Instance of AuthRegisterBody to be compared + /// Boolean + public bool Equals(AuthRegisterBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + FirstName == other.FirstName || + FirstName != null && + FirstName.Equals(other.FirstName) + ) && + ( + LastName == other.LastName || + LastName != null && + LastName.Equals(other.LastName) + ) && + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Password == other.Password || + Password != null && + Password.Equals(other.Password) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (FirstName != null) + hashCode = hashCode * 59 + FirstName.GetHashCode(); + if (LastName != null) + hashCode = hashCode * 59 + LastName.GetHashCode(); + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Password != null) + hashCode = hashCode * 59 + Password.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(AuthRegisterBody left, AuthRegisterBody right) + { + return Equals(left, right); + } + + public static bool operator !=(AuthRegisterBody left, AuthRegisterBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Models/CurrencyAddAssetBody.cs b/src/IO.Swagger/Models/CurrencyAddAssetBody.cs new file mode 100644 index 0000000..db780c8 --- /dev/null +++ b/src/IO.Swagger/Models/CurrencyAddAssetBody.cs @@ -0,0 +1,151 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class CurrencyAddAssetBody : IEquatable + { + /// + /// Gets or Sets CollectionId + /// + + [DataMember(Name="collectionId")] + public int? CollectionId { get; set; } + + /// + /// Gets or Sets AssetName + /// + + [StringLength(32, MinimumLength=1)] + [DataMember(Name="assetName")] + public string AssetName { get; set; } + + /// + /// Gets or Sets AssetLink + /// + [RegularExpression("/^(https?|ftp)://[^\\s/$.?#].[^\\s]*$/")] + [DataMember(Name="assetLink")] + public string AssetLink { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class CurrencyAddAssetBody {\n"); + sb.Append(" CollectionId: ").Append(CollectionId).Append("\n"); + sb.Append(" AssetName: ").Append(AssetName).Append("\n"); + sb.Append(" AssetLink: ").Append(AssetLink).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((CurrencyAddAssetBody)obj); + } + + /// + /// Returns true if CurrencyAddAssetBody instances are equal + /// + /// Instance of CurrencyAddAssetBody to be compared + /// Boolean + public bool Equals(CurrencyAddAssetBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + CollectionId == other.CollectionId || + CollectionId != null && + CollectionId.Equals(other.CollectionId) + ) && + ( + AssetName == other.AssetName || + AssetName != null && + AssetName.Equals(other.AssetName) + ) && + ( + AssetLink == other.AssetLink || + AssetLink != null && + AssetLink.Equals(other.AssetLink) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (CollectionId != null) + hashCode = hashCode * 59 + CollectionId.GetHashCode(); + if (AssetName != null) + hashCode = hashCode * 59 + AssetName.GetHashCode(); + if (AssetLink != null) + hashCode = hashCode * 59 + AssetLink.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(CurrencyAddAssetBody left, CurrencyAddAssetBody right) + { + return Equals(left, right); + } + + public static bool operator !=(CurrencyAddAssetBody left, CurrencyAddAssetBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Models/CurrencyCreateBody.cs b/src/IO.Swagger/Models/CurrencyCreateBody.cs new file mode 100644 index 0000000..0b506bf --- /dev/null +++ b/src/IO.Swagger/Models/CurrencyCreateBody.cs @@ -0,0 +1,137 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class CurrencyCreateBody : IEquatable + { + /// + /// Gets or Sets Name + /// + + [StringLength(32, MinimumLength=1)] + [DataMember(Name="name")] + public string Name { get; set; } + + /// + /// Gets or Sets Symbol + /// + + [StringLength(4, MinimumLength=1)] + [DataMember(Name="symbol")] + public string Symbol { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class CurrencyCreateBody {\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" Symbol: ").Append(Symbol).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((CurrencyCreateBody)obj); + } + + /// + /// Returns true if CurrencyCreateBody instances are equal + /// + /// Instance of CurrencyCreateBody to be compared + /// Boolean + public bool Equals(CurrencyCreateBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Name == other.Name || + Name != null && + Name.Equals(other.Name) + ) && + ( + Symbol == other.Symbol || + Symbol != null && + Symbol.Equals(other.Symbol) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Name != null) + hashCode = hashCode * 59 + Name.GetHashCode(); + if (Symbol != null) + hashCode = hashCode * 59 + Symbol.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(CurrencyCreateBody left, CurrencyCreateBody right) + { + return Equals(left, right); + } + + public static bool operator !=(CurrencyCreateBody left, CurrencyCreateBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Models/CurrencyCreateCollectionBody.cs b/src/IO.Swagger/Models/CurrencyCreateCollectionBody.cs new file mode 100644 index 0000000..9d7f8b0 --- /dev/null +++ b/src/IO.Swagger/Models/CurrencyCreateCollectionBody.cs @@ -0,0 +1,120 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class CurrencyCreateCollectionBody : IEquatable + { + /// + /// Gets or Sets CollectionName + /// + + [DataMember(Name="collectionName")] + public string CollectionName { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class CurrencyCreateCollectionBody {\n"); + sb.Append(" CollectionName: ").Append(CollectionName).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((CurrencyCreateCollectionBody)obj); + } + + /// + /// Returns true if CurrencyCreateCollectionBody instances are equal + /// + /// Instance of CurrencyCreateCollectionBody to be compared + /// Boolean + public bool Equals(CurrencyCreateCollectionBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + CollectionName == other.CollectionName || + CollectionName != null && + CollectionName.Equals(other.CollectionName) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (CollectionName != null) + hashCode = hashCode * 59 + CollectionName.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(CurrencyCreateCollectionBody left, CurrencyCreateCollectionBody right) + { + return Equals(left, right); + } + + public static bool operator !=(CurrencyCreateCollectionBody left, CurrencyCreateCollectionBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Models/CurrencyMintBody.cs b/src/IO.Swagger/Models/CurrencyMintBody.cs new file mode 100644 index 0000000..8ff6244 --- /dev/null +++ b/src/IO.Swagger/Models/CurrencyMintBody.cs @@ -0,0 +1,135 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class CurrencyMintBody : IEquatable + { + /// + /// Gets or Sets CurrencyId + /// + + [DataMember(Name="currencyId")] + public int? CurrencyId { get; set; } + + /// + /// Gets or Sets Amount + /// + + [DataMember(Name="amount")] + public decimal? Amount { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class CurrencyMintBody {\n"); + sb.Append(" CurrencyId: ").Append(CurrencyId).Append("\n"); + sb.Append(" Amount: ").Append(Amount).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((CurrencyMintBody)obj); + } + + /// + /// Returns true if CurrencyMintBody instances are equal + /// + /// Instance of CurrencyMintBody to be compared + /// Boolean + public bool Equals(CurrencyMintBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + CurrencyId == other.CurrencyId || + CurrencyId != null && + CurrencyId.Equals(other.CurrencyId) + ) && + ( + Amount == other.Amount || + Amount != null && + Amount.Equals(other.Amount) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (CurrencyId != null) + hashCode = hashCode * 59 + CurrencyId.GetHashCode(); + if (Amount != null) + hashCode = hashCode * 59 + Amount.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(CurrencyMintBody left, CurrencyMintBody right) + { + return Equals(left, right); + } + + public static bool operator !=(CurrencyMintBody left, CurrencyMintBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Models/WalletTransferDigitalBody.cs b/src/IO.Swagger/Models/WalletTransferDigitalBody.cs new file mode 100644 index 0000000..358c7d2 --- /dev/null +++ b/src/IO.Swagger/Models/WalletTransferDigitalBody.cs @@ -0,0 +1,135 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class WalletTransferDigitalBody : IEquatable + { + /// + /// Gets or Sets Email + /// + + [DataMember(Name="email")] + public string Email { get; set; } + + /// + /// Gets or Sets AssetId + /// + + [DataMember(Name="assetId")] + public int? AssetId { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class WalletTransferDigitalBody {\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" AssetId: ").Append(AssetId).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((WalletTransferDigitalBody)obj); + } + + /// + /// Returns true if WalletTransferDigitalBody instances are equal + /// + /// Instance of WalletTransferDigitalBody to be compared + /// Boolean + public bool Equals(WalletTransferDigitalBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + AssetId == other.AssetId || + AssetId != null && + AssetId.Equals(other.AssetId) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (AssetId != null) + hashCode = hashCode * 59 + AssetId.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(WalletTransferDigitalBody left, WalletTransferDigitalBody right) + { + return Equals(left, right); + } + + public static bool operator !=(WalletTransferDigitalBody left, WalletTransferDigitalBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Models/WalletTransferPhysicalBody.cs b/src/IO.Swagger/Models/WalletTransferPhysicalBody.cs new file mode 100644 index 0000000..2233bcc --- /dev/null +++ b/src/IO.Swagger/Models/WalletTransferPhysicalBody.cs @@ -0,0 +1,150 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class WalletTransferPhysicalBody : IEquatable + { + /// + /// Gets or Sets Email + /// + + [DataMember(Name="email")] + public string Email { get; set; } + + /// + /// Gets or Sets Amount + /// + + [DataMember(Name="amount")] + public decimal? Amount { get; set; } + + /// + /// Gets or Sets CurrencyId + /// + + [DataMember(Name="currencyId")] + public int? CurrencyId { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class WalletTransferPhysicalBody {\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Amount: ").Append(Amount).Append("\n"); + sb.Append(" CurrencyId: ").Append(CurrencyId).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((WalletTransferPhysicalBody)obj); + } + + /// + /// Returns true if WalletTransferPhysicalBody instances are equal + /// + /// Instance of WalletTransferPhysicalBody to be compared + /// Boolean + public bool Equals(WalletTransferPhysicalBody other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Email == other.Email || + Email != null && + Email.Equals(other.Email) + ) && + ( + Amount == other.Amount || + Amount != null && + Amount.Equals(other.Amount) + ) && + ( + CurrencyId == other.CurrencyId || + CurrencyId != null && + CurrencyId.Equals(other.CurrencyId) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (Email != null) + hashCode = hashCode * 59 + Email.GetHashCode(); + if (Amount != null) + hashCode = hashCode * 59 + Amount.GetHashCode(); + if (CurrencyId != null) + hashCode = hashCode * 59 + CurrencyId.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(WalletTransferPhysicalBody left, WalletTransferPhysicalBody right) + { + return Equals(left, right); + } + + public static bool operator !=(WalletTransferPhysicalBody left, WalletTransferPhysicalBody right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger/Program.cs b/src/IO.Swagger/Program.cs new file mode 100644 index 0000000..ae409c1 --- /dev/null +++ b/src/IO.Swagger/Program.cs @@ -0,0 +1,29 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore; + +namespace IO.Swagger +{ + /// + /// Program + /// + public class Program + { + /// + /// Main + /// + /// + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + /// + /// Create the web host builder. + /// + /// + /// IWebHostBuilder + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); + } +} diff --git a/src/IO.Swagger/Properties/launchSettings.json b/src/IO.Swagger/Properties/launchSettings.json new file mode 100644 index 0000000..5bb6f82 --- /dev/null +++ b/src/IO.Swagger/Properties/launchSettings.json @@ -0,0 +1,36 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50352/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger/", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "web": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "publishAllPorts": true, + "useSSL": true + } + } +} \ No newline at end of file diff --git a/src/IO.Swagger/Security/BearerAuthenticationHandler.cs b/src/IO.Swagger/Security/BearerAuthenticationHandler.cs new file mode 100644 index 0000000..15c7ab0 --- /dev/null +++ b/src/IO.Swagger/Security/BearerAuthenticationHandler.cs @@ -0,0 +1,58 @@ +using System; +using System.Net.Http.Headers; +using System.Security.Claims; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace IO.Swagger.Security +{ + /// + /// class to handle bearer authentication. + /// + public class BearerAuthenticationHandler : AuthenticationHandler + { + /// + /// scheme name for authentication handler. + /// + public const string SchemeName = "Bearer"; + + public BearerAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) + { + } + + /// + /// verify that require authorization header exists. + /// + protected override async Task HandleAuthenticateAsync() + { + if (!Request.Headers.ContainsKey("Authorization")) + { + return AuthenticateResult.Fail("Missing Authorization Header"); + } + try + { + var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]); + + /// TODO handle token. + } + catch + { + return AuthenticateResult.Fail("Invalid Authorization Header"); + } + + var claims = new[] { + new Claim(ClaimTypes.NameIdentifier, "changeme"), + new Claim(ClaimTypes.Name, "changeme"), + }; + var identity = new ClaimsIdentity(claims, Scheme.Name); + var principal = new ClaimsPrincipal(identity); + var ticket = new AuthenticationTicket(principal, Scheme.Name); + + return AuthenticateResult.Success(ticket); + } + } +} diff --git a/src/IO.Swagger/Startup.cs b/src/IO.Swagger/Startup.cs new file mode 100644 index 0000000..9a497e9 --- /dev/null +++ b/src/IO.Swagger/Startup.cs @@ -0,0 +1,146 @@ +/* + * T&J Central Bank API + * + * API documentation for T&J Central Bank's digital wallets + * + * OpenAPI spec version: 1.0.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.IO; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; +using IO.Swagger.Filters; +using IO.Swagger.Security; + +namespace IO.Swagger +{ + /// + /// Startup + /// + public class Startup + { + private readonly IWebHostEnvironment _hostingEnv; + + private IConfiguration Configuration { get; } + + /// + /// Constructor + /// + /// + /// + public Startup(IWebHostEnvironment env, IConfiguration configuration) + { + _hostingEnv = env; + Configuration = configuration; + } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + // Add framework services. + services + .AddMvc(options => + { + options.InputFormatters.RemoveType(); + options.OutputFormatters.RemoveType(); + }) + .AddNewtonsoftJson(opts => + { + opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + opts.SerializerSettings.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy())); + }) + .AddXmlSerializerFormatters(); + + services.AddAuthentication(BearerAuthenticationHandler.SchemeName) + .AddScheme(BearerAuthenticationHandler.SchemeName, null); + + + services + .AddSwaggerGen(c => + { + c.SwaggerDoc("1.0.0", new OpenApiInfo + { + Version = "1.0.0", + Title = "T&J Central Bank API", + Description = "T&J Central Bank API (ASP.NET 7.0)", + Contact = new OpenApiContact() + { + Name = "Swagger Codegen Contributors", + Url = new Uri("https://github.com/swagger-api/swagger-codegen"), + Email = "" + }, + // TermsOfService = new Uri("") + }); + c.CustomSchemaIds(type => type.FullName); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml"); + // Sets the basePath property in the Swagger document generated + c.DocumentFilter("/v1"); + + // Include DataAnnotation attributes on Controller Action parameters as Swagger validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.UseRouting(); + + //TODO: Uncomment this if you need wwwroot folder + // app.UseStaticFiles(); + + app.UseAuthorization(); + + app.UseSwagger(); + app.UseSwaggerUI(c => + { + //TODO: Either use the SwaggerGen generated Swagger contract (generated from C# classes) + c.SwaggerEndpoint("/swagger/1.0.0/swagger.json", "T&J Central Bank API"); + + //TODO: Or alternatively use the original Swagger contract that's included in the static files + // c.SwaggerEndpoint("/swagger-original.json", "T&J Central Bank API Original"); + }); + + //TODO: Use Https Redirection + // app.UseHttpsRedirection(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + //TODO: Enable production exception handling (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling) + app.UseExceptionHandler("/Error"); + + app.UseHsts(); + } + } + } +} diff --git a/src/IO.Swagger/appsettings.json b/src/IO.Swagger/appsettings.json new file mode 100644 index 0000000..c6af7d9 --- /dev/null +++ b/src/IO.Swagger/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Information", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/src/IO.Swagger/web.config b/src/IO.Swagger/web.config new file mode 100644 index 0000000..2c68e3c --- /dev/null +++ b/src/IO.Swagger/web.config @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/IO.Swagger/wwwroot/README.md b/src/IO.Swagger/wwwroot/README.md new file mode 100644 index 0000000..6a0b784 --- /dev/null +++ b/src/IO.Swagger/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s new. + +ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854). +Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks). + +We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015. +The ASP.NET Team + +### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016) + +### This application consists of: +* Sample pages using ASP.NET MVC 6 +* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources +* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939) + +#### NEW CONCEPTS +* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008) +* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012) +* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013) +* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014) +* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849) +* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850) + +#### CUSTOMIZE APP +* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600) +* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602) +* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603) +* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606) +* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604) +* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009) +* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848) + +#### DEPLOY +* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851) +* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852) +* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853) +* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609) +* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019) + +We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015) diff --git a/src/IO.Swagger/wwwroot/index.html b/src/IO.Swagger/wwwroot/index.html new file mode 100644 index 0000000..cde1f2f --- /dev/null +++ b/src/IO.Swagger/wwwroot/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/IO.Swagger/wwwroot/swagger-original.json b/src/IO.Swagger/wwwroot/swagger-original.json new file mode 100644 index 0000000..9ec6b5c --- /dev/null +++ b/src/IO.Swagger/wwwroot/swagger-original.json @@ -0,0 +1,471 @@ +{ + "openapi" : "3.0.0", + "info" : { + "title" : "T&J Central Bank API", + "description" : "API documentation for T&J Central Bank's digital wallets", + "version" : "1.0.0" + }, + "servers" : [ { + "url" : "https://tjbank.shrukanslab.xyz/v1" + } ], + "tags" : [ { + "name" : "auth", + "description" : "User authentication operations" + }, { + "name" : "wallet", + "description" : "User wallet operations" + }, { + "name" : "currency", + "description" : "Currency and asset operations" + } ], + "paths" : { + "/api/auth/register" : { + "post" : { + "tags" : [ "auth" ], + "summary" : "Register a new user", + "operationId" : "registerUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/auth_register_body" + } + } + }, + "required" : true + }, + "responses" : { + "201" : { + "description" : "User registered successfully", + "content" : { + "application/json" : { + "example" : { + "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" + } + } + } + }, + "400" : { + "description" : "Bad Request" + }, + "409" : { + "description" : "Conflict (user with provided email already exists)" + } + } + } + }, + "/api/auth/login" : { + "post" : { + "tags" : [ "auth" ], + "summary" : "Log in with email and password", + "operationId" : "loginUser", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/auth_login_body" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Logged in successfully", + "content" : { + "application/json" : { + "example" : { + "token" : "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + } + } + } + }, + "/api/auth/details" : { + "get" : { + "tags" : [ "auth" ], + "summary" : "Get user details", + "operationId" : "getUserDetails", + "responses" : { + "200" : { + "description" : "Successful response", + "content" : { + "application/json" : { + "example" : { + "firstName" : "John", + "lastName" : "Doe", + "email" : "user@example.com" + } + } + } + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + }, + "/api/wallet" : { + "get" : { + "tags" : [ "wallet" ], + "summary" : "Get user's wallet", + "operationId" : "getUserWallet", + "responses" : { + "200" : { + "description" : "Successful response", + "content" : { + "application/json" : { + "example" : { + "currencies" : [ { + "id" : 1, + "name" : "US Dollar", + "symbol" : "USD", + "amount" : 1500 + } ], + "digitalAssets" : [ { + "id" : 101, + "name" : "Bitcoin", + "link" : "https://example.com/bitcoin" + } ] + } + } + } + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + }, + "/api/wallet/transferPhysical" : { + "post" : { + "tags" : [ "wallet" ], + "summary" : "Transfer physical currency to another user", + "operationId" : "transferPhysicalCurrency", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/wallet_transferPhysical_body" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Successful transfer" + }, + "400" : { + "description" : "Bad Request" + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + }, + "/api/wallet/transferDigital" : { + "post" : { + "tags" : [ "wallet" ], + "summary" : "Transfer digital asset to another user", + "operationId" : "transferDigitalAsset", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/wallet_transferDigital_body" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Successful transfer" + }, + "400" : { + "description" : "Bad Request" + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + }, + "/api/currency/mint" : { + "post" : { + "tags" : [ "currency" ], + "summary" : "Mint additional units of a currency", + "operationId" : "mintCurrency", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/currency_mint_body" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "Successful minting" + }, + "400" : { + "description" : "Bad Request" + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + }, + "/api/currency/create" : { + "post" : { + "tags" : [ "currency" ], + "summary" : "Create a new currency type", + "operationId" : "createCurrency", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/currency_create_body" + } + } + }, + "required" : true + }, + "responses" : { + "201" : { + "description" : "Currency type created successfully" + }, + "400" : { + "description" : "Bad Request" + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + }, + "/api/currency/createCollection" : { + "post" : { + "tags" : [ "currency" ], + "summary" : "Create a new collection of digital assets owned by the user", + "operationId" : "createAssetCollection", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/currency_createCollection_body" + } + } + }, + "required" : true + }, + "responses" : { + "201" : { + "description" : "Successful collection creation", + "content" : { + "application/json" : { + "example" : { + "message" : "Digital asset collection created successfully", + "collectionId" : 123 + } + } + } + }, + "400" : { + "description" : "Bad Request" + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + }, + "/api/currency/addAsset" : { + "post" : { + "tags" : [ "currency" ], + "summary" : "Add a digital asset to the user's collection", + "operationId" : "addDigitalAssetToCollection", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/currency_addAsset_body" + } + } + }, + "required" : true + }, + "responses" : { + "201" : { + "description" : "Successful asset addition" + }, + "400" : { + "description" : "Bad Request" + }, + "401" : { + "description" : "Unauthorized" + } + }, + "security" : [ { + "BearerAuth" : [ ] + } ] + } + } + }, + "components" : { + "schemas" : { + "auth_register_body" : { + "type" : "object", + "properties" : { + "firstName" : { + "maxLength" : 32, + "minLength" : 3, + "type" : "string" + }, + "lastName" : { + "maxLength" : 32, + "minLength" : 3, + "type" : "string" + }, + "email" : { + "pattern" : "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", + "type" : "string", + "format" : "email" + }, + "password" : { + "type" : "string" + } + } + }, + "currency_addAsset_body" : { + "type" : "object", + "properties" : { + "collectionId" : { + "type" : "integer" + }, + "assetName" : { + "maxLength" : 32, + "minLength" : 1, + "type" : "string" + }, + "assetLink" : { + "pattern" : "^(https?|ftp):\\/\\/[^\\s/$.?#].[^\\s]*$", + "type" : "string" + } + } + }, + "currency_create_body" : { + "type" : "object", + "properties" : { + "name" : { + "maxLength" : 32, + "minLength" : 1, + "type" : "string" + }, + "symbol" : { + "maxLength" : 4, + "minLength" : 1, + "type" : "string" + } + } + }, + "auth_login_body" : { + "type" : "object", + "properties" : { + "email" : { + "pattern" : "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", + "type" : "string", + "format" : "email" + }, + "password" : { + "type" : "string" + } + } + }, + "currency_mint_body" : { + "type" : "object", + "properties" : { + "currencyId" : { + "type" : "integer" + }, + "amount" : { + "type" : "number" + } + } + }, + "currency_createCollection_body" : { + "type" : "object", + "properties" : { + "collectionName" : { + "type" : "string" + } + } + }, + "wallet_transferPhysical_body" : { + "type" : "object", + "properties" : { + "email" : { + "type" : "string", + "format" : "email" + }, + "amount" : { + "type" : "number" + }, + "currencyId" : { + "type" : "integer" + } + } + }, + "wallet_transferDigital_body" : { + "type" : "object", + "properties" : { + "email" : { + "type" : "string", + "format" : "email" + }, + "assetId" : { + "type" : "integer" + } + } + } + }, + "securitySchemes" : { + "BearerAuth" : { + "type" : "http", + "scheme" : "bearer", + "bearerFormat" : "JWT" + } + } + } +} diff --git a/src/IO.Swagger/wwwroot/web.config b/src/IO.Swagger/wwwroot/web.config new file mode 100644 index 0000000..e70a777 --- /dev/null +++ b/src/IO.Swagger/wwwroot/web.config @@ -0,0 +1,9 @@ + + + + + + + + +