Exemplo n.º 1
0
        protected override async Task <string> RunIsolatedAsync(AssemblyLoader.AssemblyLoader assemblyLoader)
        {
            var document       = new OpenApiDocument();
            var generator      = new JsonSchemaGenerator(Settings);
            var schemaResolver = new OpenApiSchemaResolver(document, Settings);

#if FullNet
            var assemblies = PathUtilities.ExpandFileWildcards(AssemblyPaths)
                             .Select(path => Assembly.LoadFrom(path)).ToArray();
#else
            var currentDirectory = DynamicApis.DirectoryGetCurrentDirectory();
            var assemblies       = PathUtilities.ExpandFileWildcards(AssemblyPaths)
                                   .Select(path => assemblyLoader.Context.LoadFromAssemblyPath(PathUtilities.MakeAbsolutePath(path, currentDirectory))).ToArray();
#endif

            var allExportedClassNames = assemblies.SelectMany(a => a.ExportedTypes).Select(t => t.FullName).ToList();
            var matchedClassNames     = ClassNames
                                        .SelectMany(n => PathUtilities.FindWildcardMatches(n, allExportedClassNames, '.'))
                                        .Distinct();

            foreach (var className in matchedClassNames)
            {
                var type = assemblies.Select(a => a.GetType(className)).FirstOrDefault(t => t != null);
                generator.Generate(type, schemaResolver);
            }

            return(document.ToJson(OutputType));
        }