What's the best way to convey required/optional DTO properties in ServiceStack?

Viewed 4961

I'm having an issue with my ServiceStack w/ Swagger implementation regarding documenting required/optional properties. Developers implementing clients that consume my services love the Swagger documentation, however they don't know which properties are required vs. optional--aside from getting a 400 response on each attempt to get a valid request through.

Take the following example:

public class UserProfile
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public UserAddress Address { get; set; }
}

public class UserAddress
{
    public string AddressLine1 { get; set; }
    public string AddressLine2 { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string Zip { get; set; }
    public string Country { get; set; }
    public string PhoneNumber { get; set; }
}

Swagger will cleanly show both of these types if they are part of my DTO, however I can't convey that FirstName, LastName, or any of the Address properties are required or not. Is there a way to accomplish this without having to roll a separate spec document?

1 Answers
Related