You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
First of all, thank you for the great library !!
I have a specific use case in which I want to create a schema for a case class in which most of the types are known and can be created automatically, for example: String, Int , etc.
But for some other types I want to create a custom schema manually, how can I achieve that?
In addition I want to create a custom schema and change the field name, for example:
case class CusotmClass(unsafeMap: Map[String, Int])
in the json the case class will actually look like the following, instead of "unsafeMap" it will be written "flags".
"flags" : {
"a1" : 1,
"a2" : 2
}
How can I create custom scehma for FiniteDuration ?
Thanks :)
The text was updated successfully, but these errors were encountered:
but in general for case 1 what you need to do is make sure that manually created schemas for your types have been put into an implicit scope when the json schema for the main case class is getting generated
for the 2: there is no way to make code generator generate a json schema model containing renamed field, but you can update the model on your own
say
case class Foo(foo: String)
val fooSchema = Json.objectSchema[Foo].withFieldsUpdated {
case f if f.name == "foo" => f.copy(name = "bar")
}
Hi,
First of all, thank you for the great library !!
I have a specific use case in which I want to create a schema for a case class in which most of the types are known and can be created automatically, for example: String, Int , etc.
But for some other types I want to create a custom schema manually, how can I achieve that?
In addition I want to create a custom schema and change the field name, for example:
case class CusotmClass(unsafeMap: Map[String, Int])
in the json the case class will actually look like the following, instead of "unsafeMap" it will be written "flags".
"flags" : {
"a1" : 1,
"a2" : 2
}
Thanks :)
The text was updated successfully, but these errors were encountered: