-
Notifications
You must be signed in to change notification settings - Fork 153
Fix repeated enum field generate [[]] into typespec #140
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
Fix repeated enum field generate [[]] into typespec #140
Conversation
| def enum_to_spec(:TYPE_SINT64), do: "integer" | ||
| def enum_to_spec(_), do: "any" | ||
| def enum_to_spec(:TYPE_MESSAGE, type, true = _repeated), do: "#{type}.t" | ||
| def enum_to_spec(:TYPE_MESSAGE, type, true = _repeated), do: "[#{type}.t]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just see that message type doesn't add | nil into generated type. Should we need to add into this patch?
whatyouhide
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @wingyplus , sorry for the long wait! Could you rebase this on the master branch?
|
|
||
| defp fmt_type(%{label: "repeated", type_enum: type_enum, type: type}) do | ||
| "[#{type_to_spec(type_enum, type, true)}]" | ||
| "#{type_to_spec(type_enum, type, true)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be 👇 now?
| "#{type_to_spec(type_enum, type, true)}" | |
| type_to_spec(type_enum, type, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@whatyouhide This comment is apply. :)
Removing [] out of Protobuf.Protoc.Generator.Message.fmt_type/1 and add [] into Protobuf.TypeUtil.enum_to_spec/3 when TYPE_MESSAGE is match alongs with repeated true. Fixes elixir-protobuf#132
1f61714 to
61e50f9
Compare
|
@whatyouhide thank you for reviewing my changes. The PR already rebase and apply your suggestion. Please kindly review again. |
Removing
[]out ofProtobuf.Protoc.Generator.Message.fmt_type/1andadd
[]intoProtobuf.TypeUtil.enum_to_spec/3whenTYPE_MESSAGEis matchalongs with repeated true.
Fixes #132