-
Notifications
You must be signed in to change notification settings - Fork 6k
Importing pre existing models in generated clients
Sometimes you don't want the codegen to make a model for you--you might want to just include one that already exists in your codebase. Say you already have a User
object and want to reuse that, which has a different model package from the other generated files:
First, indicate that the class is already included by default. This will keep the codegen from trying to generate the class:
override def defaultIncludes = super.defaultIncludes ++ Set("User")
This statement will take the existing defaultIncludes
and add User
to it.
Next, if the User
class is a different package, add an importMapping
to tell the generator to include that import wherever User
is used:
override def importMapping = super.importMapping ++ Map(
"User" -> "com.yourpackage.existingModels.User")
Now the codegen will know what to import from that specific package.
would suggest when compiling to use flag to ignore tests. The tests requires extra dependencies and the compilation might fail due to that.