Swagger interface showing optional parameter using ServiceStack

I'm having trouble 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 produces: Swagger ui error

I would expect that only WidgetId will be in the parameter list, but it displays WidgetId and UpdageReqWidget, the class name for the request. Any ideas what I am doing wrong?

EDIT: I am using version 3.9.55 for ServiceStack and ServiceStack.API.Swagger. I changed the templates to better suit our needs.

+7
servicestack swagger
source share
1 answer

There is a recent addition to ServiceStack.Api.Swagger to automatically generate a request body parameter in the Swagger user interface. I think that there is an extreme case when a DTO request does not have properties that are not designated as parameters of the path or request, as in your case here the code will still generate this parameter of the UpdateReqWidget body, but it will be an empty object in Swagger.

+6
source share

All Articles