Skip to content

ApiDescription server should inject Environment variable #65618

@svrooij

Description

@svrooij

Currently if you use the ApiDescription.Server you need to do reflection to see if it is running with this server.

using System.Reflection;

var builder = WebApplication.CreateBuilder(args);
// I don't want this!!
if (Assembly.GetEntryAssembly()?.GetName().Name != "GetDocument.Insider")
{
    builder.AddServiceDefaults();
}

This is very bad, I don't want any reflection in my code (AOT build), maybe it can inject a special environment variable in the config?

I want (or similar):

if (builder.Configuration.GetValue<bool>("ASPNET_APIDESCRIPTION"))
{
...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions