|
|
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:
|
|
|
First, indicate that the class is already included by default. This will keep the codegen from trying to generate the class.
|
|
|
|
|
|
```scala
|
|
|
override def defaultIncludes = super.defaultIncludes ++ Set("User")
|
|
|
```bash
|
|
|
--language-specific-primitives=Pet
|
|
|
```
|
|
|
|
|
|
This statement will take the existing `defaultIncludes` and add `User` to it.
|
|
|
This command line option will tell the generator to consider `Pet` a "primitive" type.
|
|
|
|
|
|
Next, if the `User` class is a different package, add an `importMapping` to tell the generator to include that import wherever `User` is used:
|
|
|
Next, if the `Pet` class is a different package, add an `--import-mapping` to tell the generator to include that import wherever `Pet` is used:
|
|
|
|
|
|
```scala
|
|
|
override def importMapping = super.importMapping ++ Map(
|
|
|
"User" -> "com.yourpackage.existingModels.User")
|
|
|
```bash
|
|
|
--import-mappings=Pet=com.yourpackage.models.Pet
|
|
|
```
|
|
|
|
|
|
Now the codegen will know what to import from that specific package. |
|
|
\ No newline at end of file |
|
|
Now the codegen will know what to import from that specific package.
|
|
|
|
|
|
NOTE: `import-mappings` is assigned a key-value pair in this example, but multiple values can be comma-separate. For instance:
|
|
|
|
|
|
```bash
|
|
|
--import-mappings=Pet=com.yourpackage.models.Pet,User=com.yourpackage.models.User
|
|
|
``` |