New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.net core 3.0 pre9 Swashbuckle.AspNetCore5.0 error #1259
Comments
What version of Swashbuckle.AspNetCore 5.0.0 are you using? A minimum of rc2 is required for use with .NET Core 3.0, see #1061. |
I'm getting a fairly similar, but different set of exceptions. Can I assume that I should open a different issue? (And I've installed 5.0.0-rc4 into this tutorial project.) Thanks. |
I am having the same issue, running .net core 3. everything is the latest version. |
Hi, we still have the same exception with swashbuckle
|
Same troubles on ASP Net Core 3. Everything is latest. To reproduce it's enough to add swagger in ConfigureServices: public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen();
} .csproj file: <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.OpenApi" Version="1.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="4.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="4.0.1" />
</ItemGroup>
</Project> Exception output:
|
same here |
You must use at least |
Strangely, I ran into a very similar problem while setting up an ASP.NET Core 3 application. In my case I was using 5.0.0-rc4. Turned out I hadn't yet added a controller of any kind to the application, as I was creating a skeleton app from scratch. Added a controller with a dummy controller action and the problem went away. |
I had the same problem on ASP.NET Core 3.0 with Swagger 4.0.0, which as mentioned isn't supported (despite the documents saying ASP.NET Core version >= 2.0 for Swagger v4.0). I upgraded to 5.0.0-rc4 (which requires Microsoft.OpenAPi 1.1.4), and then verified that all controllers and methods were decorated with routing attributes and that all non-route parameters where decorated with FromBody or FromQuery. Now working fine. |
Brubning thanks for the pointer... working great now. |
I had the same problem on ASP.NET Core 3.0 with Swagger 4.0.0 |
System.AggregateException
HResult=0x80131500
Message=Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator': Failed to compare two elements in the array.) (Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.SwaggerGen.ISchemaRegistryFactory Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SchemaRegistryFactory': Failed to compare two elements in the array.)
Source=Microsoft.Extensions.DependencyInjection
StackTrace:
at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(IEnumerable
1 serviceDescriptors, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options) at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder) at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter
1.CreateServiceProvider(Object containerBuilder)at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Paperlee.FOStock.WebAPI.Program.Main(String[] args) in G:\selfproj\FOStock\Paperlee.FOStock.WebAPI\Program.cs:line 17
内部异常 1:
InvalidOperationException: Error while validating the service descriptor 'ServiceType: Swashbuckle.AspNetCore.Swagger.ISwaggerProvider Lifetime: Transient ImplementationType: Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator': Failed to compare two elements in the array.
内部异常 2:
InvalidOperationException: Failed to compare two elements in the array.
内部异常 3:
TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.MvcJsonOptions' from assembly 'Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers(options =>
{
options.Filters.Add();
});
services.AddCors(options => { options.AddPolicy("AllowAllOrigin", builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials(); }); });
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new Info
{
Version = "Version 1.0",
Title = "通用数据API",
Description = "Author:Lee"
});
options.OperationFilter();
SwaggerHelper.LoadXml(options, new string[] { "JQProject.FOStock.IApp.xml", "JQProject.FOStock.WebAPI.xml" }, AppContext.BaseDirectory);
});
//new StartupConfig().Init(services);
}
The text was updated successfully, but these errors were encountered: