Commit 287b338e authored by Jeremy Bokobza's avatar Jeremy Bokobza Committed by GitHub

Merge pull request #24 from stratisproject/feature/more-types

Added Swagger controller methods comments
parents 31db50fa b08ea8bc
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework> <TargetFramework>netcoreapp1.0</TargetFramework>
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback> <PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\\Breeze.Deamon\\bin\\Debug\\netcoreapp1.0\\Breeze.Api.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" />
......
...@@ -15,6 +15,10 @@ namespace Breeze.Api.Controllers ...@@ -15,6 +15,10 @@ namespace Breeze.Api.Controllers
this.blockNotification = blockNotification; this.blockNotification = blockNotification;
} }
/// <summary>
/// Returns some general information about the status of the underlying node.
/// </summary>
/// <returns></returns>
[HttpGet] [HttpGet]
[Route("status")] [Route("status")]
public IActionResult Status() public IActionResult Status()
...@@ -22,6 +26,12 @@ namespace Breeze.Api.Controllers ...@@ -22,6 +26,12 @@ namespace Breeze.Api.Controllers
return this.NotFound(); return this.NotFound();
} }
/// <summary>
/// Starts sending block to the wallet for synchronisation.
/// This is for demo and testing use only.
/// </summary>
/// <param name="model">The hash of the block from which to start syncing.</param>
/// <returns></returns>
[HttpPost] [HttpPost]
[Route("sync")] [Route("sync")]
public IActionResult Sync([FromBody] HashModel model) public IActionResult Sync([FromBody] HashModel model)
......
using System.Linq; using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.Swagger;
namespace Breeze.Api namespace Breeze.Api
...@@ -55,7 +57,14 @@ namespace Breeze.Api ...@@ -55,7 +57,14 @@ namespace Breeze.Api
return true; return true;
}); });
});
//Set the comments path for the swagger json and ui.
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
var apiXmlPath = Path.Combine(basePath, "Breeze.Api.xml");
var walletXmlPath = Path.Combine(basePath, "Breeze.Wallet.xml");
setup.IncludeXmlComments(apiXmlPath);
setup.IncludeXmlComments(walletXmlPath);
});
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>..\\Breeze.Deamon\\bin\\Debug\\netcoreapp1.0\\Breeze.Wallet.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HBitcoin" Version="0.1.5" /> <PackageReference Include="HBitcoin" Version="0.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" />
......
...@@ -11,6 +11,9 @@ using Breeze.Wallet.Wrappers; ...@@ -11,6 +11,9 @@ using Breeze.Wallet.Wrappers;
namespace Breeze.Wallet.Controllers namespace Breeze.Wallet.Controllers
{ {
/// <summary>
/// Controller providing operations on a wallet.
/// </summary>
[Route("api/v{version:apiVersion}/[controller]")] [Route("api/v{version:apiVersion}/[controller]")]
public class WalletController : Controller public class WalletController : Controller
{ {
...@@ -49,6 +52,11 @@ namespace Breeze.Wallet.Controllers ...@@ -49,6 +52,11 @@ namespace Breeze.Wallet.Controllers
} }
} }
/// <summary>
/// Loads a wallet previously created by the user.
/// </summary>
/// <param name="walletLoad">The name of the wallet to load.</param>
/// <returns></returns>
[Route("load")] [Route("load")]
[HttpPost] [HttpPost]
public IActionResult Load([FromBody]WalletLoadRequest walletLoad) public IActionResult Load([FromBody]WalletLoadRequest walletLoad)
...@@ -81,6 +89,11 @@ namespace Breeze.Wallet.Controllers ...@@ -81,6 +89,11 @@ namespace Breeze.Wallet.Controllers
} }
} }
/// <summary>
/// Recovers a wallet.
/// </summary>
/// <param name="walletRecovery">The object containing the parameters used to recover a wallet.</param>
/// <returns></returns>
[Route("recover")] [Route("recover")]
[HttpPost] [HttpPost]
public IActionResult Recover([FromBody]WalletRecoveryRequest walletRecovery) public IActionResult Recover([FromBody]WalletRecoveryRequest walletRecovery)
...@@ -113,8 +126,13 @@ namespace Breeze.Wallet.Controllers ...@@ -113,8 +126,13 @@ namespace Breeze.Wallet.Controllers
return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString()); return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString());
} }
} }
[Route("info")] /// <summary>
/// Get some general info about a wallet.
/// </summary>
/// <param name="model">The name of the wallet.</param>
/// <returns></returns>
[Route("info")]
[HttpGet] [HttpGet]
public IActionResult GetInfo([FromQuery] WalletName model) public IActionResult GetInfo([FromQuery] WalletName model)
{ {
...@@ -136,6 +154,11 @@ namespace Breeze.Wallet.Controllers ...@@ -136,6 +154,11 @@ namespace Breeze.Wallet.Controllers
} }
} }
/// <summary>
/// Retrieves the history of a wallet.
/// </summary>
/// <param name="model">The name of the wallet.</param>
/// <returns></returns>
[Route("history")] [Route("history")]
[HttpGet] [HttpGet]
public IActionResult GetHistory([FromQuery] WalletName model) public IActionResult GetHistory([FromQuery] WalletName model)
...@@ -158,6 +181,11 @@ namespace Breeze.Wallet.Controllers ...@@ -158,6 +181,11 @@ namespace Breeze.Wallet.Controllers
} }
} }
/// <summary>
/// Gets the balance of a wallet.
/// </summary>
/// <param name="model">The name of the wallet.</param>
/// <returns></returns>
[Route("balance")] [Route("balance")]
[HttpGet] [HttpGet]
public IActionResult GetBalance([FromQuery] WalletName model) public IActionResult GetBalance([FromQuery] WalletName model)
...@@ -180,6 +208,11 @@ namespace Breeze.Wallet.Controllers ...@@ -180,6 +208,11 @@ namespace Breeze.Wallet.Controllers
} }
} }
/// <summary>
/// Builds a transaction.
/// </summary>
/// <param name="request">The transaction parameters.</param>
/// <returns>All the details of the transaction, including the hex used to execute it.</returns>
[Route("build-transaction")] [Route("build-transaction")]
[HttpPost] [HttpPost]
public IActionResult BuildTransaction([FromBody] BuildTransactionRequest request) public IActionResult BuildTransaction([FromBody] BuildTransactionRequest request)
...@@ -202,6 +235,11 @@ namespace Breeze.Wallet.Controllers ...@@ -202,6 +235,11 @@ namespace Breeze.Wallet.Controllers
} }
} }
/// <summary>
/// Sends a transaction.
/// </summary>
/// <param name="request">The hex representing the transaction.</param>
/// <returns></returns>
[Route("send-transaction")] [Route("send-transaction")]
[HttpPost] [HttpPost]
public IActionResult SendTransaction([FromBody] SendTransactionRequest request) public IActionResult SendTransaction([FromBody] SendTransactionRequest request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment