Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Created June 4, 2020 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavilanch/d9326bd02a6789ec2d4b1c1c12dab6c1 to your computer and use it in GitHub Desktop.
Save gavilanch/d9326bd02a6789ec2d4b1c1c12dab6c1 to your computer and use it in GitHub Desktop.
// Unnecessary code removed for brevity
namespace WebApiSwaggerVersion
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSwaggerGen(config =>
{
var titleBase = "Movies API";
var description = "This is a Web API for Movies operations";
var TermsOfService = new Uri("https://udemy.com/user/felipegaviln/");
var License = new OpenApiLicense()
{
Name = "MIT"
};
var Contact = new OpenApiContact()
{
Name = "Felipe Gavilán",
Email = "felipe_gavilan887@hotmail.com",
Url = new Uri("https://gavilan.blog/")
};
config.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = titleBase + " v1",
Description = description,
TermsOfService = TermsOfService,
License = License,
Contact = Contact
});
config.SwaggerDoc("v2", new OpenApiInfo
{
Version = "v2",
Title = titleBase + " v2",
Description = description,
TermsOfService = TermsOfService,
License = License,
Contact = Contact
});
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseSwagger();
app.UseSwaggerUI(config =>
{
config.SwaggerEndpoint("/swagger/v1/swagger.json", "MoviesAPI v1");
config.SwaggerEndpoint("/swagger/v2/swagger.json", "MoviesAPI v2");
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment