Пример #1
0
        public static void Register()
        {
            var thisAssembly = typeof(SwaggerConfig).Assembly;
            var contractAssembly = typeof(CreateOrderCommand).Assembly;

            GlobalConfiguration.Configuration.EnableSwagger(c =>
            {
                c.SingleApiVersion("v1", "SOLID Services API");

                string xmlCommentsPath = HostingEnvironment.MapPath("~/App_Data/Contract.xml");

                c.IncludeXmlComments(xmlCommentsPath);

                var filter = new ControllerlessActionOperationFilter(xmlCommentsPath);
                c.OperationFilter(() => filter);
            })
            .EnableSwaggerUi(c => { });
        }
Пример #2
0
        public static void Register()
        {
            var thisAssembly     = typeof(SwaggerConfig).Assembly;
            var contractAssembly = typeof(CreateOrderCommand).Assembly;

            GlobalConfiguration.Configuration.EnableSwagger(c =>
            {
                c.SingleApiVersion("v1", "SOLID Services API");

                string xmlCommentsPath = HostingEnvironment.MapPath("~/App_Data/Contract.xml");

                c.IncludeXmlComments(xmlCommentsPath);

                var filter = new ControllerlessActionOperationFilter(xmlCommentsPath);
                c.OperationFilter(() => filter);
            })
            .EnableSwaggerUi(c => { });
        }
Пример #3
0
        private static void IncludeXmlCommentsFromAppDataFolder(SwaggerDocsConfig c)
        {
            var appDataPath = HostingEnvironment.MapPath("~/App_Data");

            // The XML comment files are copied using a post-build event (see project settings / Build Events).
            string[] xmlCommentsPaths = Directory.GetFiles(appDataPath, "*.xml");

            foreach (string xmlCommentsPath in xmlCommentsPaths)
            {
                c.IncludeXmlComments(xmlCommentsPath);
            }

            var filter = new ControllerlessActionOperationFilter(xmlCommentsPaths);

            c.OperationFilter(() => filter);

            if (!xmlCommentsPaths.Any())
            {
                throw new ConfigurationErrorsException("No .xml files were found in the App_Data folder.");
            }
        }