Skip to content

Commit c15d6d6

Browse files
committed
docs: 更新文档-关于 defineConfig & options.describe
1 parent f3ade51 commit c15d6d6

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

README-en_US.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,28 @@ create `openapi-ts-request.config.ts` file in the project root directory
4545
> the config file also supports **_.openapi-ts-request.ts_**, **_openapi-ts-request.config.cjs_** format, reference [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#cosmiconfig)
4646
4747
```ts
48-
import type { GenerateServiceProps } from 'openapi-ts-request';
48+
import { defineConfig } from 'openapi-ts-request';
4949

50-
export default {
51-
// schemaPath: './openapi.json', // local openapi file
52-
// serversPath: './src/apis', // interface storage path
50+
export default defineConfig({
5351
schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
54-
} as GenerateServiceProps;
52+
serversPath: './src/apis',
53+
});
54+
55+
//
56+
57+
// import type { GenerateServiceProps } from 'openapi-ts-request';
58+
59+
// export default {
60+
// schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
61+
// } as GenerateServiceProps;
5562
```
5663

5764
support passing in array config for generate
5865

5966
```ts
60-
import type { GenerateServiceProps } from 'openapi-ts-request';
67+
import { defineConfig } from 'openapi-ts-request';
6168

62-
export default [
69+
export default defineConfig([
6370
{
6471
schemaPath: 'http://app.swagger.io/v2/swagger.json',
6572
serversPath: './src/apis/app',
@@ -68,7 +75,22 @@ export default [
6875
schemaPath: 'http://auth.swagger.io/v2/swagger.json',
6976
serversPath: './src/apis/auth',
7077
},
71-
] as GenerateServiceProps[];
78+
]);
79+
80+
// or
81+
82+
// import type { GenerateServiceProps } from 'openapi-ts-request';
83+
84+
// export default [
85+
// {
86+
// schemaPath: 'http://app.swagger.io/v2/swagger.json',
87+
// serversPath: './src/apis/app',
88+
// },
89+
// {
90+
// schemaPath: 'http://auth.swagger.io/v2/swagger.json',
91+
// serversPath: './src/apis/auth',
92+
// },
93+
// ] as GenerateServiceProps[];
7294
```
7395

7496
add the command in `script` of `package.json`: `"openapi": "openapi-ts",`
@@ -229,6 +251,7 @@ openapi -i ./spec.json -o ./apis
229251
| serversPath | no | string | './src/apis' | the folder path for the run results |
230252
| requestLibPath | no | string | 'axios' | custom request lib path, for example: '@/request', 'node-fetch' |
231253
| full | no | boolean | true | full replacement |
254+
| describe | no | string | - | description information, which will be used when using cli interactive operation mode |
232255
| enableLogging | no | boolean | false | open the log |
233256
| priorityRule | no | string | 'include' | priority rule, include/exclude/both |
234257
| filterCaseInsensitive | no | boolean | false | whether to perform a case-insensitive match with includeTags, includePaths, excludeTags, excludePaths filters |

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ openapi --i ./spec.json --o ./apis
291291
| customTemplates | {<br>[TypescriptFileType.serviceController]?: <T, U>(item: T, context: U) => string;<br>} | 自定义模板,详情请看源码 |
292292
| customRenderTemplateData | {<br>[TypescriptFileType]?: (list: any[], context: {fileName: string, params: Record<string, unknown>}) => any[]<br>} | 自定义文件生成时的 list 参数处理,支持对不同文件类型进行精细化控制 |
293293

294+
[hooks 示例](https://github.com/openapi-ui/openapi-ts-request/blob/main/agents.md#-advanced-customization-hooks)
295+
294296
## Apifox-Config
295297

296298
| 属性 | 类型 | 说明 | 必填 |
@@ -368,7 +370,8 @@ export default {
368370
4. 确保你的代码可以通过所有测试用例(新增功能需要添加新的功能测试用例):`pnpm test:unit`
369371
5. 创建 changeset 文件通过命令:`pnpm changeset`
370372
6. 使用 commit 提交你的修改(需遵循 commitlint 规范)
371-
7. 发起 Pull Request
373+
7. 如果涉及文档,请同步更新 README.md、READMD-en_US.md、agents.md
374+
8. 发起 Pull Request
372375

373376
## 感谢
374377

agents.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ else if (isNodeProject) {
102102
| `namespace` | string | `"API"` | TypeScript namespace | Custom namespace |
103103
| `templatesFolder` | string | - | Custom template directory | Custom templates |
104104
| `apifoxConfig` | object | - | Apifox-specific configuration | Apifox integration |
105+
| `describe` | string | - | description information | Using cli interactive operation mode |
105106

106107
### 3. Feature Requirements Mapping
107108

0 commit comments

Comments
 (0)