Posts

Showing posts from December, 2020

How to Process the Result Returned by NSwagStudio Generated c# Client

Context: OpenAPI v2 endpoints implemented using Swagger C# client generated using NSwagStudio. Using .NET dll framework Basically, we'll need to cast the result to JArray and then cast it to the desired object type. var result = (JArray) bookingClient.GetV1BookingSearchByDateRangeAsync(SearchStartDate, SearchEndDate, 10, 1, "", null).Result; var bookings = result.ToObject<List<BookingViewModel>>(); Please take note that the above only needed if there's no response type declared. For those endpoints with the response type declared, the generated response will not be in JArray. For example, the same code above can be done with the below code which the result is in type IList<BookingViewModel> var result = bookingClient.GetV1BookingSearchByDateRangeAsync(SearchStartDate, SearchEndDate, 10, 1, "", null).Result; Yea, Softinn is developing our API endpoints. This will open up more opportunities moving forward. IF you're a developer and keep t