api - Document response classes with Swagger and ServiceStack -


in petstore example wordnik have provided documentation response classes. example can seen on /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 store } 

it looks supports following parameters:

  • optional (flag specifies if property in response)
  • allowed values
  • description

is there way accomplish servicestack implementation?

here's servicestack swagger implementation supports, of version 3.9.59:

  • optional: nullable value types described optional. other that, there no support explicitly defining properties in request/response body optional. path or query string parameters, can control optionality using apimemberattribute
  • allowed values: enum types automatically list of allowed values. other types (e.g. string property predefined set of values), annotate property apiallowablevalues attribute
  • description: use system.componentmodel.description attribute

make sure request dto implements ireturn<responsedtotype> interface.

the following closest approximation petstore example can think of, given 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" implemented internally string     [description("pet status in store")]     [apiallowablevalues("status", "available", "pending", "sold")]     public string status1 { get; set; }      // if can implement "status" enum, allowable values     // instead automatically documented:     [description("pet status in store")]     public statuses status2 { get; set; }      public enum statuses { available, pending, sold } } 

the property in dto marked optional id.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -