Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Created June 4, 2020 16:33
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/3d121ca3011b7261a6778287bee96042 to your computer and use it in GitHub Desktop.
Save gavilanch/3d121ca3011b7261a6778287bee96042 to your computer and use it in GitHub Desktop.
namespace WebApiSwaggerVersion
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(config =>
{
config.SwaggerDoc("WebAPI", new OpenApiInfo
{
Title = "Movies API",
Description = "This is a Web API for Movies operations",
TermsOfService = new Uri("https://udemy.com/user/felipegaviln/"),
License = new OpenApiLicense()
{
Name = "MIT"
},
Contact = new OpenApiContact()
{
Name = "Felipe Gavilán",
Email = "felipe_gavilan887@hotmail.com",
Url = new Uri("https://gavilan.blog/")
}
});
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseSwagger();
app.UseSwaggerUI(config =>
{
config.SwaggerEndpoint("/swagger/WebAPI/swagger.json", "MoviesAPI");
});
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment