Skip to content

Items type for google.protobuf.ListValue #3414

Open
@skunkie

Description

@skunkie

🐛 Bug Report

If we use google.protobuf.ListValue, the generated swagger spec specifies items type as object:

"listvalueField": {
  "type": "array",
  "items": {
    "type": "object"
  }
},

Swagger-ui considers it an error, if we pass an array, e.g. of strings:

propKeysystemTagserrorindex0errorParameter string value must be valid JSON

The generated json spec contains:

"listvalueField": {
  "type": "array",
  "items": {
    "type": "object"
  }
},

To Reproduce

  1. Create a proto file:
syntax = "proto3";

package my_service;
option go_package = "./pb";

import "google/protobuf/empty.proto";
import "google/protobuf/struct.proto";

message UpdateItem {
  message Request {
    google.protobuf.ListValue listvalue_field = 1;
  }
}

service MyService {
  rpc UpdateA(UpdateA.Request) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      patch: "/v1/item"
      body: "*"
    };
}
  1. Generate swagger spec with protoc.

Expected behavior

There should be a choice to specify the type for items.

Actual Behavior

The items type is taken from wktSchemas:
https://github.com/grpc-ecosystem/grpc-gateway/blob/v2.16.0/protoc-gen-openapiv2/internal/genopenapi/template.go#L98-L104

Your Environment

OSX Ventura 13.4.1, Go 1.20, [email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions