1

Im using nswag with a angular2 typescript application and would like to return a generic type or 'any' in typescript from the WebAPI:

public async Task<T> GetSomeInput(SomeInput input)
{
        if (input == "Car")
        {
            var result = await _repository.GetAsync<Car>(input);
            return result.MapTo<CarDto>();
        }

         if (input == "Bike")
        {
            var result = await _repository.GetAsync<Bike>(input);
            return result.MapTo<BikeDto>();
        }
   }

So in the angular side i make the cast. Is there a way to do that?

gog
  • 11,788
  • 23
  • 67
  • 129

1 Answers1

-1

If you use the full stack of nswag (swagger and code gen) you can just define the response as object and it should be typed as any in typescript.

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