Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Stratis.Features.Unity3dApi/Controllers/Unity3dController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public GetUTXOsResponseModel GetUTXOsForAddress([FromQuery] string address)
/// <response code="400">Unexpected exception occurred</response>
[Route("getaddressbalance")]
[HttpGet]
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GetBalanceResponseModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
public IActionResult GetAddressBalance(string address)
{
Expand Down Expand Up @@ -304,10 +304,10 @@ public RawTxModel GetRawTransaction([FromQuery] string trxid)
/// <response code="500">Request is null</response>
[Route("send-transaction")]
[HttpPost]
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.Forbidden)]
[ProducesResponseType((int)HttpStatusCode.InternalServerError)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(WalletSendTransactionModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(ErrorResult))]
[ProducesResponseType((int)HttpStatusCode.Forbidden, Type = typeof(ErrorResult))]
[ProducesResponseType((int)HttpStatusCode.InternalServerError, Type = typeof(ErrorResult))]
public async Task<IActionResult> SendTransactionAsync([FromBody] SendTransactionRequest request,
CancellationToken cancellationToken = default(CancellationToken))
{
Expand Down Expand Up @@ -521,9 +521,9 @@ public ReceiptResponse GetReceiptAPI([FromQuery] string txHash)
/// <response code="500">Unable to deserialize method parameters</response>
[Route("local-call")]
[HttpPost]
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
[ProducesResponseType((int)HttpStatusCode.InternalServerError)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(ILocalExecutionResult))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(ErrorResult))]
[ProducesResponseType((int)HttpStatusCode.InternalServerError, Type = typeof(ErrorResult))]
public IActionResult LocalCallSmartContractTransaction([FromBody] LocalCallContractRequest request)
{
if (!this.ModelState.IsValid)
Expand Down
24 changes: 23 additions & 1 deletion src/Stratis.Features.Unity3dApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Models;
using NBitcoin;
using Newtonsoft.Json.Serialization;
using Stratis.Bitcoin;
using Stratis.Bitcoin.Features.Api;
Expand Down Expand Up @@ -128,7 +131,26 @@ public void ConfigureServices(IServiceCollection services)
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();

// Register the Swagger generator. This will use the options we injected just above.
services.AddSwaggerGen();
services.AddSwaggerGen(options => {
options.MapType(typeof(Money), () => new OpenApiSchema
{
Type = "integer",
Example = new OpenApiInteger(9999)
});

options.MapType(typeof(uint160), () => new OpenApiSchema
{
Type = "string",
Example = new OpenApiString("ffffffffffffffffffffffffffffffffffffffff")
});

options.MapType(typeof(uint256), () => new OpenApiSchema
{
Type = "string",
Example = new OpenApiString("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
});
});

services.AddSwaggerGenNewtonsoftSupport(); // Use Newtonsoft JSON serializer with swagger. Needs to be placed after AddSwaggerGen()

// Hack to be able to access and modify the options object
Expand Down