Beispiel #1
0
        private static void Main(string[] args)
        {
            var options = new CommandLineOptions();

            try
            {
                if (CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    LoadReferences(options);

                    string                      assemblyPath    = options.AssemblyPath;
                    HttpConfiguration           config          = HttpConfigurationImporter.ImportConfiguration(assemblyPath);
                    Collection <ApiDescription> descriptions    = config.Services.GetApiExplorer().ApiDescriptions;
                    IOutputGenerator            outputGenerator = LoadOutputGenerator(options);

                    outputGenerator.GenerateIndex(descriptions);

                    foreach (var api in descriptions)
                    {
                        HelpPageSampleGenerator sampleGenerator = config.GetHelpPageSampleGenerator();
                        HelpPageApiModel        apiModel        = HelpPageConfigurationExtensions.GenerateApiModel(api, sampleGenerator);
                        if (apiModel != null)
                        {
                            outputGenerator.GenerateApiDetails(apiModel);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e.Message);
            }
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            var options = new CommandLineOptions();

            try
            {
                if (CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    LoadReferences(options);

                    string            assemblyPath = options.AssemblyPath;
                    HttpConfiguration config       = HttpConfigurationImporter.ImportConfiguration(assemblyPath);

                    //Get the ApiExplorer instance, and bind our own XML doc provider to it
                    var explorer = (ApiExplorer)config.Services.GetApiExplorer();

                    if (!string.IsNullOrEmpty(options.XmlDocPath))
                    {
                        var docProvider = new XmlDocumentationProvider(options.XmlDocPath);
                        explorer.DocumentationProvider = docProvider;
                    }

                    //And extract our API documentation
                    Collection <ApiDescription> descriptions    = explorer.ApiDescriptions;
                    IOutputGenerator            outputGenerator = LoadOutputGenerator(options);

                    outputGenerator.GenerateIndex(descriptions);

                    foreach (var api in descriptions)
                    {
                        HelpPageSampleGenerator sampleGenerator = config.GetHelpPageSampleGenerator();
                        HelpPageApiModel        apiModel        = HelpPageConfigurationExtensions.GenerateApiModel(api, sampleGenerator);
                        if (apiModel != null)
                        {
                            outputGenerator.GenerateApiDetails(apiModel);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: {0}", e.Message);
            }
        }
Beispiel #3
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            var documentationProvider = new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/bin/Triangles.xml"));

            HelpPageConfigurationExtensions.SetDocumentationProvider(config, documentationProvider);
        }
Beispiel #4
0
        private static void Main(string[] args)
        {
            var options = new CommandLineOptions();

            try
            {
                var success = CommandLine.Parser.Default.ParseArguments(args, options);

                if (true)
                {
                    LoadReferences(options);

                    var assemblyPath    = options.AssemblyPath;
                    var config          = HttpConfigurationImporter.ImportConfiguration(assemblyPath);
                    var descriptions    = config.Services.GetApiExplorer().ApiDescriptions;
                    var outputGenerator = LoadOutputGenerator(options);

                    outputGenerator.GenerateIndex(descriptions, options);

                    foreach (var api in descriptions)
                    {
                        var sampleGenerator = config.GetHelpPageSampleGenerator();
                        var apiModel        = HelpPageConfigurationExtensions.GetHelpPageApiModel(config, api.GetFriendlyId());

                        if (apiModel != null)
                        {
                            outputGenerator.GenerateApiDetails(apiModel, options);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                PrintException(e);
                Environment.Exit(-1);
            }
        }