Skip to content

Instantly share code, notes, and snippets.

@felipebossolani
Created February 17, 2019 00:53
Show Gist options
  • Save felipebossolani/5397eb13455a59c56a75a52f5e7affdb to your computer and use it in GitHub Desktop.
Save felipebossolani/5397eb13455a59c56a75a52f5e7affdb to your computer and use it in GitHub Desktop.
Startup.cs - ConfigureServices Method
// Configurando o serviço de documentação do Swagger
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1",
new Info
{
Title = "Comparador de Fundos - Meuportfol.io",
Version = "v1",
Description = "Comparador de Fundos - Meuportfol.io. Para utilização nos procure para obter credencial",
Contact = new Contact
{
Name = "Felipe Bossolani",
Url = "https://meuportfol.io"
}
});
c.CustomSchemaIds(x => x.FullName); //Essa linha deve ser inserida em casos que há classes com mesmo nome em namespaces diferentes
//Obtendo o diretório e depois o nome do arquivo .xml de comentários
var applicationBasePath = PlatformServices.Default.Application.ApplicationBasePath;
var applicationName = PlatformServices.Default.Application.ApplicationName;
var xmlDocumentPath = Path.Combine(applicationBasePath, $"{applicationName}.xml");
//Caso exista arquivo então adiciona-lo
if (File.Exists(xmlDocumentPath))
{
c.IncludeXmlComments(xmlDocumentPath);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment