I had a problem implementing Swagger in ServiceStack regarding documentation of typed response objects. Strongly typed response objects are correctly documented and displayed, however, as soon as a typically typed object is used as an answer, the documentation is inaccurate and misleading.
DTO Request
[Route("/users/{UserId}", "GET", Summary = "Get a specific User Profile")] public class GetUser : IReturn<ServiceResponse<UserProfile>> { [ApiMember(Description = "User Id", ParameterType = "path", IsRequired = true)] public int UserId { get; set; } }
DTO answer
public class ServiceResponse<T> : IServiceResponse<T> { public IList<string> Errors { get; set; } public bool Successful { get; set; } public string Message { get; set; } public string StackTrace { get; set; } public T Data { get; set; } public ServiceResponse() { Errors = new List<string>(); } }
DTO response type
public class UserProfile : RavenDocument { public UserProfile() { Races = new List<UserRace>(); Workouts = new List<Workout>(); } public string FirstName { get; set; } public string LastName { get; set; } public string DisplayName { get; set; } public DateTime? BirthDate { get; set; } public Gender? Gender { get; set; } public string UltracartPassword { get; set; } public string UltracartCartId { get; set; } [UniqueConstraint] public string Email { get; set; } public string ImageUrl { get; set; } public FacebookUserInfo FacebookData { get; set; } public GoogleUserInfo GoogleData { get; set; } public DateTime CreatedOn { get; set; } public DateTime? LastUpdated { get; set; } public UserAddress ShippingAddress { get; set; } public UserAddress BillingAddress { get; set; } public IList<UserRace> Races { get; set; } public IList<Workout> Workouts { get; set; } }
The examples are pretty straightforward. Nothing serious or hacked, but this is a sample of the documentation I get from Swagger out of the box:

As you can see, the generic type is not documented correctly, but a different type is used instead. Since I use this same ServiceResponse wrapper for all my answers, this happens in all directions.
source share