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

  1. Have a proto file that includes a google.protobuf.Any somewhere
  2. Generate the OpenAPI v2 yaml
  3. 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:

yaml
  protobufAny:
    type: object
    properties:
      '@type':
        type: string
    additionalProperties: true

When turned into OpenAPI client sdk for golang, it would become something like this:

go
type ProtobufAny struct {
	Type *string `json:"@type"`
	AdditionalProperties map[string]any
}

Actual Behavior

yaml
  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:

go
type ProtobufAny struct {
	Type *string `json:"@type"`
	AdditionalProps map[string]struct{}
}

or

go
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