Skip to content

Work Instruction

Lou edited this page Dec 29, 2022 · 7 revisions

How to generate ts-axios client from our swagger spec ?

  1. Install the tool

      npm install -g @openapitools/openapi-generator-cli

    or using yarn

      yarn add -g @openapitools/openapi-generator-cli
  2. Merge the spec files using openapi-generator-cli

        openapi-generator-cli generate -i <entry point> -g <format> -o <output dir> 

    so my command is:

        openapi-generator-cli generate -i doc\api.yml -g openapi-yaml -o outDir 
  3. Generate ts-axios client using swagger editor

    • Go to swagger editor
    • Open your merged yml file (in the output dir you specified)
    • Click on Generate client menu
    • click on typescript-axios then download the file
  4. Put generated api.ts, base.ts, configuration.ts, index.ts, apis, models in gen/bpClient

  5. Change the BASE_PATH in base.ts as follows

    export const BASE_PATH = (process.env.REACT_APP_BPARTNERS_API_URL || '').replace(/\/+$/, '');

Clone this wiki locally