/// <summary>Generates the Swagger definition for all controllers in the assembly.</summary> /// <param name="controllerClassNames">The controller class names.</param> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> /// <returns>The Swagger definition.</returns> public override async Task <SwaggerDocument> GenerateForControllersAsync(IEnumerable <string> controllerClassNames) { if (!(Settings.SchemaNameGenerator is DefaultSchemaNameGenerator)) { throw new InvalidOperationException("The SchemaNameGenerator cannot be customized when loading types from external assemblies."); } if (!(Settings.TypeNameGenerator is DefaultTypeNameGenerator)) { throw new InvalidOperationException("The TypeNameGenerator cannot be customized when loading types from external assemblies."); } #if FullNet using (var isolated = new AppDomainIsolation <WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPaths.First())), Settings.AssemblyConfig)) { var document = await Task.Run(() => isolated.Object.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings))).ConfigureAwait(false); return(await SwaggerDocument.FromJsonAsync(document).ConfigureAwait(false)); } #else var loader = new WebApiAssemblyLoader(); var data = loader.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return(await SwaggerDocument.FromJsonAsync(data).ConfigureAwait(false)); #endif }
/// <summary>Gets the available controller classes from the given assembly.</summary> /// <returns>The controller classes.</returns> /// <exception cref="FileNotFoundException">The assembly could not be found.</exception> /// <exception cref="FileNotFoundException">The assembly config file could not be found..</exception> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> public override string[] GetControllerClasses() { if (Settings.AssemblyPaths == null || Settings.AssemblyPaths.Length == 0) { throw new InvalidOperationException("No assembly paths have been provided."); } if (!File.Exists(Settings.AssemblyPaths.First())) { throw new FileNotFoundException("The assembly could not be found.", Settings.AssemblyPaths.First()); } if (!string.IsNullOrEmpty(Settings.AssemblyConfig) && !File.Exists(Settings.AssemblyConfig)) { throw new FileNotFoundException("The assembly config file could not be found.", Settings.AssemblyConfig); } #if FullNet using (var isolated = new AppDomainIsolation <WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPaths.First())), Settings.AssemblyConfig)) return(isolated.Object.GetControllerClasses(Settings.AssemblyPaths, GetAllReferencePaths(Settings))); #else var loader = new WebApiAssemblyLoader(); return(loader.GetControllerClasses(Settings.AssemblyPaths, GetAllReferencePaths(Settings))); #endif }
/// <summary>Generates the Swagger definition for all controllers in the assembly.</summary> /// <param name="controllerClassNames">The controller class names.</param> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> /// <returns>The Swagger definition.</returns> public override SwaggerDocument GenerateForControllers(IEnumerable <string> controllerClassNames) { var loader = new WebApiAssemblyLoader(); var data = loader.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return(SwaggerDocument.FromJson(data)); }
/// <summary>Generates the Swagger definition for all controllers in the assembly.</summary> /// <param name="controllerClassNames">The controller class names.</param> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> /// <returns>The Swagger definition.</returns> public override SwaggerDocument GenerateForControllers(IEnumerable <string> controllerClassNames) { #if FullNet using (var isolated = new AppDomainIsolation <WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPaths.First())), Settings.AssemblyConfig)) { var document = isolated.Object.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return(SwaggerDocument.FromJson(document)); } #else var loader = new WebApiAssemblyLoader(); var data = loader.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return(SwaggerDocument.FromJson(data)); #endif }
/// <summary>Generates the Swagger definition for all controllers in the assembly.</summary> /// <param name="controllerClassNames">The controller class names.</param> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> /// <returns>The Swagger definition.</returns> public override SwaggerDocument GenerateForControllers(IEnumerable<string> controllerClassNames) { #if FullNet using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPaths.First())), Settings.AssemblyConfig)) { var document = isolated.Object.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return SwaggerDocument.FromJson(document); } #else var loader = new WebApiAssemblyLoader(); var data = loader.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return SwaggerDocument.FromJson(data); #endif }
/// <summary>Generates the Swagger definition for all controllers in the assembly.</summary> /// <param name="controllerClassNames">The controller class names.</param> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> /// <returns>The Swagger definition.</returns> public override async Task <SwaggerDocument> GenerateForControllersAsync(IEnumerable <string> controllerClassNames) { #if FullNet using (var isolated = new AppDomainIsolation <WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPaths.First())), Settings.AssemblyConfig)) { var document = await Task.Run(() => isolated.Object.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings))).ConfigureAwait(false); return(await SwaggerDocument.FromJsonAsync(document).ConfigureAwait(false)); } #else var loader = new WebApiAssemblyLoader(); var data = loader.GenerateForControllers(controllerClassNames, JsonConvert.SerializeObject(Settings)); return(await SwaggerDocument.FromJsonAsync(data).ConfigureAwait(false)); #endif }
/// <summary>Gets the available controller classes from the given assembly.</summary> /// <returns>The controller classes.</returns> /// <exception cref="FileNotFoundException">The assembly could not be found.</exception> /// <exception cref="FileNotFoundException">The assembly config file could not be found..</exception> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> public override string[] GetControllerClasses() { if (Settings.AssemblyPaths == null || Settings.AssemblyPaths.Length == 0) throw new InvalidOperationException("No assembly paths have been provided."); if (!File.Exists(Settings.AssemblyPaths.First())) throw new FileNotFoundException("The assembly could not be found.", Settings.AssemblyPaths.First()); if (!string.IsNullOrEmpty(Settings.AssemblyConfig) && !File.Exists(Settings.AssemblyConfig)) throw new FileNotFoundException("The assembly config file could not be found.", Settings.AssemblyConfig); #if FullNet using (var isolated = new AppDomainIsolation<WebApiAssemblyLoader>(Path.GetDirectoryName(Path.GetFullPath(Settings.AssemblyPaths.First())), Settings.AssemblyConfig)) return isolated.Object.GetControllerClasses(Settings.AssemblyPaths, GetAllReferencePaths(Settings)); #else var loader = new WebApiAssemblyLoader(); return loader.GetControllerClasses(Settings.AssemblyPaths, GetAllReferencePaths(Settings)); #endif }
/// <summary>Gets the available controller classes from the given assembly.</summary> /// <returns>The controller classes.</returns> /// <exception cref="FileNotFoundException">The assembly could not be found.</exception> /// <exception cref="FileNotFoundException">The assembly config file could not be found..</exception> /// <exception cref="InvalidOperationException">No assembly paths have been provided.</exception> public override string[] GetControllerClasses() { if (Settings.AssemblyPaths == null || Settings.AssemblyPaths.Length == 0) { throw new InvalidOperationException("No assembly paths have been provided."); } if (!File.Exists(Settings.AssemblyPaths.First())) { throw new FileNotFoundException("The assembly could not be found.", Settings.AssemblyPaths.First()); } if (!string.IsNullOrEmpty(Settings.AssemblyConfig) && !File.Exists(Settings.AssemblyConfig)) { throw new FileNotFoundException("The assembly config file could not be found.", Settings.AssemblyConfig); } var loader = new WebApiAssemblyLoader(); return(loader.GetControllerClasses(Settings.AssemblyPaths, GetAllReferencePaths(Settings))); }