@@ -12,6 +12,7 @@ Generate TS interfaces, request client, request mock service, enum, type field l
1212
1313* support Swagger2.0/OpenAPI 3.0,3.1 specification
1414* generate TypeScript interface, reuquest client, request mock service, enum, type field label, JSON Schemas
15+ * support work with npx, CLI, Nodejs
1516* support custom request function, Fetch、Axios、UniApp-request、Node.js、XHR client available
1617* support filter generate result by tags
1718* support JSON specification
@@ -100,6 +101,50 @@ generate result:
100101npm run openapi
101102```
102103
104+ ### NPX
105+
106+ ```
107+ npx openapi-ts-request openapi -i ./openapi.json -o ./apis
108+ ```
109+
110+ ### CLI
111+
112+ ```
113+ npm i openapi-ts-request -g
114+ ```
115+
116+ ```
117+ $ openapi --help
118+
119+ Usage: openapi [options]
120+
121+ Options:
122+ -V, --version output the version number
123+ -i, --input <string> OpenAPI specification, can be a path, url (required)
124+ -o, --output <string> Output directory (required)
125+ --requestLibPath <string> custom request lib path, for example: "@/request", "node-fetch"
126+ --allowedTags <string[]> Generate results from allowed tags
127+ --requestOptionsType <string> Custom request method options parameter type (default: "{ [key:
128+ string]: unknown }")
129+ --requestImportStatement <string> custom request import statement, for example: "const request =
130+ require(`@/request`)"
131+ --apiPrefix <string> Custom the prefix of the api path, for example: "api"(variable),
132+ `"api"`(string)
133+ --isDisplayTypeLabel <boolean> Generate label matching type field (default: false) (default: false)
134+ --isGenJsonSchemas <boolean> Generate JSON Schemas (default: false) (default: false)
135+ --mockFolder <string> Mock file path, (default: "./mocks")
136+ --nullable <boolean> null instead of optional (default: false) (default: false)
137+ --isCamelCase <boolean> CamelCase naming of controller files and request client (default: true)
138+ (default: true)
139+ -h, --help display help for command
140+ ```
141+
142+ generate result:
143+
144+ ``` bash
145+ openapi -i ./spec.json -o ./apis
146+ ```
147+
103148## Parameter
104149
105150| props | required | type | default | remark |
@@ -110,7 +155,7 @@ npm run openapi
110155| allowedTags | no | string[ ] | - | generate results from allowed tags |
111156| requestOptionsType | no | string | '{ [ key: string] : unknown }' | custom request method options parameter type |
112157| requestImportStatement | no | string | - | custom request import statement, for example: "const request = require('@/request')" |
113- | apiPrefix | no | string | - | custom the prefix of the api path,例如: 'api'(variable), "'api'"(string) |
158+ | apiPrefix | no | string | - | custom the prefix of the api path, for example: 'api'(variable), "'api'"(string) |
114159| isDisplayTypeLabel | no | boolean | false | generate label matching type field |
115160| isGenJsonSchemas | no | boolean | false | generate JSON Schemas |
116161| mockFolder | no | string | './mocks' | mock file path |
0 commit comments