Closed adamw closed 5 years ago
Circe has KeyEncoder
and KeyDecoder
for that use case. Maybe we can use it in circe modules or define something similar in the core module and add a derivation to/from corresponding circe typeclasses.
https://circe.github.io/circe/codecs/custom-codecs.html#custom-key-types
I did a first version of this generation which is to generate schemas for Map[String, _]
Regarding other types of keys support and keyEncoder
approach. We already have similar situation with oneOf
macro where we are forcing users to provide asString: A => String
converting method. If we decide to implement something like keyEncoder
, we should apply this pattern to both places.
@guersam generating circe encoders/decoders from a schema is a whole other story, but definitely worth investigating at some point :) Or event better - replacing the whole thing with sth like https://github.com/scalaz/scalaz-schema
The default schema for
Map
should be an object without arbitrary fields. Alternatively: only forMap[String, V]
for anyV
.Such a schema should also be properly generated in the docs.