Erro ao executar o programa:
O erro é indicado em app.MapController();
Exceção sem tratamento (erro em App.MapController - Program.cs)
System.ArgumentException: 'There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character. Arg_ParamName_Name'
RoutePatternException: There is an incomplete parameter in the route template. Check that each '{' character has a matching '}' character.
program.cs
using FilmesApi.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
//Como conectar e acessar o banco
//DBContext abstrai a lógica de acesso ao banco de dados
var connectionString = builder.Configuration.GetConnectionString("FilmeConnection");
builder.Services.AddDbContext<FilmeContext>(Opts =>
Opts.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
//Add services to the automapper
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
// Add services to the container.
builder.Services.AddControllers().AddNewtonsoftJson();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "FilmesAPI", Version = "v1" });
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();