zijianhuang / webapiclientgen

Strongly Typed Client API Generators generate strongly typed client APIs in C# .NET and in TypeScript for jQuery and Angular 2+ from ASP.NET Web API and .NET Core Web API
MIT License
167 stars 38 forks source link

support JsonPropertyNameAttribute #148

Closed ZijianFLG closed 3 months ago

ZijianFLG commented 3 months ago

https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonpropertynameattribute https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft

ZijianFLG commented 3 months ago

https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/migrate-from-newtonsoft#jsonobjectattribute Newtonsoft.Json has an attribute, JsonObjectAttribute, that can be applied at the type level to control which members are serialized, how null values are handled, and whether all members are required. System.Text.Json has no equivalent attribute that can be applied on a type.

Therefore, DateContractAttribute still shine for cheery picking.

Or, use assembly cheery picking, that is, put those classes that needs to be exposed to client apps into a data model assembly. Good for decoupling / "separation of concerns" / service loading anyway.

ZijianFLG commented 3 months ago

Ready to release: JsonPropertyNameAttribute JsonIgnoreAttribute JsonRequiredAttribute