essencebit / SignalRSwaggerGen

MIT License
70 stars 8 forks source link

XML docs missing from auto discovery #14

Closed saver-r closed 2 years ago

saver-r commented 2 years ago

Applying SignalRSwaggerGen on the following example

/// <summary>Signal/R Hub</summary>
[SignalRHub(autoDiscover: AutoDiscover.MethodsAndArgs)]
public class SomeHub : Hub
{
    /// <summary>
    /// Open session.
    /// </summary>
    /// <param arg="temp">true if temporary session.</param>
    /// <returns>Session ID</returns>
    public async Task OpenSession(bool temp)
    {
        // ...
    }
}

does yield proper hubs/SomeHub/OpenSession entry, however, it's missing all XML-Doc. I naively expected auto discovery to make use of XML descriptions. If I explicitly annotate the method

    /// <summary>
    /// Open session.
    /// </summary>
    /// <param arg="temp">true if temporary session.</param>
    /// <returns>Session ID</returns>
    [SignalRMethod(name: "OpenSession")]
    public async Task OpenSession(bool temp)

comments still won't show up in generated OpenAPI docs.

Only if I use explicit annotation arguments

    /// <summary>
    /// Open session.
    /// </summary>
    /// <param arg="temp">true if temporary session.</param>
    /// <returns>Session ID</returns>
    [SignalRMethod(name: "OpenSession", summary: "bla", description: "more bla")]
    public async Task OpenSession(bool temp)

SignalRSwaggerGen will display summary and description, but not the one from the XML.

I added all relevant XML-documentation files to Swagger generator with

opts.IncludeXmlComments(xmlFile)

and it works with REST-API, so it's not a configuration error.

Is XML-API-doc supported? If yes, how do I enable it? If not, do you plan to support it in the future?

Dorin-Mocan commented 2 years ago

@saver-r , at the moment XML doc is not supported. I can investigate this feature and come back to you with an answer if I'm going to add the support for comments or not. Stay tuned 😜 And thanks for raising an issues 🙏

Dorin-Mocan commented 2 years ago

@saver-r , I'll try add support for xml comments this week,

Dorin-Mocan commented 2 years ago

@saver-r , just to let you know, I'm working on a new release

Dorin-Mocan commented 2 years ago

@saver-r m I just released a preview version. If no issues will be reported, will publish the newest release.

Dorin-Mocan commented 2 years ago

@saver-r , the newest release has support for xml comments. Check out and please close the thread if all good. Thank you!

saver-r commented 2 years ago

Excellent, thank you very much! I tried SignalRSwaggerGen 3.0.0, removed from my hub all [SignalRMethod] annotations and replaced them by respective XML comments. I left [SignalRHub] in place on top of Hub class.

Then I replaced

opts.DocumentFilter<SignalRSwaggerGen.SignalRSwaggerGen>(new List<Assembly> { typeof(Hubs.SomeHub).Assembly });

with

opts.AddSignalRSwaggerGen();

I also moved the last invocation to the end of the Swashbuckle options, but, unfortunately, no XML comments are displayed.

saver-r commented 2 years ago

[SignalRHub(autoDiscover: AutoDiscover.MethodsAndParams)] also does not help :-(

Dorin-Mocan commented 2 years ago

@saver-r , you need to enable XML comments in the option of AddSignalRSwaggerGen()

Dorin-Mocan commented 2 years ago

Add the path to XML comments file

saver-r commented 2 years ago

This made it work!

opts.AddSignalRSwaggerGen(o => o.UseXmlComments(xmlFiles.ToArray()));

Thank you very much!