dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.71k stars 425 forks source link

ConfigSchemaGenerator should ignore casing of configuration keys #4773

Closed bart-vmware closed 2 months ago

bart-vmware commented 3 months ago

Is there an existing issue for this?

Describe the bug

When using ConfigSchemaGenerator, the casing of segments in the config path should be ignored. This is because configuration keys in .NET are case-insensitive.

For example, the following entries should be merged into a single subtree:

[assembly: ConfigurationSchema("Management:Endpoints:Health", typeof(HealthEndpointOptions))]
[assembly: ConfigurationSchema("management:endpoints:Actuator", typeof(HypermediaEndpointOptions))]

I would expect the difference in casing to be ignored, so that the JSON fragment below is produced:

{
  "type": "object",
  "properties": {
    "Management": {
      "type": "object",
      "properties": {
        "Endpoints": {
          "type": "object",
          "properties": {
            "Actuator": {},
            "Health": {}
          }
        }
      }
    }
  }
}

The actual behavior is that no unification takes place:

{
  "type": "object",
  "properties": {
    "Management": {
      "type": "object",
      "properties": {
        "Endpoints": {
          "type": "object",
          "properties": {
            "Health": {}
          }
        }
      }
    },
    "management": {
      "type": "object",
      "properties": {
        "endpoints": {
          "type": "object",
          "properties": {
            "Actuator": {}
          }
        }
      }
    }
  }
}

The same problem possibly applies to the class properties.

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

This should be easy to fix, because JsonObject has a constructor that takes a JsonNodeOptions, which contains the boolean property PropertyNameCaseInsensitive.

bart-vmware commented 3 months ago

/cc @eerhardt I'd be happy to work on a PR to address this.

eerhardt commented 3 months ago

/cc @eerhardt I'd be happy to work on a PR to address this.

Thanks. That would be appreciated!