diff --git a/frontend/orval.config.js b/frontend/orval.config.js index 759eca3e7c65..2e59e42e0649 100644 --- a/frontend/orval.config.js +++ b/frontend/orval.config.js @@ -2,10 +2,8 @@ * How to generate OpenAPI client * * For now we only use generated types (src/openapi/models). - * We will use methods (src/openapi/apis) for new features soon. - * 1. `yarn gen:api` to generate the client - * 2. `rm -rf src/openapi/apis` to remove methods (! except if you want to use some of those) - * 3. clean up `src/openapi/index.ts` imports + * Run `yarn gen:api` to generate the client. + * We may use methods (src/openapi/apis) for new features in the future. */ module.exports = { unleashApi: { @@ -34,5 +32,8 @@ module.exports = { process.env.UNLEASH_OPENAPI_URL || 'http://localhost:4242/docs/openapi.json', }, + hooks: { + afterAllFilesWrite: './scripts/clean_orval_generated.sh', + }, }, }; diff --git a/frontend/scripts/clean_orval_generated.sh b/frontend/scripts/clean_orval_generated.sh index 28d698b59123..c0dc2358c160 100755 --- a/frontend/scripts/clean_orval_generated.sh +++ b/frontend/scripts/clean_orval_generated.sh @@ -5,9 +5,8 @@ rm -rf src/openapi/apis # Remove all but last line from index.ts echo "Cleaning index.ts..." -tail -1 src/openapi/index.ts > index_tmp ; -cat index_tmp > src/openapi/index.ts ; -rm index_tmp +echo "export * from './models';" > src/openapi/index.ts +echo '' >> src/openapi/index.ts echo "Formatting..." yarn fmt