Created
June 4, 2020 21:02
-
-
Save gavilanch/d9326bd02a6789ec2d4b1c1c12dab6c1 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
// 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 = "[email protected]", | |
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