I'm using latest version of Swashbuckle.
If I use SwaggerResponse it works fine but not with XML Comments.
This is my API:
/// <summary>
/// Gets activity logs.
/// </summary>
/// <param name="locationId">Location id.</param>
/// <param name="filter">Activity log filter options.</param>
[ResponseType(typeof(ActivityLogResponse))]
public async Task<HttpResponseMessage> FetchActivityLogs(int locationId, ActivityLogFilterOptions filter)
{
try
{
var response = await _activityLogLogic.GetActivityLogs(CHIdentity.User, locationId, filter);
return Request.CreateResponse(HttpStatusCode.OK, response);
}
catch (HttpRequestException ex)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message + "\n" + ex.InnerException.Message);
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
}
}
IOperationFilter Class:
public class MultipleOperationsWithSameVerbFilter : IOperationFilter
{
public void Apply(
Operation operation,
SchemaRegistry schemaRegistry,
ApiDescription apiDescription)
{
// List<string> lst = new List<string>();
if (operation.parameters != null)
{
operation.operationId += "By";
foreach (var parm in operation.parameters)
{
operation.operationId += string.Format("{0}-{1}", parm.name, Guid.NewGuid());//Some of the api are creating same operation Id. we have append param name and Guid of URI to avoid to create duplicatate operation ID
}
}
}
}
Defination of ActivityLogResponse class:
public class ActivityLogResponse
{
public List<ActivityLogMessage> ActivityLogs { get; set; }
Logs { get; set; }
}
In swagger JSON responses "type": "object" is coming instead of ActivityLogFilterOptions
See Responses in following Swagger Json:
"/api/locations/{locationId}/FetchActivityLogs": {
"post": {
"tags": ["ActivityLog"],
"summary": "Gets activity logs.",
"operationId": "ActivityLog_FetchActivityLogs",
"consumes": ["application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded"],
"produces": ["application/json", "text/json", "application/xml", "text/xml"],
"parameters": [{
"name": "locationId",
"in": "path",
"description": "Location id.",
"required": true,
"type": "integer",
"format": "int32"
}, {
"name": "filter",
"in": "body",
"description": "Activity log filter options.",
"required": true,
"schema": {
"$ref": "#/definitions/ActivityLogFilterOptions"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object"
}
}
}
}
},

How to load ActivityLogFilterOptions here instead of {}?
I got the same issue that the repsonse shows up as an empty object with the XML comments below.
/// <summary>
aaaabbbbbbb
/// </summary>
/// <param name="purchaseRequest">The transaction request.</param>
/// <returns><see cref="TransactionResult"/></returns>
/// <response code="201" cref="TransactionResult">The purchase was successfully created</response>
/// <response code="400" > Invalid data was passed in the request body. The response body details the invalid fields</response>
/// <response code="500" > The server encountered an error</response>
/// <response code="401" > The OAuth2 token is invalid or expired</response>
/// <response code="403" > The caller does not have authorization for the operation requested</response>
@Thomasg-76
Decorate each API with following attribute:
[SwaggerResponse(HttpStatusCode.OK, Type = typeof(apiojecttypetoreturn))]
Most helpful comment
@Thomasg-76
Decorate each API with following attribute:
[SwaggerResponse(HttpStatusCode.OK, Type = typeof(apiojecttypetoreturn))]