コード例 #1
0
ファイル: Utilities.cs プロジェクト: p3s/craftsman
        public static void AddStartupEnvironmentsWithServices(
            string solutionDirectory,
            string projectName,
            string dbName,
            List <ApiEnvironment> environments,
            SwaggerConfig swaggerConfig,
            int port,
            bool useJwtAuth,
            string projectBaseName,
            IFileSystem fileSystem)
        {
            AppSettingsBuilder.CreateWebApiAppSettings(solutionDirectory, dbName, projectBaseName);

            if (environments.Where(e => e.EnvironmentName == "Development").Count() == 0)
            {
                environments.Add(new ApiEnvironment {
                    EnvironmentName = "Development", ProfileName = $"{projectName} (Development)"
                });
            }

            foreach (var env in environments)
            {
                WebApiLaunchSettingsModifier.AddProfile(solutionDirectory, env, port, projectBaseName);
            }
            if (!swaggerConfig.IsSameOrEqualTo(new SwaggerConfig()))
            {
                SwaggerBuilder.RegisterSwaggerInStartup(solutionDirectory, projectBaseName);
            }
        }
コード例 #2
0
 public static void AddSwagger(string solutionDirectory, SwaggerConfig swaggerConfig, string solutionName, bool addJwtAuthentication, List <Policy> policies)
 {
     if (!swaggerConfig.IsSameOrEqualTo(new SwaggerConfig()))
     {
         AddSwaggerServiceExtension(solutionDirectory, swaggerConfig, solutionName, addJwtAuthentication, policies);
         AddSwaggerAppExtension(solutionDirectory, swaggerConfig, addJwtAuthentication);
         UpdateWebApiCsProjSwaggerSettings(solutionDirectory, solutionName);
     }
 }
コード例 #3
0
ファイル: SwaggerBuilder.cs プロジェクト: p3s/craftsman
 public static void AddSwagger(string solutionDirectory, SwaggerConfig swaggerConfig, string projectName, bool addJwtAuthentication, IEnumerable <Policy> policies, string projectBaseName, IFileSystem fileSystem)
 {
     if (!swaggerConfig.IsSameOrEqualTo(new SwaggerConfig()))
     {
         AddSwaggerServiceExtension(solutionDirectory, projectBaseName, swaggerConfig, projectName, addJwtAuthentication, policies, fileSystem);
         WebApiAppExtensionsBuilder.CreateSwaggerWebApiAppExtension(solutionDirectory, swaggerConfig, addJwtAuthentication, projectBaseName, fileSystem);
         UpdateWebApiCsProjSwaggerSettings(solutionDirectory, projectBaseName);
     }
 }
コード例 #4
0
ファイル: Utilities.cs プロジェクト: znedw/craftsman
        public static void AddStartupEnvironmentsWithServices(
            string solutionDirectory,
            string solutionName,
            string dbName,
            List <ApiEnvironment> environments,
            SwaggerConfig swaggerConfig,
            int port,
            bool useJwtAuth,
            string projectBaseName = "")
        {
            // add a development environment by default for local work if none exists
            if (environments.Where(e => e.EnvironmentName == "Development").Count() == 0)
            {
                environments.Add(new ApiEnvironment {
                    EnvironmentName = "Development", ProfileName = $"{solutionName} (Development)"
                });
            }

            if (environments.Where(e => e.EnvironmentName == "Production").Count() == 0)
            {
                environments.Add(new ApiEnvironment {
                    EnvironmentName = "Production", ProfileName = $"{solutionName} (Production)"
                });
            }

            var sortedEnvironments = environments.OrderBy(e => e.EnvironmentName == "Development" ? 1 : 0).ToList(); // sets dev as default profile

            foreach (var env in sortedEnvironments)
            {
                // default startup is already built in cleanup phase
                if (env.EnvironmentName != "Production")
                {
                    StartupBuilder.CreateWebApiStartup(solutionDirectory, env.EnvironmentName, useJwtAuth, projectBaseName);
                }

                WebApiAppSettingsBuilder.CreateAppSettings(solutionDirectory, env, dbName, projectBaseName);
                WebApiLaunchSettingsModifier.AddProfile(solutionDirectory, env, port, projectBaseName);

                //services
                if (!swaggerConfig.IsSameOrEqualTo(new SwaggerConfig()))
                {
                    SwaggerBuilder.RegisterSwaggerInStartup(solutionDirectory, env, projectBaseName);
                }
            }

            // add an integration testing env to make sure that an in memory database is used
            var functionalEnv = new ApiEnvironment()
            {
                EnvironmentName = "FunctionalTesting"
            };

            WebApiAppSettingsBuilder.CreateAppSettings(solutionDirectory, functionalEnv, "", projectBaseName);
        }