ApiDescription server should inject Environment variable
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
Currently if you use the [ApiDescription.Server](https://www.nuget.org/packages/microsoft.extensions.apidescription.server/) you need to do [reflection](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/aspnetcore-openapi?view=aspnetcore-10.0&tabs=visual-studio%2Cvisual-studio-code#customize-runtime-behavior-during-build-time-document-generation) to see if it is running with this server.
```csharp
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):
```csharp
if (builder.Configuration.GetValue("ASPNET_APIDESCRIPTION"))
{
...
}
```
Contributor guide
Assessment
This issue has not been assessed yet.