-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedaffected-very-fewThis issue impacts very few customersThis issue impacts very few customersarea-hostingIncludes HostingIncludes Hostingarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsseverity-nice-to-haveThis label is used by an internal toolThis label is used by an internal tool
Description
Issue:
When attempting to execute dotnet swagger tofile
on dll
with generic Startup
class if fails to locate it.
I do not think that It is Swashbuckle library issue because .NET code fails to locate dll
.
Reproduction scenario:
- From VS create a new ASP.NET Core Web Application. You can select ASP.NET Core Web API to have request and working API.
- In
Startup.cs
, rewriteStartup
toStartup<T>
. Therefore inProgram.cs
, rewrite
webBuilder.UseStartup();
to (for example)
webBuilder.UseStartup<Startup<int>>();
- From cmd execute
dotnet new tool-manifest
in root folder of the project - From cmd execute
dotnet tool install --local --version ${swaggerVersion} Swashbuckle.AspNetCore.Cli
where${swaggerVersion}
- is a version ofSwashbuckle.AspNetCore.Swagger.dll
located together with.dll
- From cmd execute
dotnet tool restore
- From cmd execute
dotnet swagger tofile --output <json documentation file name to generate> <full path to .dll> <version of Web Service API>
Result:
Unhandled exception. System.InvalidOperationException: A type named 'StartupProduction' or 'Startup' could not be found in assembly 'WebApplication1'.
at Microsoft.AspNetCore.Hosting.StartupLoader.FindStartupType(String startupAssemblyName, String environmentName)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Hosting.WebHostBuilder.<>c__DisplayClass14_2.<BuildCommonServices>b__2(IServiceProvider _)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Hosting.WebHost.EnsureStartup()
at Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.WebHost.Initialize()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
Expected:
Swagger JSON/YAML succesfully written to <file path>
Assumption:
Called code only checks with Startup
name and name of generic class will be different.
var startupNameWithoutEnv = "Startup"; |
throw new InvalidOperationException(String.Format("A type named '{0}' or '{1}' could not be found in assembly '{2}'.", |
sviatoslav-vilkovych
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedaffected-very-fewThis issue impacts very few customersThis issue impacts very few customersarea-hostingIncludes HostingIncludes Hostingarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsseverity-nice-to-haveThis label is used by an internal toolThis label is used by an internal tool