ng-openapi-gen icon indicating copy to clipboard operation
ng-openapi-gen copied to clipboard

Support for adding custom extra templates to generate things like spec files

Open deniszholob opened this issue 3 years ago • 2 comments

The docs say you can replace templates with your own custom ones, but does the tool support adding custom templates somehow? If not is this something that could be implemented?

deniszholob avatar Jan 20 '22 16:01 deniszholob

Well, adding a custom template means calling from the generator TS code the actual template. To implement additional, we need to know :

  • For which kind of data it is called: one per service? one per models? just a general one?
  • Which context is passed to the template: the service / model / other data to be used in the template
  • Which is the destination filename

So, it is kind of hard to do it too general. Adding configuration to it would also be kind of hard, I think.

Finally, I'm totally out of time to work in this project. So my bet would be for you to fork it and implement the additional template separately.

luisfpg avatar Jan 20 '22 16:01 luisfpg

Context and data could be tetermined if the templates where structured in folders, could be something like

templates
  _partials
    _simple.handlebars
  services
    service.ts.handlebars
    service.spec.ts.handlebars
  models
    model.model.ts.handlebars
    model.enum.ts.handebars
  api.module.ts.handlebars
  base-service.ts.handlebars

Destination filename would be whatever the template is called (would enable to just add in a file that requires no context at all like a custom index or readme)

But yeah looks like its not a simple thing to add....

deniszholob avatar Jan 20 '22 17:01 deniszholob