3

I have a generic wrapper for .NET's HttpClient but I'd like to use NSwagStudio's code generator to generate code that calls my generic client rather than the standard HttpClient. I have achieved most of this however there's one part I'm not able to customise: the code for the DTO objects. I know that it's being generated from the File.liquid template here:

{% if GenerateContracts -%}
    {{ Classes | tab }}

I can't see how to modify the code that is generated from Classes

The code that gets generated is:

public partial class ExampleDomainObject 
{
    [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
    public int Id { get; set; }

    [Newtonsoft.Json.JsonProperty("name", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
    public string Name { get; set; }
}

I want to use System.Text.Json instead of Newtonsoft so I either want to remove the Newtonsoft attribute completely or use JsonPropertyName instead.

Can anyone point me to where to make the change?

Dmitry Pavlov
  • 30,789
  • 8
  • 97
  • 121
Mark
  • 2,392
  • 4
  • 21
  • 42

1 Answers1

0

NSwagStudio has a option for Json

NSwagStudio has a option for Json

Juver Paredes
  • 124
  • 1
  • 2