Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Extract cref primitive/enum values and place them into descriptions #69

Open
@scott-lin

Description

@scott-lin

Take for example the following code and comments.

public enum DayOfWeek
{
    Monday,
    Tuesday,
    ...
    Sunday
}

public class FooController : Controller
{
    public const string DefaultValue = "Default";
    public const int DefaultValue2 = 10;

    /// <param name="stringCriteria" required="false" cref="string" in="query">
    /// Optional string criteria of resource to query. Default is <see cref="DefaultValue"/>.
    /// </param>
    /// <param name="dayOfWeek" required="false" cref="DayOfWeek" in="query">
    /// Optional day of week of resource to query. Default is <see cref="DayOfWeek.Tuesday"/>.
    /// </param>
    /// <param name="numberCriteria" required="false" cref="int" in="query">
    /// Optional number criteria of resource to query. Default is <see cref="DefaultValue2"/>.
    /// </param>
    public void Get(
        string stringCriteria = DefaultValue,
        DayOfWeek dayOfWeek = DayOfWeek.Tuesday,
        int numberCriteria = DefaultValue2 )
    {
        ...
    }
}

I would love to see the descriptions in the resulting OpenAPI document to be:

Optional string criteria of resource to query. Default is 'Default'.
Optional day of week of resource to query. Default is 'Tuesday'.
Optional number criteria of resource to query. Default is '10'.

Today, the descriptions are filled with the literal cref text, so for the examples above, they would be something like:

Optional string criteria of resource to query. Default is 'DefaultValue'.
Optional day of week of resource to query. Default is 'DayOfWeek.Tuesday'.
Optional number criteria of resource to query. Default is 'DefaultValue2'.

Naturally, we cannot do this convenience for complex referenced types, but for simple types like primitives and enums, we should be able to. It would keep documentation in sync with the code values, which is a plus for readers of the OpenAPI documents since they don't have to refer back to code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions