@openapi-qraft/cli 1.14.0-beta.2 → 1.14.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/CHANGELOG.md +18 -0
- package/README.md +50 -32
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @openapi-qraft/cli
|
|
2
2
|
|
|
3
|
+
## 1.14.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [346a408]
|
|
8
|
+
- @openapi-qraft/plugin@1.14.0-beta.4
|
|
9
|
+
- @openapi-qraft/openapi-typescript-plugin@1.1.0-beta.4
|
|
10
|
+
- @openapi-qraft/tanstack-query-react-plugin@1.14.0-beta.4
|
|
11
|
+
|
|
12
|
+
## 1.14.0-beta.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [c5c4426]
|
|
17
|
+
- @openapi-qraft/plugin@1.14.0-beta.3
|
|
18
|
+
- @openapi-qraft/openapi-typescript-plugin@1.1.0-beta.3
|
|
19
|
+
- @openapi-qraft/tanstack-query-react-plugin@1.14.0-beta.3
|
|
20
|
+
|
|
3
21
|
## 1.14.0-beta.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -27,36 +27,36 @@ Arguments:
|
|
|
27
27
|
input Input OpenAPI Document file path, URL (json, yml) (default: null)
|
|
28
28
|
|
|
29
29
|
Options:
|
|
30
|
-
-o, --output-dir <path>
|
|
31
|
-
-rm, --clean
|
|
32
|
-
--filter-services <glob-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
--
|
|
38
|
-
|
|
39
|
-
--file-header <string>
|
|
40
|
-
--openapi-types-import-path <path>
|
|
41
|
-
--explicit-import-extensions
|
|
42
|
-
--export-openapi-types [bool]
|
|
43
|
-
--operation-generics-import-path <path>
|
|
44
|
-
--openapi-types-file-name <path>
|
|
45
|
-
--enum
|
|
46
|
-
|
|
47
|
-
--
|
|
48
|
-
--
|
|
49
|
-
--
|
|
50
|
-
--
|
|
51
|
-
--
|
|
52
|
-
--
|
|
53
|
-
--
|
|
54
|
-
--
|
|
55
|
-
--
|
|
56
|
-
--
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
|
|
30
|
+
-o, --output-dir <path> Output directory for generated services
|
|
31
|
+
-rm, --clean Clean output directory before generating services
|
|
32
|
+
--filter-services <glob-patterns...> Filter services to be generated by glob pattern. Eg: "/user/**,/post/**". See NPM `micromatch` package for more details.
|
|
33
|
+
--operation-predefined-parameters <patterns...> Predefined parameters for services. The specified services parameters will be optional. Eg: "/**:header.x-monite-version,query.x-api-key" or "get
|
|
34
|
+
/**:header.x-monite-entity-id"
|
|
35
|
+
--operation-name-modifier <patterns...> Modifies operation names using a pattern. Use the `==>` operator to separate the regular expression (left) and the substitution string (right). For
|
|
36
|
+
example: "post /**:[A-Za-z]+Id ==> createOne"
|
|
37
|
+
--postfix-services <string> Postfix to be added to the generated service name (eg: Service)
|
|
38
|
+
--service-name-base <endpoint[<index>] | tags> Use OpenAPI Operation `endpoint[<index>]` path part (e.g.: "/0/1/2") or `tags` as the base name of the service. (default: "endpoint[0]")
|
|
39
|
+
--file-header <string> Header to be added to the generated file (eg: /* eslint-disable */)
|
|
40
|
+
--openapi-types-import-path <path> Path to schema types file (.d.ts), eg: "../schema.d.ts"
|
|
41
|
+
--explicit-import-extensions All import statements will include explicit `.js` extensions. Ideal for projects using ECMAScript modules.
|
|
42
|
+
--export-openapi-types [bool] Export the OpenAPI schema types from the generated `./index.ts` file (default: true)
|
|
43
|
+
--operation-generics-import-path <path> Path to operation generics file (default: "@openapi-qraft/react")
|
|
44
|
+
--openapi-types-file-name <path> OpenAPI Schema types file name, eg: "schema.d.ts" (default: "schema.ts")
|
|
45
|
+
--enum Export true TS enums instead of unions
|
|
46
|
+
--enum-values Export enum values as arrays.
|
|
47
|
+
--dedupe-enums Dedupe enum types when `--enum` is set
|
|
48
|
+
-t, --export-type Export top-level `type` instead of `interface`
|
|
49
|
+
--immutable Generate readonly types
|
|
50
|
+
--additional-properties Treat schema objects as if `additionalProperties: true` is set
|
|
51
|
+
--empty-objects-unknown Generate `unknown` instead of `Record<string, never>` for empty objects
|
|
52
|
+
--default-non-nullable Set to `false` to ignore default values when generating non-nullable types
|
|
53
|
+
--properties-required-by-default Treat schema objects as if `required` is set to all properties by default
|
|
54
|
+
--array-length Generate tuples using array minItems / maxItems
|
|
55
|
+
--path-params-as-types Convert paths to template literal types
|
|
56
|
+
--alphabetize Sort object keys alphabetically
|
|
57
|
+
--exclude-deprecated Exclude deprecated types
|
|
58
|
+
--no-blob-from-binary If this option is enabled, binary format fields will not be converted to Blob types, preserving the native representation
|
|
59
|
+
-h, --help display help for command
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
## Usage example
|
|
@@ -78,13 +78,22 @@ npx openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript http
|
|
|
78
78
|
### Edge-case Options
|
|
79
79
|
|
|
80
80
|
- **`-rm, --clean`:** Clean the specified output directory services before generating to remove stale files _(optional)_.
|
|
81
|
-
- **`--filter-services
|
|
82
|
-
|
|
81
|
+
- **`--filter-services <glob-patterns...>`:** Filter services to be generated by glob pattern _(optional)_.
|
|
82
|
+
- **Pattern syntax:**
|
|
83
|
+
- `<glob-pattern>,<glob-pattern>,...` - comma-separated list of glob patterns. See [`micromatch`](https://github.com/micromatch/micromatch)
|
|
84
|
+
package for more details. More than one pattern can be specified.
|
|
83
85
|
- Examples:
|
|
84
86
|
- `--filter-services '/user/**,/post/**'` - include only API endpoints that start with `/user/` or `/post/`
|
|
85
87
|
- `--filter-services '**,!/internal/**'` - include _all_ API endpoints _except_ those that start with `/internal/`
|
|
86
88
|
- **`--operation-predefined-parameters <patterns...> `:** Predefined parameters for services. The specified services parameters will be optional. _(optional)_
|
|
87
89
|
|
|
90
|
+
- **Pattern syntax:**
|
|
91
|
+
- `<path glob>:<operation parameter>,...`
|
|
92
|
+
- `<method> <path glob>:<operation parameter>,...`
|
|
93
|
+
- Each modifier consists of an _optional_ **method**, a **path glob** pattern,
|
|
94
|
+
a colon, and a comma-separated list of **operation parameters** to be set as optional.
|
|
95
|
+
More than one predefined parameter option can be specified.
|
|
96
|
+
|
|
88
97
|
This most wanted option 💎 allows you to **set default parameters** across multiple endpoints. However, if an endpoint doesn't contain a parameter specified in this option, an error will be displayed. For example:
|
|
89
98
|
|
|
90
99
|
```text
|
|
@@ -112,8 +121,17 @@ npx openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript http
|
|
|
112
121
|
|
|
113
122
|
- **`--operation-name-modifier <patterns...>`:** Modifies operation names using a pattern.
|
|
114
123
|
|
|
124
|
+
- **Pattern syntax:**
|
|
125
|
+
- `<path glob>:<regular expression> ==> <new operation name>`
|
|
126
|
+
- `<method> <path glob>:<regular expression> ==> <new operation name>`
|
|
127
|
+
- Each modifier consists of an _optional_ **method**, a **path glob** pattern,
|
|
128
|
+
a colon, and a **regular expression** that matches the operation name. The part after `==>` is the new operation name.
|
|
129
|
+
More than one modifier option can be specified.
|
|
115
130
|
- Examples:
|
|
116
131
|
- `--operation-name-modifier 'get /**:[A-Za-z]+Id ==> findOne'` - will change all `GET` operations with `Id` suffix to `findOne`.
|
|
132
|
+
- `--operation-name-modifier 'get /**:get(.*) ==> find-$1'` - will change all `GET` operations with `get` prefix to `findById | findAll | ...`.
|
|
133
|
+
- The pattern is a regular expression that matches the operation name.
|
|
134
|
+
- The operation name is converted to Camel Case. Spaces, hyphens, and underscores are removed.
|
|
117
135
|
- `--operation-name-modifier 'put,patch /**:[A-Za-z]+Id ==> updateOne'` - will change all `PUT` and `PATCH` operations with `Id` suffix to `updateOne`.
|
|
118
136
|
- `--operation-name-modifier '/posts,/files:create[a-zA-Z]+ ==> createOne'` - will change all operations under `/posts` and `/files` to `createOne` if the operation name starts with `create`.
|
|
119
137
|
- `--operation-name-modifier 'post /files ==> createOne' 'put /posts ==> updateOne'` - will change all `POST` operations under `/files` to `createOne` and all `PUT` operations under `/posts` to `updateOne`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/cli",
|
|
3
|
-
"version": "1.14.0-beta.
|
|
3
|
+
"version": "1.14.0-beta.4",
|
|
4
4
|
"description": "CLI for generating typed Tanstack Query React Hooks and services from OpenAPI Schemas, improving type safety in React apps",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"openapi-qraft": "./bin.mjs"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@openapi-qraft/openapi-typescript-plugin": "1.1.0-beta.
|
|
19
|
-
"@openapi-qraft/plugin": "1.14.0-beta.
|
|
20
|
-
"@openapi-qraft/tanstack-query-react-plugin": "1.14.0-beta.
|
|
18
|
+
"@openapi-qraft/openapi-typescript-plugin": "1.1.0-beta.4",
|
|
19
|
+
"@openapi-qraft/plugin": "1.14.0-beta.4",
|
|
20
|
+
"@openapi-qraft/tanstack-query-react-plugin": "1.14.0-beta.4",
|
|
21
21
|
"commander": "^11.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|