DEV Community

BernoItaliano
BernoItaliano

Posted on

Error versioning in NetCore

good morning

I have my API and I want to make two versions of it, reading this excellent post (https://dev.to/htissink/versioning-asp-net-core-apis-with-swashbuckle-making-space-potatoes-vxxx-3po7) .
I follow every step to the letter, and I have the error I attached ...

*** ArgumentException: An item with the same key has already been added. Key: v1
c.SwaggerDoc("v1", new Info { Title = "API 1 HILP", Version = "v1" }); ***

        services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v1", new Info { Title = "API 1 HILP", Version = "v1" });
            c.SwaggerDoc("v2", new Info { Title = "API 2 *PRUEBA* HILP", Version = "v2" });
           // c.ExampleFilters();


            // Set the comments path for the Swagger JSON and UI.
            var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
            var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
            c.IncludeXmlComments(xmlPath);
            c.CustomSchemaIds(x => x.FullName);
        });

From what I understand, I am using the same Key twice but I cannot find this error.

I appreciate every contribution and help!

Regards!!

Top comments (0)