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

Optional fields in proto2 files #1300

Closed
randm-ch opened this issue Sep 15, 2021 · 2 comments
Closed

Optional fields in proto2 files #1300

randm-ch opened this issue Sep 15, 2021 · 2 comments

Comments

@randm-ch
Copy link

A proto definition

message UnlockEvent {
    optional string eventId = 1;
}

compiles to

final case class UnlockEvent(@_root_.pbdirect.pbIndex(1) eventId: _root_.java.lang.String)

whereas I would expect it to be

final case class UnlockEvent(@_root_.pbdirect.pbIndex(1) eventId: _root_.scala.Option[_root_.java.lang.String])

Is there an option for this (haven't found anything in the docs)? It works correctly if using another message BTW:

message EventId {
    string value = 1;
}

message UnlockEvent {
    optional EventId eventId = 1;
}

will result in Option[EventId] correctly.

Using addSbtPlugin("io.higherkindness" % "sbt-mu-srcgen" % "0.26.0"). Thanks!

@fedefernandez
Copy link
Contributor

fedefernandez commented Sep 17, 2021

hi @randm-ch,

sbt-mu-srcgen uses skeumorph by default for the source generation. There's an issue related to this:

You can use avrohugger for the code generation through the SBT setting key muSrcGenAvroGeneratorType. Take a look to the documentation.

If I'm not wrong, you shouldn't have that problem with avrohugger.

@randm-ch
Copy link
Author

Thanks for the explaination and the workaround. Closing the issue.

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