oapi-codegen
oapi-codegen copied to clipboard
Load user-templates from URL
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
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.