Open bgraham1962 opened 4 years ago
I think that you can decorate your method with
[return: CanBeNull]
and that it would generate the nullable:true in the OpenApi definition that would then be understood by the client generator.
If you can use C#9, it would be easier to annotate your controller with nullable reference types
Thanks for the reply Jérémy,
I cannot find that attribute within the normal C# attributes. Is it a JetBrains one?
Cheers
Brian
From: Jérémy VIGNELLES notifications@github.com Sent: Friday, 14 August 2020 5:17 pm To: RicoSuter/NSwag NSwag@noreply.github.com Cc: Brian Graham brian.graham@slingshot.co.nz; Author author@noreply.github.com Subject: Re: [RicoSuter/NSwag] A SwaggerException is generated in the C# client when upgrading from 13.6.2 to 13.7.0 (#3005)
I think that you can decorate your method with [return: CanBeNull] and that it would generate the nullable:true in the OpenApi definition that would then be understood by the client generator.
If you can use C#9, it would be easier to annotate your controller with nullable reference types
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RicoSuter/NSwag/issues/3005#issuecomment-673888760 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMOMP2XDVLPX3RIPE52553SATCELANCNFSM4P63FZPA . https://github.com/notifications/beacon/ABMOMPYPKTQLXE2GLLVWFK3SATCELA5CNFSM4P63FZPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFAVLT6A.gif
It could be the one from jetbrains, but IIRC, any attribute with that name (including attibute you declare in your project) would work by convention.
Could also be the one from the NJsonSchema NuGet package : https://github.com/RicoSuter/NJsonSchema/blob/958afa39a8386a6f02bf6604aca742e4d18acb61/src/NJsonSchema/Annotations/CanBeNullAttribute.cs
Thanks Jérémy
I will check them out.
Regards Brian
From: Jérémy VIGNELLES notifications@github.com Sent: Monday, 17 August 2020 8:15 am To: RicoSuter/NSwag NSwag@noreply.github.com Cc: Brian Graham brian.graham@slingshot.co.nz; Author author@noreply.github.com Subject: Re: [RicoSuter/NSwag] A SwaggerException is generated in the C# client when upgrading from 13.6.2 to 13.7.0 (#3005)
Could also be the one from the NJsonSchema NuGet package : https://github.com/RicoSuter/NJsonSchema/blob/958afa39a8386a6f02bf6604aca742e4d18acb61/src/NJsonSchema/Annotations/CanBeNullAttribute.cs
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/RicoSuter/NSwag/issues/3005#issuecomment-674572424, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABMOMP3AARO4PEXEC6HJX7TSBA43VANCNFSM4P63FZPA.
For a number of our API endpoints we return 200 null if that is the most sensible result. For example:
Since the upgrade to 13.7 the generated C# client now throws an error in this situation.
How do we annotate the method to tell it that File (in this case) is a nullable return type?
Regards Brian