google.protobuf.Any generated OpenAPI v2 yaml that is potentially incorrect
Author: veqrynCreated Sep 15, 2024Updated Aug 21, 2026
Labelsbugopenapi
Bug Report
I believe the generated OpenAPI v2 yaml for a google.protobuf.Any is incorrect.
This may also occur on other objects that use additionalProperties: {}
To Reproduce
- Have a proto file that includes a google.protobuf.Any somewhere
- Generate the OpenAPI v2 yaml
- Look at the OpenAPI v2 yaml, try generating OpenAPI client sdk's based on it.
Expected behavior
I expect the generated yaml to look like this:
protobufAny:
type: object
properties:
'@type':
type: string
additionalProperties: trueWhen turned into OpenAPI client sdk for golang, it would become something like this:
type ProtobufAny struct {
Type *string `json:"@type"`
AdditionalProperties map[string]any
}Actual Behavior
protobufAny:
type: object
properties:
'@type':
type: string
additionalProperties: {}I believe this is wrong, because additionalProperties: {} can either imply a second level map, or an object without fields. It should be additionalProperties: true
When turned into OpenAPI client sdk for golang, it becomes this:
type ProtobufAny struct {
Type *string `json:"@type"`
AdditionalProps map[string]struct{}
}or
type ProtobufAny struct {
Type *string `json:"@type"`
AdditionalProperties map[string]map[string]interface{}
}In both cases, the client fails on trying to unmarshal into this struct.
Your Environment
v2.22.0 Linux and Mac
Source: grpc-ecosystem/grpc-gateway