openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] C# Nullable string with nullable reference types

Open marcselman opened this issue 1 year ago • 1 comments

Bug Report Checklist

  • [ ] Have you provided a full/minimal spec to reproduce the issue?
  • [ ] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] 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

Using the nullableReferenceTypes option for the C# generator does not generate string? types, but just string types.

openapi-generator version

7.1.0

marcselman avatar Dec 08 '23 14:12 marcselman

Looks like it only works when using generichost for the library setting.

marcselman avatar May 24 '24 09:05 marcselman

I just came across this problem too. The nullableReferenceTypes setting works just fine for most reference types, but it does not seem to apply to string which seems odd. I'm currently looking into the code to try to find out if that is on purpose or some sort of oversight. So far, I have come across the patchVendorExtensionNullableValueType and patchVendorExtensionNullableValueTypeLegacy methods in AbstractCSharpCodegen.java which seems at least related to that problem since there is a deliberate switch to the "non-legacy" version in CSharpClientCodegen.patchVendorExtensionNullableValueType if the library is set to generichost.

I really only just started searching though. If anybody knows more about this, I would appreciate some pointers. With the code that is generated right now, I get very inconsistent null handling since all the types have correct nullable annotations except for string which unfortunately makes up a significant part of the API that I am generating.

Angineer48 avatar Oct 29 '24 08:10 Angineer48