OpenAPI Generator CLI – Override a single file

This is simple to do, but not obvious from the docs.

First, find the mustache template you want to change.

Then make a folder named for the kind of generator you’re working on, and put the customization there.

When you invoke the generator CLI, use the -t argument with the folder you made – that’s all you have to do.

You only need to add files you change. The CLI calls a Java jar, and this path is added to the classpath prior to anything else, so anything not included in the folder will ultimately still be found.

openapi-generator \
  generate -i openapi.yaml \
  -g java \
  -t ./java \
  --additional-properties="<properties here>" \
  -o ./api-bindings