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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

an google.protobuf.Any type how to get openapiv2 output? #4135

Closed
dobet opened this issue Mar 25, 2024 · 1 comment
Closed

an google.protobuf.Any type how to get openapiv2 output? #4135

dobet opened this issue Mar 25, 2024 · 1 comment

Comments

@dobet
Copy link

dobet commented Mar 25, 2024

馃殌 Feature

(A clear and concise description of what the feature is.)
I have an field

message Test1 {
    string name = 1;
}

message Test2 {
    repeated string names = 1;
}

message Reply {
    google.protobuf.Any Data = 1;
}

sometimes Reply.Data is Test2.name, sometime Reply.Data is names,
when I gen openapi.json, Reply.Data is error .

What can I do?

@johanbrandhorst
Copy link
Collaborator

Hi, thanks for your issue. google.protobuf.Any fields are not great for JSON translation. You may want something like google.protobuf.Struct instead - this type allows arbitrary JSON. Note that it's not a great experience for users (as you noticed). I recommend having strictly typed responses for each endpoint, instead of one that varies.

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