openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Options for custom template files

Open josh-hemphill opened this issue 2 years ago • 7 comments

Needed something similar to #1268 and decided to create a PR that provides for custom templates for the three main code bits I think anyone would want to replace.

Adds:

    --serviceTemplate <value> Path to custom service handlebars template to generate the service files
    --clientTemplate <value>  Path to custom client handlebars template to generate the client file
    --indexTemplate <value>   Path to custom index handlebars template to generate the index file

josh-hemphill avatar Apr 11 '23 08:04 josh-hemphill

@ferdikoomen I think I've got this working well. I've used my fork for some stuff already. Don't know if more templates might be commonly needed enough that they should be in this PR, please let me know if you'd like me to add more.

josh-hemphill avatar May 01 '23 21:05 josh-hemphill

@ferdikoomen Do you have any feedback or comments on this, I'd like to know if this is something you'd be interested in merging in some form, since some of my teams are already using my fork, and I don't want to forget about this and accidentally leave my fork in for someone else to have to deal with years later. 😜

josh-hemphill avatar May 24 '23 18:05 josh-hemphill

Woops, didn't mean to push those last two. I'll back those out.

josh-hemphill avatar Jun 02 '23 16:06 josh-hemphill

@josh-hemphill I'm curious if you have a sample how to work with these templates that you share?

noneall avatar Sep 29 '23 04:09 noneall

Sure, I've created gists of the template files I've used with trying to generate reactive VueUse useFetch bindings: https://gist.github.com/josh-hemphill/c6b45fad353e82548e27079b59348469 My useFetchPolyfill import is just a copy of VueUse's useFetch code with some modifications since I didn't like how it handled errors. And the the util imports are pretty self explanatory, I think I just pieced those together by slightly deviating from what openapi-typescript-codegen usually does.

josh-hemphill avatar Sep 29 '23 05:09 josh-hemphill

Sure, I've created gists of the template files I've used with trying to generate reactive VueUse useFetch bindings: https://gist.github.com/josh-hemphill/c6b45fad353e82548e27079b59348469 My useFetchPolyfill import is just a copy of VueUse's useFetch code with some modifications since I didn't like how it handled errors. And the the util imports are pretty self explanatory, I think I just pieced those together by slightly deviating from what openapi-typescript-codegen usually does.

nice, thank you Josh

noneall avatar Sep 29 '23 13:09 noneall

I would love this! Any way we can get it merged?

kmahlqvist avatar Oct 16 '23 09:10 kmahlqvist