Skip to content

[BUG] [csharp][generichost] Wrong DateOnly parsing leads to excpetion during JSON deserialization with DateOnlyJsonConverter #22089

@McMlok

Description

@McMlok

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • 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

Schema

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;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions