0

I have a rest-api app I am working on. I run generate-controller on my domain, and a controller is generated, but in other profiles I have been able to "install" the templates that were used and customize them. This profile has no install templates command.

All attempts at doing this with the rest-api profile have been unsuccessful. I exported the templates that are used from the plugin jar and placed them in the file system, in a place grails could find them, but they are not used.

Should it be possible with this profile to customize the templates used for code generation - controller,service, view GSON? If so what does that project setup look like? I am working with a vanilla 4.0.0 rest-api profile project.

Section 10.5.3 in the documentation glosses over this, and contains a dead link to the scaffolding plugin, so it is of no help.

I tried to add the scaffolding plugin to my project build.gradle.

compile "org.grails.plugins:scaffolding"

but then the project won't even run.

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'abstractViewResolver' available

It seems like it ought to be possible to customize the code generation templates in the rest-api profile, but I can't find a working configuration/setup to do it. Any pointers would be greatly appreciated.

When I generate the scaffolding after adding the scaffolding plugin, and run install-templates, it installs the templates for a web profile, rather than rest-api, so they are of little use. And even after doing so, they are not used in generation.

WizardsOfWor
  • 2,974
  • 29
  • 23

1 Answers1

0

Should it be possible with this profile to customize the templates used for code generation - controller,service, view gsps?

It probably should be but I don't think the templates are currently supported in the rest-api profile. I don't think install-templates even exists in that profile by default. You mention GSPs but I would not anticipate that install-templates would generate GSP templates in a rest-api app because by default, there is no GSP support in the rest-api profile.

If so what does that project setup look like?

If support is added for this I would expect the project setup to looks just like a typical rest-api app plus the templates installed below the src folder.

Feel free to submit feature requests at https://github.com/grails-profiles/rest-api/issues and/or pull requests at https://github.com/grails-profiles/rest-api/pulls.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47