I’ve been using Swagger on Core MVC for a while but now we’re moving over to ServiceStack. I’m currently stuck on trying to document the response type from a POST endpoint while returning a 201 status code.
In Core MVC I could use this attribute:
[ProducesResponseType(typeof(CreateCustomerCommand.Result), 201)]
I closest I have gotten is using this attribute:
[ApiResponse(HttpStatusCode.Created, "Created")]
But I end up with the response model under “default” instead of my 201 response in Swagger.
Is it possible to remove “default” from a service that only returns a NoContent response? I am hoping I am missing some kind of magic sauce to remove it.
ServiceModel
[Route("/Text/Message/Sessionkey/{SessionKey}", "DELETE",
Summary = @"Delete a ZipWhip session key")]
[ApiResponse(HttpStatusCode.NoContent, "No Content")]
[Authenticate, RequiresScopes(Scope.ZipWhipAllow, Scope.FullAccess)]
public class DeleteSessionKey : IDelete
{
public string SessionKey { get; set; }
}
ServiceInterface
public async Task Delete(DeleteSessionKey req)
{
/// ...
return;
}
Is there any way to change “default” to mirror what is actually being returned, HTTP Status Code 200?
If I add an ApiResponse attribute then I end up with this:
ASP.NET Core MVC does this automatically.
Thanks… -Paul