Beispiel #1
0
        private async Task ExecuteDocumentAsync(IConsoleHost host, string filePath)
        {
            host.WriteMessage("\nExecuting file '" + filePath + "'...\n");

            var document = await NSwagDocument.LoadAsync(filePath);

            await document.ExecuteAsync();

            host.WriteMessage("Done.\n");
        }
Beispiel #2
0
        /// <exception cref="InvalidOperationException">Configuraiton file does not contain AssemblyTypeToSwagger settings.</exception>
        protected async Task <AssemblyTypeToSwaggerGenerator> CreateGeneratorAsync()
        {
            if (!string.IsNullOrEmpty(File))
            {
                var document = await NSwagDocument.LoadAsync(File);

                var settings = document.SwaggerGenerators?.AssemblyTypeToSwaggerCommand?.Settings;
                if (settings == null)
                {
                    throw new InvalidOperationException("Configuraiton file does not contain AssemblyTypeToSwagger settings.");
                }

                return(new AssemblyTypeToSwaggerGenerator(settings));
            }
            else
            {
                return(new AssemblyTypeToSwaggerGenerator((AssemblyTypeToSwaggerGeneratorSettings)Settings));
            }
        }