Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

code documentation, get value from constant

Is it possible, that having a constant

 public const string MyString = "myValue"

to get its value "myValue" in xml comments ? I'm interested in this for generating swagger documentation.

    /// <summary>
    /// Creates a new resource.
    /// </summary>
    /// <param name="request">The request object.</param>
    /// <returns code="200">The id of the new resource.</returns>
    /// <response code="400">
    /// <see cref="Errors.BadRequestCodes.MyString"/><para/>
    /// </response>

This is an example of a documented endpoint. And in the swagger ui, instead of seeing the message "myValue" on the 400 status code section I'm actually seeing "Errors.BadRequestCodes.MyString". Is there any way of achieving this?


1 Answers

Have you tried using <inheritdoc>, and just adding the const value in the first file and then referring to it in the second?

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/inheritdoc

Rendering constants into XML documentation?

like image 62
Joe Avatar answered Jul 04 '26 04:07

Joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!