Simplify your OpenAPI integration with our .NET 9 NuGet packages! OpenApi.Extensions delivers essential, reusable extensions to streamline and enhance your OpenAPI documentation. OpenApi.NodaTime builds on this foundation, adding seamless support for NodaTime, ensuring accurate and user-friendly representations of time-related data in your APIs. Perfect for developers seeking both flexibility and precision in their API solutions.
var collection = new ServiceCollection();
using var services = collection.BuildServiceProvider();
services.AddOpenApi(opt =>
{
opt.OpenApiVersion = OpenApiSpecVersion.OpenApi3_0;
opt.AddDescription("This project contains samples on the extensions library OpenApi.Extensions.");
opt.ConfigureNodaTime();
opt.AddType<CommandRequestId, string>(new CommandRequestId(Guid.Empty));
});Allows to configure Asp.Net Core and OpenApi to use NodaTime types.
dotnet add package MMonrad.OpenApi.NodaTime
| NodaTime Type | OpenAPI Type | OpenAPI Format | Description | Example |
|---|---|---|---|---|
| Instant | string |
date-time |
Represents an instant in time (UTC) without time zone information. | 2023-12-21T15:30:00Z |
| LocalDateTime | string |
date-time |
A date and time without a time zone. | 2023-12-21T15:30:00 |
| LocalDate | string |
date |
A date without a time component or time zone. | 2023-12-21 |
| LocalTime | string |
time |
A time without a date or time zone. | 15:30:00 |
| OffsetDateTime | string |
date-time |
A date and time with an offset from UTC, but without a specific time zone. | 2023-12-21T15:30:00+01:00 |
| OffsetTime | string |
time |
A time with an offset from UTC, but without a specific date. | 15:30:00+01:00 |
| ZonedDateTime | string |
date-time |
A date and time with a time zone. Often used for scheduling and calendaring. | 2023-12-21T15:30:00+01:00[Europe/London] |
| Period | string |
duration |
An ISO 8601 duration representing an elapsed time. | P1Y2M10DT2H30M |
| Duration | string |
string |
An elapsed time measured in nanoseconds. | 25:01:01.001 |
| Interval | object |
- | Represents a time interval between two Instant values, expressed with start and end. |
{ "start": "2023-12-21T10:00:00Z", "end": "2023-12-21T15:30:00Z" } |
| DateInterval | object |
- | A date interval between two LocalDate values, expressed with start and end. |
{ "start": "2023-12-20", "end": "2023-12-25" } |
If you want to contribute to the project and make it better, your help is very welcome.
- Create a personal fork of the project on Github.
- Create a new branch to work on! Branch from
main. - Implement/fix your feature, comment your code.
- Follow the code style of the project, including indentation.
- Add or change the documentation as needed.
- From your fork open a pull request in the correct branch. Target the project's
mainbranch.