-
Notifications
You must be signed in to change notification settings - Fork 162
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
#241, #242 Capture name of product and enum to schema #246
Conversation
Thank you for your work on this! This is a highly sought-after addition to ZIO Schema.
I think you have to use a hidden field inside the map, which stores the typeId for the record. You can see it would affect this: map => DynamicValue.Record(/* extract out type ID from map */, ListMap(map.toSeq: _*)),
record => record.values ++ /* store record type id into map */ The build is still failing, can you please take a look? 🙏 |
override type Accessors[Lens[_, _], Prism[_, _], Traversal[_, _]] = (Lens[(A, B), A], Lens[(A, B), B]) | ||
|
||
val first = "_1" | ||
val second = "_2" |
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 am using these strings as singleton type parameters. If I inline them it fails to compile on 2.12
hey @jdegoes, took me some time to resolve issues for scala 2.12 and 3 but its ready to review now. Please check also the comment I made about extracting strings that I use for singleton types.
|
…ypan/zio-schema into capture_name_of_the_record
This PR implements features #241 and #242. However instead of adding
name
to all records and enums,TypeId
was added so its possible to get fully qualified name like:I am still missing macro schema generation for scala 3 which was recently added (scala 2 works fine)
In order to be able to convert from
Schema.Record
toDynamicValue.Record
and back without loosing informationTypeId
was introduced also onDynamicValue
.Because of that, however, I don't know how to write
Schema
forDynamicValue.Record
as Schema[DynamicValue] describes DynamicValue itself, not underlying untyped data structure. So even though for example DynamicValue is representation ofAddress(street: String, number:Int, postalCode: String)
its Schema is a CaseClass1
As you can see Schema provides a way how to construct data structure, which in this case is DynamicValue, however we don't know the name of data structure that DynamicValue represents (Address) - we just know how to construct it. The same applies also for enums.
Files in
zio-schema-thrift/shared/src/test/scala-2/zio/schema/codec/generated/
were auto generated by new version of Thrift compiler 0.16.0 - no need to be reviewed.