improve support for additionalProperties
codeboten opened this issue · 1 comments
codeboten commented
With the following schema, I would expect to be able to access additional properties on the generated struct:
"Attributes": {
"title": "Attributes",
"type": "object",
"additionalProperties": true,
"properties": {
"service.name": {
"type": "string"
}
}
}
But looking at the generated struct, there's no way for me to get additional properties:
type Attributes struct {
// ServiceName corresponds to the JSON schema field "service.name".
ServiceName *string `mapstructure:"service.name,omitempty"`
}
I'd like to propose an additional field is added to the generated struct to look something like this:
type Attributes struct {
// ServiceName corresponds to the JSON schema field "service.name".
ServiceName *string `mapstructure:"service.name,omitempty"`
AdditionalProperties map[string]interface{} // <--- the type here could depend on the "type" field if one is set
}
Reference
Generated code: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/044e09ac8bfe0d5a60510778017bec57413243d9/config/generated_config.go#L19-L22