in src/Microsoft.Health.Dicom.Api/Features/Swagger/ErrorCodeOperationFilter.cs [15:44]
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
EnsureArg.IsNotNull(operation, nameof(operation));
EnsureArg.IsNotNull(context, nameof(context));
foreach (ApiResponseType responseType in context.ApiDescription.SupportedResponseTypes)
{
if (responseType.StatusCode == 400 || responseType.StatusCode == 404 || responseType.StatusCode == 406 || responseType.StatusCode == 415)
{
string responseKey = responseType.IsDefaultResponse ? "default" : responseType.StatusCode.ToString();
OpenApiResponse response = operation.Responses[responseKey];
foreach (string contentType in response.Content.Keys)
{
if (response.Content.Count == 1)
{
OpenApiMediaType value = response.Content[contentType];
response.Content.Remove(contentType);
response.Content.Add("application/json", value);
break;
}
response.Content.Remove(contentType);
}
operation.Responses[responseKey] = response;
}
}
}