Search code examples
visual-studio.net-coreswagger-ui

Swagger UI encoding error in .Net Core Web Api


I'm currrently using swagger in a .Net Core API project but the documentation page generated by swagger is having encoding issues :

enter image description here

Does anyone know how to solve this encoding issue? I tried looking for a place to configure the encoding but didn't find it.

builder.Services.AddSwaggerGen(options =>
{
    options.SwaggerDoc(swaggerVersion, new OpenApiInfo
    {
        Version = swaggerVersion,
        Title = "Validação de telefones",
        Description = "API de validação de números de telefone utilizando somente dados internos.A api utilizado dados..."

    });
 });

Solution

  • It seems the issue was the encoding of Program.cs file. I was using Visual Studio 2022 and it's default encoding is Western Europe not UTF-8. I followed the instructions in this link to make Visual Studio change the enconding it saved the file with.