How to get the methods exposed in the webAPI project?

How can I programmatically get a list of public w / parameters methods that appear in my webAPI project? I need to provide this list to our QA department. I do not want to make and maintain a list myself. I want to provide a link to QA to find the methods myself. I need something like what you get when you view the .asmx file.

+4
source share
3 answers

ASP.NET web interface allows you to create a help page automatically. This page will help document all the endpoints provided by your API. Please refer to this blog post: Creating Help Pages for ASP.NET Web APIs .

You can, of course, create fully customizable documentation using the interface IApiExplorer.

+5
source

You can try something like this:

public static void Main() 
    {
        Type myType =(typeof(MyTypeClass));
        // Get the public methods.
        MethodInfo[] myArrayMethodInfo = myType.GetMethods(BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly);
        Console.WriteLine("\nThe number of public methods is {0}.", myArrayMethodInfo.Length);
        // Display all the methods.
        DisplayMethodInfo(myArrayMethodInfo);
        // Get the nonpublic methods.
        MethodInfo[] myArrayMethodInfo1 = myType.GetMethods(BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.DeclaredOnly);
        Console.WriteLine("\nThe number of protected methods is {0}.", myArrayMethodInfo1.Length);
        // Display information for all methods.
        DisplayMethodInfo(myArrayMethodInfo1);      
    }
    public static void DisplayMethodInfo(MethodInfo[] myArrayMethodInfo)
    {
        // Display information for all methods. 
        for(int i=0;i<myArrayMethodInfo.Length;i++)
        {
            MethodInfo myMethodInfo = (MethodInfo)myArrayMethodInfo[i];
            Console.WriteLine("\nThe name of the method is {0}.", myMethodInfo.Name);
        }
    }

I got it from here

0
source

, :

Web API WSDL SOAP. WCF REST, WCF/WSDL SOAP, REST.

: -API ASP.NET(WSDL)

, .

0
source

All Articles