OpenAPI.NET icon indicating copy to clipboard operation
OpenAPI.NET copied to clipboard

Add support for DateOnly and/or DateTime.

Open TeunKooijman opened this issue 3 years ago • 1 comments

With the introduction of DateOnly and TimeOnly in .NET 6.0, it would be beneficial to support these value types in OpenAPI.NET as well. The biggest downside here is of course that you wouldn't be able to publish it under netstandard2.0 (as far as I know).

Just looking to start a conversation as to whether this would be possible.

TeunKooijman avatar Jan 06 '22 15:01 TeunKooijman

We might need to pull all rich typing out of this library in v2 because OpenAPI 3.1 uses native JSON Schema and it is limited to JSON types. We may be able add support for setting a corresponding format property that corresponds to DateOnly and TimeOnly, but you could do that now also.

What is the scenario you are using OpenAPI.NET for?

darrelmiller avatar Jan 23 '22 02:01 darrelmiller

IMHO, DateOnly had already been supported well in Swagger 2.0 and OpenApi 3.0 already, as described on https://swagger.io/docs/specification/data-models/data-types/#string and https://swagger.io/docs/specification/data-models/data-types/

date – full-date notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), for example, 2017-07-21
date-time – the date-time notation as defined by [RFC 3339, section 5.6](https://tools.ietf.org/html/rfc3339#section-5.6), for example, 2017-07-21T17:32:28Z

OpenApiClientGen has supported string/date with DateOnly in C# codes generated.

For example, [C# codes generated] contains a lot DateOnly properties for Medicare Online definition file

Therefore, nothing needs to be done in OpenApi.NET regarding the OP.

zijianhuang avatar Jan 16 '24 12:01 zijianhuang

Closing this issue in favour of JSON schema support in 3.1.

MaggieKimani1 avatar Mar 26 '24 08:03 MaggieKimani1