oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Load user-templates from URL

Open deefdragon opened this issue 3 years ago • 1 comments

I have a number of smaller services that I generate API for (ideally) using the same custom user templates, all in different repositories. To prevent drift between my customized templates in different services, I would like to be able to set the template with a URL as opposed to the raw template file.

Example:

output: api.gen.go
package: api
output-options:
  skip-prune: true
  user-templates:
    client-with-responses.tmpl: https://raw.githubusercontent.com/deefdragon/oapi-templates/main/templates/client-with-responses.tmpl

deefdragon avatar Dec 20 '22 09:12 deefdragon

This should be easy enough to add in a function here and I would be happy to add it in a PR if acceptable, but I'm a bit unsure A: where to put the new function, and B: what to call it.

I would potentially suggest in pkg/codegen/configuration.go, and to call it GetUserTemplate, but I am open to alternatives.

deefdragon avatar Dec 20 '22 10:12 deefdragon