Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger UI displaying extra parameter using ServiceStack

I'm having issues with displaying the correct notes in swagger using ServiceStack.

Given this structure:

    [Route("/Widget/{WidgetId}", Summary = "Updates a widget by id", Verbs = "POST",
    Notes = "Updates a widget by id.")]
    public class UpdateReqWidget : IReturnVoid
    {
        [ApiMember(Name = "WidgetId", Description = "The id of widget to delete.")]
        public int WidgetId { get; set; }
    }

    public class WidgetService 
    {
        public void Put(UpdateReqWidget req)
        {
             //do code here
        }
    }

It's producing: Swagger UI Error

I would expect the parameters list only to have WidgetId, but it's displaying WidgetId and UpdageReqWidget, the class name for the request. any ideas what I'm doing wrong?

EDIT: I'm using versions 3.9.55 for both ServiceStack and ServiceStack.API.Swagger. I've changed the templates to better suit our needs.

like image 800
Matthew Doyle Avatar asked Jul 26 '13 04:07

Matthew Doyle


1 Answers

There is a recent addition to ServiceStack.Api.Swagger to automatically generate a request body parameter in the Swagger UI. I think there's an edge case in which the request DTO has no properties that aren't designated as path or query parameters, as in your case here, the code will still generate that UpdateReqWidget request body parameter, but it will be an empty object in Swagger.

like image 128
Mike Mertsock Avatar answered Nov 12 '22 06:11

Mike Mertsock