swagger-codegen
swagger-codegen copied to clipboard
[CSHARP] Add FromJson method to generated models
Description
I'm working on a project where we use codegen to only generate the models. It be really useful to have a method that deserializes a JSON string into an object similar to the ToJson method that serializes the object into a JSON string.
Swagger-codegen version
master branch
Swagger declaration file content or url
N/A
Command line used for generation
N/A
Steps to reproduce
N/A
Related issues/PRs
I will create a PR now.
Suggest a fix/enhancement
Add a FromJson method to modelGeneric.mustache
Example from MyClassWithInvalidRequiredEnumUsageOnRef integration test,
public static MyClassWithInvalidRequiredEnumUsageOnRef FromJson(string json)
{
return JsonConvert.DeserializeObject<MyClassWithInvalidRequiredEnumUsageOnRef>(json);
}