openapi-ts-request 0.4.5 → 0.4.6
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 +17 -14
- package/dist/bin/openapi.js +10 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,14 +33,18 @@ pnpm i openapi-ts-request -D
|
|
|
33
33
|
> 配置文件还支持 ***.openapi-ts-request.ts***, ***openapi-ts-request.config.cjs*** 等格式,参考 [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#cosmiconfig)
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
|
+
import type { GenerateServiceProps } from 'openapi-ts-request'
|
|
37
|
+
|
|
36
38
|
export default {
|
|
37
39
|
schemaPath: 'http://petstore.swagger.io/v2/swagger.json',
|
|
38
|
-
}
|
|
40
|
+
} as GenerateServiceProps
|
|
39
41
|
```
|
|
40
42
|
|
|
41
43
|
支持传入数组配置进行生成
|
|
42
44
|
|
|
43
45
|
```ts
|
|
46
|
+
import type { GenerateServiceProps } from 'openapi-ts-request'
|
|
47
|
+
|
|
44
48
|
export default [
|
|
45
49
|
{
|
|
46
50
|
schemaPath: 'http://app.swagger.io/v2/swagger.json',
|
|
@@ -50,7 +54,7 @@ export default [
|
|
|
50
54
|
schemaPath: 'http://auth.swagger.io/v2/swagger.json',
|
|
51
55
|
serversPath: './src/apis/auth',
|
|
52
56
|
}
|
|
53
|
-
]
|
|
57
|
+
] as GenerateServiceProps[]
|
|
54
58
|
```
|
|
55
59
|
|
|
56
60
|
在 ```package.json``` 的 ```script``` 中添加命令: ```"openapi": "openapi-ts",```
|
|
@@ -129,21 +133,20 @@ $ openapi --help
|
|
|
129
133
|
Options:
|
|
130
134
|
-V, --version output the version number
|
|
131
135
|
-i, --input <string> OpenAPI specification, can be a path, url (required)
|
|
132
|
-
-o, --output <string>
|
|
136
|
+
-o, --output <string> output directory (required)
|
|
133
137
|
--requestLibPath <string> custom request lib path, for example: "@/request", "node-fetch"
|
|
134
|
-
--allowedTags <string[]>
|
|
135
|
-
--requestOptionsType <string>
|
|
138
|
+
--allowedTags <string[]> generate results from allowed tags
|
|
139
|
+
--requestOptionsType <string> custom request method options parameter type (default: "{ [key:
|
|
136
140
|
string]: unknown }")
|
|
137
141
|
--requestImportStatement <string> custom request import statement, for example: "const request =
|
|
138
|
-
require(
|
|
139
|
-
--apiPrefix <string>
|
|
140
|
-
|
|
141
|
-
--isDisplayTypeLabel <boolean>
|
|
142
|
-
--isGenJsonSchemas <boolean>
|
|
143
|
-
--mockFolder <string>
|
|
144
|
-
--nullable <boolean> null instead of optional (default: false)
|
|
145
|
-
--isCamelCase <boolean>
|
|
146
|
-
(default: true)
|
|
142
|
+
require('@/request')"
|
|
143
|
+
--apiPrefix <string> custom the prefix of the api path, for example: "api"(variable),
|
|
144
|
+
"'api'"(string)
|
|
145
|
+
--isDisplayTypeLabel <boolean> generate label matching type field (default: false)
|
|
146
|
+
--isGenJsonSchemas <boolean> generate JSON Schemas (default: false)
|
|
147
|
+
--mockFolder <string> mock file path (default: "./mocks")
|
|
148
|
+
--nullable <boolean> null instead of optional (default: false)
|
|
149
|
+
--isCamelCase <boolean> camelCase naming of controller files and request client (default: true)
|
|
147
150
|
-h, --help display help for command
|
|
148
151
|
```
|
|
149
152
|
|
package/dist/bin/openapi.js
CHANGED
|
@@ -11,17 +11,17 @@ const params = commander_1.program
|
|
|
11
11
|
.usage('[options]')
|
|
12
12
|
.version(pkg.version)
|
|
13
13
|
.requiredOption('-i, --input <string>', 'OpenAPI specification, can be a path, url (required)')
|
|
14
|
-
.requiredOption('-o, --output <string>', '
|
|
14
|
+
.requiredOption('-o, --output <string>', 'output directory (required)')
|
|
15
15
|
.option('--requestLibPath <string>', 'custom request lib path, for example: "@/request", "node-fetch"')
|
|
16
|
-
.option('--allowedTags <string[]>', '
|
|
17
|
-
.option('--requestOptionsType <string>', '
|
|
18
|
-
.option('--requestImportStatement <string>',
|
|
19
|
-
.option('--apiPrefix <string>',
|
|
20
|
-
.option('--isDisplayTypeLabel <boolean>', '
|
|
21
|
-
.option('--isGenJsonSchemas <boolean>', '
|
|
22
|
-
.option('--mockFolder <string>', 'Mock file path
|
|
23
|
-
.option('--nullable <boolean>', 'null instead of optional
|
|
24
|
-
.option('--isCamelCase <boolean>', '
|
|
16
|
+
.option('--allowedTags <string[]>', 'generate results from allowed tags')
|
|
17
|
+
.option('--requestOptionsType <string>', 'custom request method options parameter type (default: "{ [key: string]: unknown }")')
|
|
18
|
+
.option('--requestImportStatement <string>', `custom request import statement, for example: "const request = require('@/request')"`)
|
|
19
|
+
.option('--apiPrefix <string>', `custom the prefix of the api path, for example: "api"(variable), "'api'"(string)`)
|
|
20
|
+
.option('--isDisplayTypeLabel <boolean>', 'generate label matching type field', false)
|
|
21
|
+
.option('--isGenJsonSchemas <boolean>', 'generate JSON Schemas', false)
|
|
22
|
+
.option('--mockFolder <string>', 'Mock file path (default: "./mocks")')
|
|
23
|
+
.option('--nullable <boolean>', 'null instead of optional', false)
|
|
24
|
+
.option('--isCamelCase <boolean>', 'camelCase naming of controller files and request client', true)
|
|
25
25
|
.parse(process.argv)
|
|
26
26
|
.opts();
|
|
27
27
|
function getPath(path) {
|
package/package.json
CHANGED