✅ OpenApi generation
I have following class generated from swagger
My issue is that when I create an instance of
RandomSearchDto
like this -> var searchBody = new RandomSearchDto();
, the CreatedAfter
and CreatedBefore
properties have a default value (because they are not nullable).
How can I generate this so that the DateTimeOffsets are generated as nullable
?16 Replies
RandomSearchDto
is sent as a body to a post endpoint. I don't wan't to specify them in this example but the default value gets send obviouslyHi,
There are multiple options
- you could make the property nullable usin a ?
- you could configure the database (read EF to see how). and tell it is nullable
I think you misunderstood something. I am consuming an API. I do not have access to any DB or something. I have a openapi definition that generates a c# client for me
/GenerateOptionalPropertiesAsNullable:true
was the solutionUnknown User•2mo ago
Message Not Public
Sign In & Join Server To View
I can't, right?
it is done via the service reference stuff that uses Newtonsoft.Json
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
@TeBeCo I am using NSwag that only supports Newtonsoft.Json to my knowledge
GitHub
Epic: Support System.Text.Json · Issue #2243 · RicoSuter/NSwag
A: Use System.Text.Json in generated C# models (DTOs): NJsonSchema 90%: RicoSuter/NJsonSchema#1013 NSwag DONE: Use System.Text.Json serializer in ReadObjectResponseAsync (client generator) B: Use S...
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Hmm I'm not sure because I never generated C# models, only TS
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
I dont own the code
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
You can edit the client templates to eliminate newtonsoft
Everything is templated
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Genius!