You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
English | <ahref="https://github.com/openapi-ui/openapi-ts-request/blob/master/README.md">简体中文</a>
5
+
English | <ahref="https://github.com/openapi-ui/openapi-ts-request/blob/master/README.md">简体中文</a>
8
6
9
7
Generate TS interfaces, request client, request mock service, enum, type field label, JSON Schemas based on [Swagger2/OpenAPI3](https://swagger.io/blog/news/whats-new-in-openapi-3-0/) specification
10
8
11
9
## Features
12
10
13
-
* support Swagger2.0/OpenAPI 3.0,3.1 specification
14
-
* generate TypeScript interface, reuquest client, request mock service, enum, type field label, JSON Schemas
15
-
* support work with npx, CLI, Nodejs
16
-
* support custom request function, Fetch、Axios、UniApp-request、Node.js、XHR client available
17
-
* support filter generate result by tags
18
-
* support JSON specification
11
+
- support Swagger2.0/OpenAPI 3.0,3.1 specification
12
+
- generate TypeScript interface, reuquest client, request mock service, enum, type field label, JSON Schemas
13
+
- support work with npx, CLI, Nodejs
14
+
- support custom request function, Fetch、Axios、UniApp-request、Node.js、XHR client available
15
+
- support filter generate result by tags
16
+
- support JSON specification
19
17
20
18
## Usage
21
19
@@ -29,21 +27,22 @@ pnpm i openapi-ts-request -D
29
27
30
28
### CosmiConfig
31
29
32
-
create ```openapi-ts-request.config.ts``` file in the project root directory
33
-
> 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)
30
+
create `openapi-ts-request.config.ts` file in the project root directory
31
+
32
+
> 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)
| customFunctionName | (data: APIDataType) => string| custom request client function name |
183
-
| customTypeName | (data: APIDataType) => string | custom type name |
184
-
| customClassName | (tagName: string) => string| custom tag name |
185
-
| customType | (<br>schemaObject: SchemaObject \| ReferenceObject,<br>namespace: string,<br>originGetType:(schemaObject: SchemaObject \| ReferenceObject, namespace: string) => string,<br>) => string | custom type <br> *returning a non-string will use the default method to get the type*|
186
-
| customFileNames |(<br>operationObject: OperationObject,<br>apiPath: string,<br>apiMethod: string,<br>) => string[]| custom generate request client controller file name, can return multiple: generate multiple files. <br> *if the return value is empty, the default getFileNames is used*|
| customFunctionName | (data: APIDataType) => string | custom request client function name |
182
+
| customTypeName | (data: APIDataType) => string | custom type name |
183
+
| customClassName | (tagName: string) => string | custom tag name |
184
+
| customType | (<br>schemaObject: SchemaObject \| ReferenceObject,<br>namespace: string,<br>originGetType:(schemaObject: SchemaObject \| ReferenceObject, namespace: string) => string,<br>) => string | custom type <br> _returning a non-string will use the default method to get the type_|
185
+
| customFileNames |(<br>operationObject: OperationObject,<br>apiPath: string,<br>apiMethod: string,<br>) => string[]| custom generate request client controller file name, can return multiple: generate multiple files. <br> _if the return value is empty, the default getFileNames is used_|
187
186
188
187
## JSON Schemas
189
188
190
189
- default generate JSON Schemas based on [components.schemas](https://spec.openapis.org/oas/latest.html#components-object), JSON Schemas corresponding to [paths](https://spec.openapis.org/oas/latest.html#paths-object) currently need to be parsed by yourself
191
190
- provide a schema parsing function to fill the references of `$ref` and `$allOf` into `current schema`
0 commit comments