Exemplo n.º 1
0
        public int OnExecute(CommandLineApplication configCmd)
        {
            ConsoleHelper.WriteHeader();

            var verboseMode = CommandLineApplicationHelper.GetVerboseMode(configCmd);
            var apiOptions  = ApiOptionsHelper.CreateDefault(configCmd);

            ApiOptionsHelper.ApplyValidationOverrides(apiOptions, configCmd);
            ApiOptionsHelper.ApplyGeneratorOverrides(apiOptions, configCmd);

            var specificationPath = CommandLineApplicationHelper.GetSpecificationPath(configCmd);
            var apiDocument       = OpenApiDocumentHelper.CombineAndGetApiDocument(specificationPath);

            var logItems = new List <LogKeyValueItem>();

            logItems.AddRange(OpenApiDocumentHelper.Validate(apiDocument, apiOptions.Validation));

            if (logItems.Any(x => x.LogCategory == LogCategoryType.Error))
            {
                return(ConsoleHelper.WriteLogItemsAndExit(logItems, verboseMode, CommandArea));
            }

            var projectPrefixName = CommandLineApplicationHelper.GetProjectPrefixName(configCmd);
            var outputPath        = CommandLineApplicationHelper.GetOutputPath(configCmd);
            var outputTestPath    = CommandLineApplicationHelper.GetOutputTestPath(configCmd);

            logItems.AddRange(GenerateHelper.GenerateServerApi(
                                  projectPrefixName,
                                  outputPath,
                                  outputTestPath,
                                  apiDocument,
                                  apiOptions));

            return(ConsoleHelper.WriteLogItemsAndExit(logItems, verboseMode, CommandArea));
        }
Exemplo n.º 2
0
        public int OnExecute(CommandLineApplication configCmd)
        {
            ConsoleHelper.WriteHeader();

            var verboseMode = CommandLineApplicationHelper.GetVerboseMode(configCmd);
            var apiOptions  = ApiOptionsHelper.CreateDefault(configCmd);

            ApiOptionsHelper.ApplyValidationOverrides(apiOptions, configCmd);

            var specificationPath = CommandLineApplicationHelper.GetSpecificationPath(configCmd);
            var apiDocument       = OpenApiDocumentHelper.CombineAndGetApiDocument(specificationPath);

            var logItems = new List <LogKeyValueItem>();

            logItems.AddRange(OpenApiDocumentHelper.Validate(apiDocument, apiOptions.Validation));

            if (logItems.Any(x => x.LogCategory == LogCategoryType.Error))
            {
                return(ConsoleHelper.WriteLogItemsAndExit(logItems, verboseMode, CommandArea));
            }

            Console.WriteLine();
            Colorful.Console.Write("Command for client-CSharp is not implemented yet, sorry...", Color.DarkKhaki);

            return(ExitStatusCodes.Success);
        }
Exemplo n.º 3
0
        public int OnExecute(CommandLineApplication configCmd)
        {
            ConsoleHelper.WriteHeader();

            var verboseMode = CommandLineApplicationHelper.GetVerboseMode(configCmd);
            var apiOptions  = ApiOptionsHelper.CreateDefault(configCmd);

            ApiOptionsHelper.ApplyValidationOverrides(apiOptions, configCmd);

            var specificationPath = CommandLineApplicationHelper.GetSpecificationPath(configCmd);
            var apiDocument       = OpenApiDocumentHelper.CombineAndGetApiDocument(specificationPath);

            var logItems = new List <LogKeyValueItem>();

            logItems.AddRange(OpenApiDocumentHelper.Validate(apiDocument, apiOptions.Validation));

            return(ConsoleHelper.WriteLogItemsAndExit(logItems, verboseMode, "Schema"));
        }