Skip to content

Commit

Permalink
Merge pull request #332 from osc-nseguin/tweakXmlDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
christianhelle authored Mar 6, 2024
2 parents 6d615f5 + 0cac175 commit 923a38e
Show file tree
Hide file tree
Showing 8 changed files with 1,227 additions and 323 deletions.
30 changes: 26 additions & 4 deletions src/Refitter.Core/XmlDocumentationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void AppendMethodDocumentation(CSharpOperationModel method, bool hasApiRe
}

this.AppendXmlCommentBlock(
"throws",
"exception",
this.BuildErrorDescription(method.Responses),
code,
new Dictionary<string, string> { ["cref"] = "ApiException" });
Expand Down Expand Up @@ -177,17 +177,39 @@ private string BuildResponseDescription(string text, IEnumerable<CSharpResponseM
{
var description = new StringBuilder(text);
var responseList = responses.ToList();

if (!this._settings.GenerateStatusCodeComments || !responseList.Any())
return description.Append(".").ToString();

description.Append(":");
description.AppendLine(":")
.AppendLine("<list type=\"table\">")
.AppendLine("<listheader>")
.AppendLine("<term>Status</term>")
.AppendLine("<description>Description</description>")
.AppendLine("</listheader>");

foreach (var response in responseList)
{
description.AppendLine().Append(response.StatusCode);
description
.AppendLine("<item>")
.Append("<term>")
.Append(response.StatusCode)
.AppendLine("</term>");

if (!string.IsNullOrWhiteSpace(response.ExceptionDescription))
description.Append(": ").Append(response.ExceptionDescription);
{
description
.Append("<description>")
.Append(response.ExceptionDescription)
.AppendLine("</description>");
}

description.AppendLine("</item>");
}

description
.Append("</list>");

return description.ToString();
}
}
Loading

0 comments on commit 923a38e

Please sign in to comment.