Tag Archives: openai

Changing client generated by openapi-generated-cli tool by modifying templates

I needed to add more derive traits on the enum generated by openapi-generate-cli e.g. strum::EnumIter.

  • First, dump the templates using the following command openapi-generator-cli author template -g rust . This will write templates to the directory out.
  • Now edit the templates inside out directory. I had to add strum to Cargo.mutache and strum::EnumIter inside derive of all pub enum inside model.mustache file.
  • Now regenerate the client using openapi-generator-cli generate -t out -i openapi.json -g rust -o api-client-rs

And you have updated client.

Here are some diffs

86d3b88c268545798a7cf5a917a99052 -- Screenshot of code

PS: I could not get the local version to run on my system. I used the following docker command

    podman run --rm \
        -v $PWD:/local openapitools/openapi-generator-cli generate \
        -i https://beta.oneapi.dognosis.link/api/v1/openapi.json \
        -t /local/templates \
        -g rust \
        -o /local/oneapi-client-rs