Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

i want to add two Version to config.SwaggerDoc in services.AddSwaggerGen for implemet swagger

I want to add two Versions to the config.SwaggerDoc in services.AddSwaggerGen to implement Swagger

for example:

services.AddSwaggerGen(
            config =>
            {
              
                config.SwaggerDoc("v1.1", new OpenApiInfo { Title = "BookingApis V1", Version = "v1.1", Description = "Developed By Demon" });
                config.SwaggerDoc("v2", new OpenApiInfo { Title = "BookingApis V2", Version = "v2", Description = "Developed By Demon" });

}
);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

these settings are necessary for me to implement swagger in Asp.Net and .core6
these settings adds in startup in the section of services.AddSwaggerGen

>Solution :

I found this issue your answer is:

app.UseSwaggerUI(options =>
        { 
            options.SwaggerEndpoint("/swagger/v1/swagger.json", "Booking API V1");
            options.SwaggerEndpoint("/swagger/v2/swagger.json", "Booking  API V2");

            {
                foreach (var description in provider.ApiVersionDescriptions)
                {
                    options.SwaggerEndpoint(
                        $"/swagger/{description.GroupName}/swagger.json",
                        description.GroupName);
                }
            }
        });
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading