Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc_gen_swagger: Why protobufListValue type is represented as object? #1106

Closed
mangatmodi opened this issue Jan 3, 2020 · 2 comments
Closed

Comments

@mangatmodi
Copy link

I am using the latest version of grpc-gateway(1.12.1). I have a proto message with field of type google.protobuf.ListValue. protoc-gen-swagger was added support for struct.proto types - #990

However, it generates the following swagger model

  protobufListValue:
    type: object
    properties:
      values:
        type: array
        items:
          $ref: '#/definitions/protobufValue'
        description: Repeated field of dynamically typed values.
    description: |-
      `ListValue` is a wrapper around a repeated field of values.

      The JSON representation for `ListValue` is JSON array.

But this seems wrong as ListValue (as written in comment) is an array. Is there a reason we couldn't generate the following? -

  protobufListValue:
    type: array
    items: {}
    description: |-
      `ListValue` is a wrapper around a repeated field of values.

      The JSON representation for `ListValue` is JSON array.

I understand that, swagger 2.0 doesn't have anyOf support over array, but we could have added examples in the tempalate, rather than using object and then explaining in the description.

@johanbrandhorst
Copy link
Collaborator

Hi! This might make sense - I think I made the original change and I wasn't sure what to do with some of them. If you'd like to submit a PR we can take a look!

@mangatmodi
Copy link
Author

@johanbrandhorst So when I ran locally from this repo, the swagger generation was perfect. I found an issue in my own build process where I was not able to update the dependency.

However, I will raise a PR with an example of struct values in examples/proto/examplepb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants