MicroElements.Swashbuckle.NodaTime
1.0.0-beta.3
Prefix Reserved
This is a prerelease version of MicroElements.Swashbuckle.NodaTime.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package MicroElements.Swashbuckle.NodaTime --version 1.0.0-beta.3
NuGet\Install-Package MicroElements.Swashbuckle.NodaTime -Version 1.0.0-beta.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MicroElements.Swashbuckle.NodaTime" Version="1.0.0-beta.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MicroElements.Swashbuckle.NodaTime --version 1.0.0-beta.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MicroElements.Swashbuckle.NodaTime, 1.0.0-beta.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MicroElements.Swashbuckle.NodaTime as a Cake Addin #addin nuget:?package=MicroElements.Swashbuckle.NodaTime&version=1.0.0-beta.3&prerelease // Install MicroElements.Swashbuckle.NodaTime as a Cake Tool #tool nuget:?package=MicroElements.Swashbuckle.NodaTime&version=1.0.0-beta.3&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MicroElements.Swashbuckle.NodaTime
Allows configure Asp.Net Core and swagger to use NodaTime types.
Latest Builds, Packages
Installation
Package Reference:
dotnet add package microelements.swashbuckle.nodatime
Getting started
- Add package reference to MicroElements.Swashbuckle.NodaTime
- Configure asp net core to use swagger
- Configure JsonSerializer to properly serialize NodaTime types. see
AddJsonFormatters
orAddJsonOptions
- Configure
AddSwaggerGen
withConfigureForNodaTime
Why MicroElements.Swashbuckle.NodaTime is better than others
- Implemented in c#, no FSharp.Core lib in dependencies
- JsonSerializerSettings ContractResolver uses for NamingStrategy, so you can use DefaultNamingStrategy, CamelCaseNamingStrategy or SnakeCaseNamingStrategy
- Added new DateInterval (waiting for new release of NodaTime.Serialization.JsonNet)
Sample
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
void InitJsonSettings(JsonSerializerSettings serializerSettings)
{
// Use DefaultContractResolver or CamelCasePropertyNamesContractResolver;
serializerSettings.ContractResolver = new DefaultContractResolver();
// Configure JsonSerializer to properly serialize NodaTime types.
serializerSettings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
}
// CASE1: AddMvcCore with AddJsonFormatters
services
.AddMvcCore()
.AddApiExplorer()
.AddJsonFormatters(InitJsonSettings)
;
// CASE2: AddMvc with AddJsonOptions
//services
// .AddMvc()
// .AddJsonOptions(options => InitJsonSettings(options.SerializerSettings))
// ;
// Adds swagger
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
// Configures swagger to use NodaTime.
// c.ConfigureForNodaTime();
// Configures swagger to use NodaTime. Use the same InitJsonSettings action that in AddJsonFormatters
c.ConfigureForNodaTime(InitJsonSettings);
// Configures swagger to use NodaTime with serializerSettings.
// c.ConfigureForNodaTime(serializerSettings);
});
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc().UseSwagger();
// Adds swagger UI
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
}
}
How it works
- MicroElements.Swashbuckle.NodaTime creates Schemas for all NodaTime types
- MicroElements.Swashbuckle.NodaTime configures JsonSerializer for examples
- Maps types to ISO 8601
Build
Windows: Run build.ps1
Linux: Run build.sh
License
This project is licensed under the MIT license. See the LICENSE file for more info.
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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- NodaTime (>= 2.0.0)
- NodaTime.Serialization.JsonNet (>= 2.0.0)
- Swashbuckle.AspNetCore (>= 2.4.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on MicroElements.Swashbuckle.NodaTime:
Package | Downloads |
---|---|
EasyDesk.CleanArchitecture.Web
Utilities for the ASP.NET Core web layer of the clean architecture as seen by EasyDesk. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.1 | 771,033 | 1/21/2021 |
4.0.0 | 8,745 | 11/21/2020 |
3.0.0 | 53,771 | 8/29/2020 |
3.0.0-rc.4 | 95,315 | 2/22/2020 |
3.0.0-rc.3 | 390 | 2/5/2020 |
3.0.0-rc.2 | 425 | 2/2/2020 |
3.0.0-rc.1 | 7,723 | 11/14/2019 |
2.0.0 | 11,713 | 3/20/2019 |
1.2.0 | 1,986 | 3/20/2019 |
1.1.0 | 2,131 | 1/10/2019 |
1.0.2 | 2,182 | 9/27/2018 |
1.0.1 | 2,190 | 9/10/2018 |
1.0.0 | 2,335 | 8/12/2018 |
1.0.0-beta.3 | 551 | 8/9/2018 |
1.0.0-beta.2 | 533 | 8/6/2018 |
1.0.0-beta.1 | 518 | 8/3/2018 |
# 1.0.0
- Initial version
Full release notes can be found at: https://github.com/micro-elements/MicroElements.Swashbuckle.NodaTime/blob/master/CHANGELOG.md