Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

832
Visualizações
¿Por qué el swagger no se abre en .NET 6?

Bueno, estaba haciendo un proyecto DDD, específicamente usando redis, pero no creo que tenga nada que ver.

El problema es que no me aparece el swagger, falla, pero cuando hago pedidos en cartero funciona normalmente.

Ese es el error:

 Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. System.TypeLoadException: Could not load type 'Microsoft.AspNetCore.Http.Metadata.ITagsMetadata' from assembly 'Microsoft.AspNetCore.Http.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions.DefaultTagsSelector(ApiDescription apiDescription) at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions.DefaultSortKeySelector(ApiDescription apiDescription) in Swashbuckle.AspNetCore.SwaggerGen.dll:token 0x600012d+0x0 at System.Linq.EnumerableSorter`2.ComputeKeys(TElement[] elements, Int32 count) in System.Linq.dll:token 0x600040b+0x10 at System.Linq.EnumerableSorter`1.ComputeMap(TElement[] elements, Int32 count) in System.Linq.dll:token 0x6000401+0x0 at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count) in System.Linq.dll:token 0x6000402+0x0 at System.Linq.OrderedEnumerable`1.GetEnumerator()+MoveNext() in System.Linq.dll:token 0x6000391+0x3d at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer) in System.Linq.dll:token 0x6000366+0x2b at System.Linq.GroupedEnumerable`2.GetEnumerator() in System.Linq.dll:token 0x600035f+0x0 at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository) in Swashbuckle.AspNetCore.SwaggerGen.dll:token 0x60000f8+0x3a at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath) in Swashbuckle.AspNetCore.SwaggerGen.dll:token 0x60000f6+0xe6 at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) in Swashbuckle.AspNetCore.Swagger.dll:token 0x6000009+0xe2 at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) in Microsoft.AspNetCore.Diagnostics.dll:token 0x60000aa+0x82

Archivo de inicio ( ConfigureServices ):

 public void ConfigureServices(IServiceCollection services) { services.AddRedisContext(Configuration); services.AddControllers(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Basket.Api", Version = "v1" }); });

Mi método en la clase de método de extensión:

 public static IServiceCollection AddRedisContext(this IServiceCollection services, IConfiguration config) { services.AddStackExchangeRedisCache(options => { options.Configuration = config["CacheSettings:ConnectionString"]; }); services.AddScoped<IBasketRepository, BasketRepository>(); services.AddScoped<IBasketService, BasketService>(); return services; }

La referencia del paquete:

 <Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net6.0</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Basket.Infra.Data\Basket.Infra.Data.csproj" /> </ItemGroup> </Project>

También comenté las líneas que se refieren a redis y todavía daba el mismo error. Así que es casi seguro que es algo relacionado con la arrogancia.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

En mi caso, el SDK no ejecutaba la versión net6.0 adecuada.

Si bien todo el proyecto usaba nuevos paquetes Net6.0 NuGet, el SDK local en esa máquina en la que estaba trabajando todavía era net5.0. Después de instalar .net6.0, Swashbuckle 6.2.3 volvió a funcionar y todo fue como se esperaba.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda