Open Closed

Swagger support to Abp Elsa demo #1530


User avatar
0
VivekKoppula created

This is a follow upto this question

I am trying to add swagger support by doing the following.

  1. Added the following line of code the web module.

    context.Services.AddElsaApiEndpoints();
    // The following is throwing exception
    context.Services.AddElsaSwagger();

But it is throwing exception. The exception is shown below for your reference. So I had to comment out.

  1. Also tried to add the following code in the same ElsaDemoWebModule.cs file.

    app.UseAbpSwaggerUI(options =>
    {
    options.SwaggerEndpoint("/swagger/v1/swagger.json", "ElsaDemo API");
    // The following did not help.
    options.SwaggerEndpoint("/swagger/v1/swagger.json", "Elsa");
    });

But it did help. I get Elsa in the drop down, but selecting it does not give the elsa swagger UI.

image.png

The full exception is as follows.

An unhandled exception occurred while processing the request.
ArgumentException: An item with the same key has already been added. Key: v1
System.Collections.Generic.Dictionary<TKey, TValue>.TryInsert(TKey key, TValue value, InsertionBehavior behavior)

DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.Extensions.Options.IOptions`1[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenOptions], System.IServiceProvider, Microsoft.AspNetCore.Hosting.IWebHostEnvironment)' on type 'ConfigureSwaggerGeneratorOptions'.
Autofac.Core.Activators.Reflection.BoundConstructor.Instantiate()

DependencyResolutionException: An exception was thrown while activating Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator -> λ:Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions -> Microsoft.Extensions.Options.OptionsManager1[[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions, Swashbuckle.AspNetCore.SwaggerGen, Version=6.1.4.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a]] -> Microsoft.Extensions.Options.OptionsFactory1[[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions, Swashbuckle.AspNetCore.SwaggerGen, Version=6.1.4.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a]] -> λ:Microsoft.Extensions.Options.IConfigureOptions`1[[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions, Swashbuckle.AspNetCore.SwaggerGen, Version=6.1.4.0, Culture=neutral, PublicKeyToken=d84d99fb0135530a]][] -> Swashbuckle.AspNetCore.SwaggerGen.ConfigureSwaggerGeneratorOptions.
Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action<ResolveRequestContext> next)


2 Answer(s)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 11, 2025, 10:10