Quack.Api
1.3.7
See the version list below for details.
dotnet add package Quack.Api --version 1.3.7
NuGet\Install-Package Quack.Api -Version 1.3.7
<PackageReference Include="Quack.Api" Version="1.3.7" />
paket add Quack.Api --version 1.3.7
#r "nuget: Quack.Api, 1.3.7"
// Install Quack.Api as a Cake Addin
#addin nuget:?package=Quack.Api&version=1.3.7
// Install Quack.Api as a Cake Tool
#tool nuget:?package=Quack.Api&version=1.3.7
Quack API
Using the both Shadow Quack base library and Shadow Quack JSON this package includes custom implementation of JsonConverter
and JsonConvertorFactory
, that wrap the JSON proxy, to allow the use of Interfaces as return and parameter types in ASP .Net API calls.
by adding the QuackInterfaceConverterFactory
to the Converters list,
services.AddControllers().AddJsonOptions(opts =>
{
opts.JsonSerializerOptions.Converters.Add(new QuackInterfaceConverterFactory());
});
You can use interfaces as the inputs and outputs to your API calls without needing to do anything else!
WeatherForecastController.cs
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Shadow.Quack;
namespace Example.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]
public IEnumerable<IWeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => Duck.Implement<IWeatherForecast>(new
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
}))
.ToArray();
}
}
}
IWeatherForecast.cs
using System;
namespace Example
{
public interface IWeatherForecast
{
DateTime Date { get; }
int TemperatureC { get; }
int TemperatureF { get; }
string Summary { get; }
}
}
The above shows using this with the Weather Forecast example API, note the Get() method now has only abstract interface types in the declaration; public IEnumerable<IWeatherForecast> Get()
and the creation of the return value is done using Duck.Implement<T>(object source)
.
Interfaces can be used as the types for API inputs too, for example
[HttpPost]
public bool Post(IPostData data)
{
return Process(data);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
-
.NETCoreApp 3.1
- Shadow.Quack.Json (>= 1.4.5)
-
.NETFramework 4.6.1
- Shadow.Quack.Json (>= 1.4.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.4.1 | 1,703 | 4/5/2022 |
1.4.0 | 418 | 1/30/2022 |
1.3.7 | 396 | 1/30/2022 |
1.3.6 | 422 | 1/20/2022 |
1.3.5 | 289 | 12/5/2021 |
1.3.4 | 427 | 9/11/2021 |
1.3.3 | 342 | 9/10/2021 |
1.3.2 | 345 | 6/18/2021 |
1.3.1 | 361 | 5/27/2021 |
1.3.0 | 326 | 5/24/2021 |
1.2.2 | 293 | 4/23/2021 |
1.2.1 | 342 | 4/17/2021 |
1.2.0 | 364 | 4/17/2021 |
1.1.0 | 290 | 4/14/2021 |
1.0.0 | 319 | 4/9/2021 |
Updated dependencies