domaindrivendev / Swashbuckle.AspNetCore

Swagger tools for documenting API's built on ASP.NET Core
MIT License
5.25k stars 1.31k forks source link

Propertiy names set by JsonPropertyAttributes are ignored whenever its class is used with [FromBody] Post Method #1467

Closed tvperez76 closed 4 years ago

tvperez76 commented 4 years ago

Propertiy names set by JsonPropertyAttributes are ignored whenever its class is used with [FromBody] Post Method. This only appears to happen with v5.0.0-rc5 version of Swashbuckle.AspNetCore library. All others appear to be working well.

Version v.5.0.0-rc5:

Swashbuckle AspNetCore v5 0 0-rc5

Version v.5.0.0-rc4:

Swashbuckle AspNetCore v5 0 0-rc4
domaindrivendev commented 4 years ago

JsonProperty is a Newtonsoft attribute which leads me to believe you're still using the Newtonsoft serializer as opposed to the new serializer System.Text.Json that ships with ASP.NET Core 3.0. If this is the case, you'll need to install a separate Swashbuckle package and explicitly opt-in to honor the Newtonsoft attributes. See https://github.com/domaindrivendev/Swashbuckle.AspNetCore#systemtextjson-stj-vs-newtonsoft

tvperez76 commented 4 years ago

That's correct. However, I am not using ASP.NET Core 3.0, so that's not really an option. So, are we to conclude that v.5.0.0 will not support ASP.NET Core 2.2 or earlier? Or, that we need to specifically invoke the AddSwaggerGenNewtonsoftSupport() method, regardless of the ASP.NET Core version we're using?

domaindrivendev commented 4 years ago

Yes you need to invoke it regardless

tvperez76 commented 4 years ago

Thank you for the information. I recommend that this be explicitly stated in the documentation, as to remove any ambiguity as to the applicability of the AddSwaggerGenNewtonsoftSupport() method in non-ASP.NET Core 3.0 hosts.