I have a web service written in Scala. As an input it takes a JSON that gets deserialized to a case class with circe. Sometimes though the definition of some inputs change. I usually add new fields of type Option[T]. It all works ok after all. There are other projects that use definitions if these objects internally.
I have problems with my tests though. I have to add this new field in every constructor invocation I have. And this is painful. I thought about adding
.zero value to the companion object of my model classes and then using
.copy to instantiate object just with the fields I need. But this seems like an overkill.
Another way I see is to use default parameters in the constructor - but then it is possible to miss this parameter in production code. Is there some other way / pattern to do this? I feel like I am just missing something.