Open
Description
Description
Hi there, thanks for this awesome library.
I have a ASP.NET core API that uses the DateOnly
type for a field, which looks like this in the generated OpenAPI doc:
"ReleaseDate": {
"type": "string",
"format": "date"
}
From the docs of the OpenAPI spec, "format": "date"
indicates:
full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21
But the OpenAPI provider sets the field type as DateTimeOffset
in the generated spec. This only works when parsing responses, but fails when posting data with this field to the API, because it cannot parse the provided string to DateOnly
:
RequestBody: {"ReleaseDate":"2024-02-22T14:30:01.8849759+01:00"}
Microsoft.AspNetCore.Http.BadHttpRequestException: Failed to read parameter "d" from the request body as JSON.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.DateOnly. Path: $.ReleaseDate | LineNumber: 0 | BytePositionInLine: 154.
Is this happening because you also want to target netstandard2.0
? IIRC DateOnly
is available starting with net6.0
.
Affected Type Providers
- SwaggerClientProvider
- OpenApiClientProvider (only used this one as my schema is OpenAPI v3.0)
Related information
- Operating system: Win 11
- .NET Runtime, CoreCLR or Mono Version: .NET 8
Metadata
Metadata
Assignees
Labels
No labels