···73737474## Configuration
75757676-<!-- `openapi-ts` supports loading configuration from a file inside your project root directory. You can either create a `openapi-ts.config.js` file -->
7777-7878-`openapi-ts` supports loading configuration from a file inside your project root directory. You just need to create a `openapi-ts.config.js` file
7676+`openapi-ts` supports loading configuration from a file inside your project root directory. You can either create a `openapi-ts.config.cjs` file
79778078```js
8179/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */
8282-export default {
8080+module.exports = {
8381 input: 'path/to/openapi.json',
8482 output: 'src/client',
8583}
8684```
87858888-<!-- or `openapi-ts.config.ts`
8686+or `openapi-ts.config.mjs`
89879090-```ts
9191-import { defineConfig } from '@nicolas-chaulet/openapi-typescript-codegen';
9292-9393-export default defineConfig({
8888+```js
8989+/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */
9090+export default {
9491 input: 'path/to/openapi.json',
9592 output: 'src/client',
9696-})
9797-``` -->
9393+}
9494+```
9595+9696+Alternatively, you can use `openapi-ts.config.js` and configure the export statement depending on your project setup.
98979998### Formatting
10099101100By default, `openapi-ts` will automatically format your client according to your project configuration. To disable automatic formatting, set `format` to false
102101103103-```ts
104104-import { defineConfig } from '@nicolas-chaulet/openapi-typescript-codegen';
105105-106106-export default defineConfig({
102102+```js
103103+/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */
104104+export default {
107105 format: false,
108106 input: 'path/to/openapi.json',
109107 output: 'src/client',
110110-})
108108+}
111109```
112110113111You can also prevent your client from being processed by formatters by adding your output path to the tool's ignore file (e.g. `.prettierignore`).
···116114117115For performance reasons, `openapi-ts` does not automatically lint your client. To enable this feature, set `lint` to true
118116119119-```ts
120120-import { defineConfig } from '@nicolas-chaulet/openapi-typescript-codegen';
121121-122122-export default defineConfig({
117117+```js
118118+/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */
119119+export default {
123120 input: 'path/to/openapi.json',
124121 lint: true,
125122 output: 'src/client',
126126-})
123123+}
127124```
128125129126You can also prevent your client from being processed by linters by adding your output path to the tool's ignore file (e.g. `.eslintignore`).
···132129133130We do not generate TypeScript [enums](https://www.typescriptlang.org/docs/handbook/enums.html) because they are not standard JavaScript and pose [typing challenges](https://dev.to/ivanzm123/dont-use-enums-in-typescript-they-are-very-dangerous-57bh). If you want to iterate through possible field values without manually typing arrays, you can export enums by running
134131135135-```ts
136136-import { defineConfig } from '@nicolas-chaulet/openapi-typescript-codegen';
137137-138138-export default defineConfig({
132132+```js
133133+/** @type {import('@nicolas-chaulet/openapi-typescript-codegen').UserConfig} */
134134+export default {
139135 enums: true,
140136 input: 'path/to/openapi.json',
141137 output: 'src/client',
142142-})
138138+}
143139```
144140145141This will export your enums as plain JavaScript objects. For example, `Foo` will generate the following
···170166 --exportCore <value> Write core files to disk (default: true)
171167 --exportServices <value> Write services to disk [true, false, regexp] (default: true)
172168 --exportModels <value> Write models to disk [true, false, regexp] (default: true)
173173- --exportSchemas <value> Write schemas to disk (default: false)
169169+ --exportSchemas <value> Write schemas to disk (default: true)
174170 --format Process output folder with formatter?
175171 --no-format Disable processing output folder with formatter
176172 --lint Process output folder with linter?