Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify Response class and return Status Codes using Swagger/ServiceStack

Is it possible with ServiceStack.Api.Swagger v3.9.33 to describe the response of an API operation and the returned status codes using Swagger? Perhaps by attribute decoration on the Response class/properties, etc.

Like the highlighted sections for the following example operation from the pet store API: (http://petstore.swagger.wordnik.com/)

enter image description here

I can only see the HTTP methods and Request DTOS can be decorated on https://github.com/ServiceStack/ServiceStack/wiki/Swagger-API and quick glance at code looks like may not yet be supported, https://github.com/ServiceStack/ServiceStack/tree/master/src/ServiceStack.Api.Swagger

like image 369
Luke Hutton Avatar asked Jan 24 '13 19:01

Luke Hutton


1 Answers

As of now, it's possible if you pull the head of the ServiceStack repo. I just got a pull request merged that adds the option to decorate your request DTOs with an [ApiResponse] attribute. See here for details:

https://github.com/ServiceStack/ServiceStack/issues/590#issuecomment-17575292

like image 151
Mark S. Rasmussen Avatar answered Oct 16 '22 04:10

Mark S. Rasmussen