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
Wrap coproducts in Option #198
Conversation
This is for compatibility with pbdirect. See 47degrees/pbdirect#30
This way it only affects schemas produced from a protobuf definition, not all schemas.
@@ -50,7 +50,7 @@ object Transform { | |||
case ProtobufF.TEnum(name, symbols, _, _) => TSum(name, symbols.map(SumField.tupled)) | |||
case ProtobufF.TMessage(name, fields, _) => TProduct(name, fields.map(f => Field(f.name, f.tpe, f.indices))) | |||
case ProtobufF.TFileDescriptor(values, _, _) => TContaining(values) | |||
case ProtobufF.TOneOf(_, fields) => TCoproduct(fields.map(_.tpe)) | |||
case ProtobufF.TOneOf(_, fields) => TOption(A.algebra(TCoproduct(fields.map(_.tpe)))) |
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.
Sorry for the noisy diff. This is one of the actual changes.
@@ -197,7 +197,7 @@ object ParseProto { | |||
FieldF.Field( | |||
name = field.getName, | |||
position = field.getNumber, | |||
tpe = repeated[A](fromFieldType(field, files, makeNamedTypesOptional = true)).embed, | |||
tpe = repeated[A](fromFieldType(field, files, makeNamedTypesOptional = false)).embed, |
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.
This is the other change.
@@ -83,7 +83,7 @@ class ProtobufProtocolSpec extends Specification with ScalaCheck { | |||
|@message final case class Book( | |||
| @_root_.pbdirect.pbIndex(1) isbn: _root_.scala.Long, | |||
| @_root_.pbdirect.pbIndex(2) title: _root_.java.lang.String, | |||
| @_root_.pbdirect.pbIndex(3) author: _root_.scala.List[_root_.scala.Option[_root_.com.acme.author.Author]], | |||
| @_root_.pbdirect.pbIndex(3) author: _root_.scala.List[_root_.com.acme.author.Author], |
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.
This is updating the test.
This is so they can be encoded as
oneof
fields in protobuf using pbdirect (see 47degrees/pbdirect#30).Also stop wrapping repeated field elements in Option when parsing protobuf protocols.