4

Is there a way to change the settings in NSwagStudio so that when the JSON serialization setting outputs as Newtonsoft.Json.Required.AllowNull instead of Newtonsoft.Json.Required.Always?

I currently have the property manually changed to allow for nulls.

[Newtonsoft.Json.JsonProperty("returnCode", Required = Newtonsoft.Json.Required.Always)]
public int ReturnCode { get; set; }

And I need it to be:

[Newtonsoft.Json.JsonProperty("returnCode", Required = Newtonsoft.Json.Required.AllowNull)]
public int ReturnCode { get; set; }
Ryan Lundy
  • 204,559
  • 37
  • 180
  • 211

1 Answers1

2

It will not be nullable inside the generated code if it is not nullable at the API-spec

API spec example:

    ReturnCode:
      type: integer
      nullable: true
Dennis Meissel
  • 1,825
  • 1
  • 21
  • 33