The way you implemented it has a mayor drawback: you are changing the contract, and also i think the new contract isn't documented in Swagger. All your endpoints return ApiResponde, but here you are returning ValidationProblem, which isn't ApiResponse instance. So in this case, api clients need to hande two api contracts and two error contracts: ValidationProblem and ApiResponse.Error
The only correct place where services from DI are method parameters is in Minimal Endpoints. In any other case, it must be a dependency of the class, and it must be resolved from the constructor
ASP NET Core has built in support for configuration from different sources like host environment, json files, dotnet-secrets and so on. It's the recommended way to configure not only ASP NET Core applicatios but any dotnet application, because all the logic is in Microsoft.Extensions.Configuration.* namespaces
What do to:
Put your configuration in appsettings.ENVIRONMENT.json. For connection strings, there is a specific key in that file, ConnectionStrings, where you must put all your connections.
Access configuration using builder.Configuration.GetSection() and for connection strings, builder.Configuration.GetConnectionString()
If you need to bind a configuration section to an object, you can use builder.Service.Configure()