openapi-generator
openapi-generator copied to clipboard
[BUG] [csharp][generichost] Wrong DateOnly parsing leads to excpetion during JSON deserialization with DateOnlyJsonConverter
Bug Report Checklist
- [X] Have you provided a full/minimal spec to reproduce the issue?
- [X] Have you validated the input using an OpenAPI validator?
- [X] Have you tested with the latest master to confirm the issue still exists?
- [X] Have you searched for related issues/PRs?
- [X] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
There is an issue with deserializing DateOnly properties with generated DateOnlyJsonConverter deserialization fail with
System.NotSupportedException: Specified method is not supported. at DateOnlyJsonConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
openapi-generator version
7.16.0
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
- Use schema above
- generate client
- Try to deserialize json
{"id":1,"created":"2025-10-07"}
Related issues/PRs
Suggest a fix
If you want to parse DateOnly type you cannot provide settings for Time with DateTimeStyles enum.
TryParse should be like this
if (DateOnly.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateOnly result)) return result;