Example #1
0
 private Task LoadAssembly()
 {
     return(RunTaskAsync(async() =>
     {
         AllClassNames = await Task.Run(() =>
         {
             var generator = new AssemblyTypeToSwaggerGenerator(AssemblyPath);
             return generator.GetClasses();
         });
         ClassName = AllClassNames.FirstOrDefault();
     }));
 }
        private void GenerateTypeSwagger(FilePath outputFile, SwaggerGeneratorSettings settings)
        {
            var genSettings = settings.JsonSettings as AssemblyTypeToSwaggerGeneratorSettings ??
                              SettingsFactory.GetAssemblyToSwaggerSettings();

            genSettings.AssemblyPath                = Source.MakeAbsolute(Environment).FullPath;
            genSettings.DefaultEnumHandling         = settings.EnumAsString ? EnumHandling.String : EnumHandling.Integer;
            genSettings.DefaultPropertyNameHandling = settings.CamelCaseProperties
                ? PropertyNameHandling.CamelCase
                : PropertyNameHandling.Default;
            genSettings.ReferencePaths = settings.AssemblyPaths.Select(a => a.FullPath).ToArray();
            var gen     = new AssemblyTypeToSwaggerGenerator(genSettings);
            var service = gen.Generate(gen.GetClasses());

            using (var stream = new StreamWriter(FileSystem.GetFile(outputFile).OpenWrite()))
            {
                stream.WriteAsync(service.ToJson());
            }
        }