Created
June 4, 2020 16:33
-
-
Save gavilanch/3d121ca3011b7261a6778287bee96042 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "[email protected]", | |
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