ts-openapi-codegen 2.1.0-beta.2 → 2.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/README.rus.md +16 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
- Supports tsc and @babel/plugin-transform-typescript
|
|
29
29
|
- Supports customization names of models
|
|
30
30
|
- Supports external references using [`swagger-parser`](https://github.com/APIDevTools/swagger-parser/)
|
|
31
|
+
- Supports strict OpenAPI diagnostics with JSON reports (`--strict-openapi`, `--report-file`)
|
|
32
|
+
- Supports generator plugins (`plugins`) including built-in `x-typescript-type`
|
|
31
33
|
- Supports binary request/response generation (`format: binary` -> `Blob`)
|
|
32
34
|
|
|
33
35
|
## Install
|
|
@@ -82,6 +84,8 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
82
84
|
| `--modelsMode` | - | string | `interfaces` | Models generation mode: `interfaces` or `classes` |
|
|
83
85
|
| `--useHistory` | - | boolean | `false` | Apply diff report annotations during generation |
|
|
84
86
|
| `--diffReport` | - | string | `./openapi-diff-report.json` | Path to diff report JSON |
|
|
87
|
+
| `--useProjectPrettier` | - | boolean | `false` | Use the project’s Prettier config to format generated code |
|
|
88
|
+
| `--useEslintFix` | - | boolean | `false` | Run ESLint `--fix` on generated files after write (requires `eslint` in the project) |
|
|
85
89
|
|
|
86
90
|
**Examples:**
|
|
87
91
|
```bash
|
|
@@ -244,7 +248,9 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
244
248
|
"enabled": true,
|
|
245
249
|
"confidence": 1,
|
|
246
250
|
"types": ["RENAME", "TYPE_COERCION"]
|
|
247
|
-
}
|
|
251
|
+
},
|
|
252
|
+
"plugins": ["./plugins/custom-type.plugin.cjs"],
|
|
253
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
248
254
|
}
|
|
249
255
|
```
|
|
250
256
|
|
|
@@ -295,6 +301,7 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
295
301
|
| `useUnionTypes` | boolean | `false` | Use union types instead of enums |
|
|
296
302
|
| `excludeCoreServiceFiles` | boolean | `false` | Exclude core and service files generation |
|
|
297
303
|
| `request` | string | - | Path to custom request file |
|
|
304
|
+
| `plugins` | string[] | `[]` | Paths to generator plugins |
|
|
298
305
|
| `customExecutorPath` | string | - | Path to custom `createExecutorAdapter` module |
|
|
299
306
|
| `interfacePrefix` | string | `I` | Prefix for interface models |
|
|
300
307
|
| `enumPrefix` | string | `E` | Prefix for enum models |
|
|
@@ -316,6 +323,14 @@ Instead of passing all options via CLI, you can use a configuration file. Create
|
|
|
316
323
|
|
|
317
324
|
**Note:** You can use the `init` command to generate a template configuration file.
|
|
318
325
|
|
|
326
|
+
### Plugins
|
|
327
|
+
|
|
328
|
+
Generator plugins can override schema type mapping (for example via `x-typescript-type`) and extend generation behavior.
|
|
329
|
+
|
|
330
|
+
- Configuration key: `plugins` (array of module paths)
|
|
331
|
+
- Supported module formats: CJS, ESM, and TS (when runtime supports TS imports)
|
|
332
|
+
- Full guide: [docs/plugins.md](./docs/plugins.md)
|
|
333
|
+
|
|
319
334
|
## Examples
|
|
320
335
|
|
|
321
336
|
### Using CLI commands
|
package/README.rus.md
CHANGED
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
- Поддерживает tsc и @babel/plugin-transform-typescript
|
|
29
29
|
- Поддерживает кастомизацию имен моделей
|
|
30
30
|
- Поддерживает внешние ссылки с помощью [`swagger-parser`](https://github.com/APIDevTools/swagger-parser/)
|
|
31
|
+
- Поддерживает strict-диагностику OpenAPI с JSON-отчетом (`--strict-openapi`, `--report-file`)
|
|
32
|
+
- Поддерживает плагины генератора (`plugins`), включая встроенный `x-typescript-type`
|
|
31
33
|
- Поддерживает генерацию бинарных request/response (`format: binary` -> `Blob`)
|
|
32
34
|
|
|
33
35
|
## Установка
|
|
@@ -81,6 +83,8 @@ openapi generate --input ./spec.json --output ./dist
|
|
|
81
83
|
| `--modelsMode` | - | string | `interfaces` | Режим генерации моделей: `interfaces` или `classes` |
|
|
82
84
|
| `--useHistory` | - | boolean | `false` | Применять diff-отчёт при генерации |
|
|
83
85
|
| `--diffReport` | - | string | `./openapi-diff-report.json` | Путь к diff-отчёту |
|
|
86
|
+
| `--useProjectPrettier` | - | boolean | `false` | Форматировать сгенерированный код конфигом Prettier проекта |
|
|
87
|
+
| `--useEslintFix` | - | boolean | `false` | Запускать ESLint `--fix` для сгенерированных файлов после записи (нужен `eslint` в проекте) |
|
|
84
88
|
|
|
85
89
|
**Примеры:**
|
|
86
90
|
```bash
|
|
@@ -243,7 +247,9 @@ openapi analyze-diff --input ./openapi/spec.yaml --git HEAD~1
|
|
|
243
247
|
"enabled": true,
|
|
244
248
|
"confidence": 1,
|
|
245
249
|
"types": ["RENAME", "TYPE_COERCION"]
|
|
246
|
-
}
|
|
250
|
+
},
|
|
251
|
+
"plugins": ["./plugins/custom-type.plugin.cjs"],
|
|
252
|
+
"customExecutorPath": "./custom/createExecutorAdapter.ts"
|
|
247
253
|
}
|
|
248
254
|
```
|
|
249
255
|
|
|
@@ -294,6 +300,7 @@ openapi analyze-diff --input ./openapi/spec.yaml --git HEAD~1
|
|
|
294
300
|
| `useUnionTypes` | boolean | `false` | Использовать union типы вместо enums |
|
|
295
301
|
| `excludeCoreServiceFiles` | boolean | `false` | Исключить генерацию core и сервисных файлов |
|
|
296
302
|
| `request` | string | - | Путь к пользовательскому файлу запросов |
|
|
303
|
+
| `plugins` | string[] | `[]` | Пути к плагинам генератора |
|
|
297
304
|
| `customExecutorPath` | string | - | Путь к пользовательскому модулю `createExecutorAdapter` |
|
|
298
305
|
| `interfacePrefix` | string | `I` | Префикс для интерфейсов моделей |
|
|
299
306
|
| `enumPrefix` | string | `E` | Префикс для enum моделей |
|
|
@@ -315,6 +322,14 @@ openapi analyze-diff --input ./openapi/spec.yaml --git HEAD~1
|
|
|
315
322
|
|
|
316
323
|
**Примечание:** Вы можете использовать команду `init` для генерации шаблона файла конфигурации.
|
|
317
324
|
|
|
325
|
+
### Плагины
|
|
326
|
+
|
|
327
|
+
Плагины генератора позволяют переопределять маппинг типов схем (например через `x-typescript-type`) и расширять поведение генерации.
|
|
328
|
+
|
|
329
|
+
- Ключ конфигурации: `plugins` (массив путей к модулям)
|
|
330
|
+
- Поддерживаемые форматы модулей: CJS, ESM и TS (если рантайм поддерживает импорт TS)
|
|
331
|
+
- Подробная документация: [docs/plugins.md](./docs/plugins.md)
|
|
332
|
+
|
|
318
333
|
## Примеры
|
|
319
334
|
|
|
320
335
|
### Использование CLI команд
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-openapi-codegen",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.4",
|
|
4
4
|
"description": "Library that generates Typescript clients based on the OpenAPI specification. It bases on openapi-typescript-codegen",
|
|
5
5
|
"author": "Alexey Zverev",
|
|
6
6
|
"homepage": "https://github.com/ozonophore/openapi-codegen.git",
|