You are on page 1of 2

public void ConfigureServices(IServiceCollection services)

{
services.AddMvc(config =>
{
config.Filters.Add(new CustomActionFilter());
})
.AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new
CamelCasePropertyNamesContractResolver();
}
);

services.AddSwaggerGen(c =>
{
var sb = new StringBuilder();
sb.AppendLine("Diário Online do sistema de gestão de dados
escolares SGDE,");
sb.AppendLine(string.Empty);
sb.AppendLine("Todos os dados seguem o seguinte padrão de
envelopamento:");
sb.AppendLine("<pre>{");
sb.AppendLine(" “data”:");
sb.AppendLine(" [");
sb.AppendLine(" {");
sb.AppendLine(" ...");
sb.AppendLine(" ...");
sb.AppendLine(" ...");
sb.AppendLine(" “_links”:");
sb.AppendLine(" {");
sb.AppendLine(" “lista”: “...”,");
sb.AppendLine(" “self”: “...”,");
sb.AppendLine(" “excluir”: “...”,");
sb.AppendLine(" “atualizar”: “...”");
sb.AppendLine(" }");
sb.AppendLine(" }");
sb.AppendLine(" ],");
sb.AppendLine(" “status”:");
sb.AppendLine(" {");
sb.AppendLine(" “code”: 0,");
sb.AppendLine(" “message”: “...”");
sb.AppendLine(" },");
sb.AppendLine(" “pagination”:");
sb.AppendLine(" {");
sb.AppendLine(" “has_prev”: “...”,");
sb.AppendLine(" “has_next”: “...”,");
sb.AppendLine(" “page_count”: “...”,");
sb.AppendLine(" “total”: 0");
sb.AppendLine(" },");
sb.AppendLine(" “link_create”: “...”,");
sb.AppendLine(" “version”: “...”");
sb.AppendLine("}</pre>");

c.SwaggerDoc("v1", new Info


{
Title = "D",
Version = "v1",
Description = sb.ToString(),
Contact = new Contact
{
Name = "",
Url = ""
}
});

var basePath =
PlatformServices.Default.Application.ApplicationBasePath;
var xmlPath = Path.Combine(basePath, "");
c.IncludeXmlComments(xmlPath);

c.AddSecurityDefinition("Bearer", new ApiKeyScheme


{
Description = "Autorização JWT no cabeçalho usando esquema
Bearer. Exemplo: \"Bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});

c.AddSecurityRequirement(new Dictionary<string,
IEnumerable<string>>
{
{ "Bearer", Enumerable.Empty<string>() }
});

c.DescribeAllEnumsAsStrings();
c.DescribeAllParametersInCamelCase();
});
}

You might also like