Search code examples
openapi-generator

How to set --enable-post-process-file in openapi-generator CLI for c++ CPP_POST_PROCESS_FILE


I got the following messages every time i generate c++ client from openapi-generator:

[main] INFO  o.o.c.languages.AbstractCppCodegen - Environment variable CPP_POST_PROCESS_FILE not defined so the C++ code may not be properly formatted. To define it, try 'export CPP_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"' (Linux/Mac)
[main] INFO  o.o.c.languages.AbstractCppCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).

[main] WARN  o.o.codegen.DefaultCodegen - The value (generator's option) must be either boolean or string. Default to `false`.

I used the following command to run the generator:

npx openapi-generator generate -i api.yaml -g cpp-restsdk -o  %CD%

How can I fix these messages.


Solution

  • Please use npx @openapitools/openapi-generator-cli instead as https://www.npmjs.com/package/@openapitools/openapi-generator-cli is the official repo of the npm wrapper for openapi-generator.

    To enable post file processing, please add --enable-post-process-file to the command, e.g.

    export CPP_POST_PROCESS_FILE="/usr/local/bin/clang-format -i"
    npx @openapitools/openapi-generator-cli generate -i api.yaml -g cpp-restsdk -o  %CD% --enable-post-process-file