This fixes a bug that has been found using both NSwag and NJsonSchema. Essentially when GenerateNullableReferenceTypes and GenerateOptionalPropertiesAsNullable are both true, these settings are not respected for an optional object property provided via a reference ($ref) and the resulting C# property is not optional.
Hi @RicoSuter , is there anything I can do to get this fix into the repo? It's quite a pain to use a local version of NSwag every time to avoid this bug.
This fixes a bug that has been found using both NSwag and NJsonSchema. Essentially when
GenerateNullableReferenceTypes
andGenerateOptionalPropertiesAsNullable
are both true, these settings are not respected for an optional object property provided via a reference ($ref
) and the resulting C# property is not optional.I believe this may solve multiple issues raised in both NSwag and NJsonSchema repos, for example: https://github.com/RicoSuter/NJsonSchema/issues/1305 https://github.com/RicoSuter/NSwag/issues/4280 (maybe?)
I've added a test that reproduces the problem and passes with the fix.