0

I have a CMD script that uses "nswag swagger2csclient" to generate a client for communicating with another API. It has worked before but once it used a newer version of Nswag things started going wrong.

The code looks like this:

// Controller method
[ProducesResponseType(typeof(IEnumerable<CarViewModel>), 200)]
public async Task<ObjectResult> GetCars()

//Generated result with an older version of Nswag
System.Threading.Tasks.Task<System.Collections.ObjectModel.ObservableCollection<CarViewModel>> GetCars();

//Generated result with an newer version of Nswag
System.Threading.Tasks.Task<System.Collections.Generic.ICollection<CarViewModel>> GetCars();

The use of Generic.ICollection is incompatible with my own code and it would be tedious work to change all data types so I need Nswag to generate ObjectModel.ObservableCollection like it did in the older version.

How do I make this work?

1 Answers1

0

You can change this default with the /ArrayType:Collection param

See https://github.com/RicoSuter/NJsonSchema/wiki/CSharpGeneratorSettings

Rico Suter
  • 11,548
  • 6
  • 67
  • 93