Platformics supports replacing one codegen template with another, either globally or for a specific type.
- Find the template that you want to replace in the base platformics template directory
- Create a directory that will contain your overriden templates, such as
template_overrides
- Copy that template to your overrides directory with the same path relative to
templates
in the platformics repo. For example, if you want to overrideplatformics/codegen/templates/database/models/class_name.py.j2
, copy it totemplate_overrides/database/models/class_name.py.j2
- Modify the template as much as you want
- When you run codegen, include the overrides folder as a parameter to the codegen tool. For example, update the
codegen
target in theMakefile
for your project directory to look like:$(docker_compose_run) $(APP_CONTAINER) platformics api generate --schemafile ./schema/schema.yaml --template-override-paths template_overrides --output-prefix .
- Find the template that you want to replace in the base platformics template directory. Note that this only works for files named
class_name.*
! - Create a directory that will contain your overriden templates, such as
template_overrides
- Copy that template to your overrides directory with the same path relative to
templates
in the platformics repo, but the filename needs to reflect the camel_case class name. For example, if you want to overrideplatformics/codegen/templates/database/models/class_name.py.j2
, for a class calledMyData
, copy it totemplate_overrides/database/models/my_data.py.j2
- Modify the template as much as you want
- When you run codegen, include the overrides folder as a parameter to the codegen tool. For example, update the
codegen
target in theMakefile
for your project directory to look like:$(docker_compose_run) $(APP_CONTAINER) platformics api generate --schemafile ./schema/schema.yaml --template-override-paths template_overrides --output-prefix .