In the petstore example from wordnik they have provided documentation for their response classes. An example can be seen on the /pet/{petId} endpoint:
Pet {
name (string, optional),
id (integer, optional): foo,
category (Category, optional),
photoUrls (array[string], optional),
tags (array[Tag], optional),
status (string, optional) = ['available' or 'pending' or 'sold']: pet status in the store
}
It looks like it supports the following parameters:
Is there a way to accomplish this with the ServiceStack implementation?
Here's what the ServiceStack Swagger implementation currently supports, as of version 3.9.59:
ApiMemberAttribute
string
property with a predefined set of values), annotate the property with the ApiAllowableValues
attributeSystem.ComponentModel.Description
attributeMake sure your request DTO implements the IReturn<ResponseDtoType>
interface.
The following is probably the closest approximation to the Petstore example I can think of, given the current ServiceStack Swagger implementation:
public class Pet
{
public string Name { get; set; }
[Description("foo")]
public int? Id { get; set; }
public Category Category { get; set; }
public List<string> PhotoUrls { get; set; }
public List<Tag> Tags { get; set; }
// If "Status" is implemented internally as a string
[Description("pet status in the store")]
[ApiAllowableValues("Status", "available", "pending", "sold")]
public string Status1 { get; set; }
// If you can implement "Status" as an enum, the allowable values
// are instead automatically documented:
[Description("pet status in the store")]
public Statuses Status2 { get; set; }
public enum Statuses { available, pending, sold }
}
The only property in that DTO that will get marked as optional is Id
.