cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
404 stars 134 forks source link

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

Open deniszholob opened 2 years ago

deniszholob commented 2 years ago

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?

luisfpg commented 2 years ago

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

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.

deniszholob commented 2 years ago

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....