Skip to content

Controller method in referenced project not mapped #5

@rkreis-v

Description

@rkreis-v

When controller functions are defined in a project reference rather than the target assembly (so they go through ParseXmlFile), doc strings are not added to the OpenApi output. Added this to models project:

public static class ExtraApis
{
    /// <summary>
    /// No doc
    /// </summary>
    /// <param name="app"></param>
    public static void MapExtraApis(this IEndpointRouteBuilder app)
    {
        var extraGroup = app.MapGroup("/api/extra");

        extraGroup.MapGet("/test-xml-doc-comment", TextXmlDocComment);
    }

    /// <summary>
    /// Test endpoint for xml doc comment
    /// </summary>
    /// <returns>A collection of todos for the specified project board.</returns>
    /// <response code="200">Returns the list of todos.</response>
    /// <response code="404">If the project board is not found.</response>
    public static IResult TestXmlDocComment()
    {
        return Results.Ok();
    }
}

It's exported to Models.xml:

<?xml version="1.0"?>
<doc>
    <assembly>
        <name>Models</name>
    </assembly>
    <members>
[...]
        <member name="M:ExtraApis.TestXmlDocComment">
            <summary>
            Test endpoint for xml doc comment
            </summary>
            <returns>A collection of todos for the specified project board.</returns>
            <response code="200">Returns the list of todos.</response>
            <response code="404">If the project board is not found.</response>
        </member>
[...]

OpenApiXmlCommentSupport.generated.cs has this XmlComment entry:

            cache.Add(@"M:ExtraApis.TestXmlDocComment", new XmlComment(@"Test endpoint for xml doc comment", null, null, @"A collection of todos for the specified project board.", null, false, null, null, [new XmlResponseComment(@"200", @"Returns the list of todos.", @""), new XmlResponseComment(@"404", @"If the project board is not found.", @"")]));

But CreateDocumentationId(MethodInfo) returns:

methodInfo.CreateDocumentationId()
"M:ExtraApis.TestXmlDocComment~Microsoft.AspNetCore.Http.IResult"

Including the return type, which doesn't match Models.xml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions