api plus description
This commit is contained in:
parent
d38f6da26f
commit
44dfa39737
|
@ -0,0 +1,18 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace MarketInsights.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class MarketController : ControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the most recent market overview.
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public MarketOverview Get()
|
||||
{
|
||||
return new MarketOverview();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace MarketInsights.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetWeatherForecast")]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
@ -7,6 +7,8 @@
|
|||
<UserSecretsId>ae71e621-bb16-41b2-b6f3-c597d2d21157</UserSecretsId>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
namespace MarketInsights
|
||||
{
|
||||
public class MarketOverview
|
||||
{
|
||||
public MarketTimeSegment[] TimeSegments { get; set; } = Array.Empty<MarketTimeSegment>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Segment of time over which market statistics are available.
|
||||
/// </summary>
|
||||
public class MarketTimeSegment
|
||||
{
|
||||
/// <summary>
|
||||
/// Start of time segment.
|
||||
/// </summary>
|
||||
public DateTime FromUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// End of time segment.
|
||||
/// </summary>
|
||||
public DateTime ToUtc { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Averages over contracts that were submitted during this time segment.
|
||||
/// </summary>
|
||||
public ContractAverages Submitted { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Averages over contracts that expired during this time segment.
|
||||
/// </summary>
|
||||
public ContractAverages Expired { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Averages over contracts that started during this time segment.
|
||||
/// </summary>
|
||||
public ContractAverages Started { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Averages over contracts that finished (succesfully) during this time segment.
|
||||
/// </summary>
|
||||
public ContractAverages Finished { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Averages over contracts that failed during this time segment.
|
||||
/// </summary>
|
||||
public ContractAverages Failed { get; set; } = new();
|
||||
}
|
||||
|
||||
public class ContractAverages
|
||||
{
|
||||
/// <summary>
|
||||
/// Number of contracts.
|
||||
/// </summary>
|
||||
public int Number { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Average price of contracts. (TSTWEI)
|
||||
/// </summary>
|
||||
public float Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Average size of slots in contracts. (bytes)
|
||||
/// </summary>
|
||||
public float Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Average duration of contracts. (seconds)
|
||||
/// </summary>
|
||||
public float Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Average collateral of contracts. (TSTWEI)
|
||||
/// </summary>
|
||||
public float Collateral { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Average proof probability of contracts.
|
||||
/// </summary>
|
||||
public float ProofProbability { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Reflection;
|
||||
|
||||
namespace MarketInsights
|
||||
{
|
||||
public class Program
|
||||
|
@ -12,7 +15,11 @@ namespace MarketInsights
|
|||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddSwaggerGen(s =>
|
||||
{
|
||||
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
s.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
namespace MarketInsights
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue