@openapi-qraft/cli 1.14.0-beta.3 → 1.14.0-beta.5

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +53 -32
  3. 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.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [0df334b]
8
+ - @openapi-qraft/openapi-typescript-plugin@1.1.0-beta.5
9
+ - @openapi-qraft/plugin@1.14.0-beta.5
10
+ - @openapi-qraft/tanstack-query-react-plugin@1.14.0-beta.5
11
+
12
+ ## 1.14.0-beta.4
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [346a408]
17
+ - @openapi-qraft/plugin@1.14.0-beta.4
18
+ - @openapi-qraft/openapi-typescript-plugin@1.1.0-beta.4
19
+ - @openapi-qraft/tanstack-query-react-plugin@1.14.0-beta.4
20
+
3
21
  ## 1.14.0-beta.3
4
22
 
5
23
  ### Patch Changes
package/README.md CHANGED
@@ -27,36 +27,37 @@ Arguments:
27
27
  input Input OpenAPI Document file path, URL (json, yml) (default: null)
28
28
 
29
29
  Options:
30
- -o, --output-dir <path> Output directory for generated services
31
- -rm, --clean Clean output directory before generating services
32
- --filter-services <glob-pattern> Filter services to be generated by glob pattern. Eg: "/user/**,/post/**". See NPM `micromatch` package for more
33
- details.
34
- --operation-predefined-parameters <patterns...> Predefined parameters for services. The specified services parameters will be optional. Eg:
35
- "/**:header.x-monite-version,query.x-api-key.;/user/**,/post/**:header.x-monite-entity-id"
36
- --postfix-services <string> Postfix to be added to the generated service name (eg: Service)
37
- --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.
38
- (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
- -t, --export-type Export top-level `type` instead of `interface`
47
- --immutable Generate readonly types
48
- --additional-properties Treat schema objects as if `additionalProperties: true` is set
49
- --empty-objects-unknown Generate `unknown` instead of `Record<string, never>` for empty objects
50
- --default-non-nullable Set to `false` to ignore default values when generating non-nullable types
51
- --properties-required-by-default Treat schema objects as if `required` is set to all properties by default
52
- --array-length Generate tuples using array minItems / maxItems
53
- --path-params-as-types Convert paths to template literal types
54
- --alphabetize Sort object keys alphabetically
55
- --exclude-deprecated Exclude deprecated types
56
- --no-blob-from-binary If this option is enabled, binary format fields will not be converted to Blob types, preserving the native
57
- representation
58
- -h, --help display help for command
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
+ --explicit-component-exports Enabling this option will export API components as separate type aliases, alongside `components` interface
60
+ -h, --help display help for command
60
61
  ```
61
62
 
62
63
  ## Usage example
@@ -78,13 +79,22 @@ npx openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript http
78
79
  ### Edge-case Options
79
80
 
80
81
  - **`-rm, --clean`:** Clean the specified output directory services before generating to remove stale files _(optional)_.
81
- - **`--filter-services`:** Filter services to be generated by glob pattern _(optional)_. See [`micromatch`](https://github.com/micromatch/micromatch)
82
- package for more details.
82
+ - **`--filter-services <glob-patterns...>`:** Filter services to be generated by glob pattern _(optional)_.
83
+ - **Pattern syntax:**
84
+ - `<glob-pattern>,<glob-pattern>,...` - comma-separated list of glob patterns. See [`micromatch`](https://github.com/micromatch/micromatch)
85
+ package for more details. More than one pattern can be specified.
83
86
  - Examples:
84
87
  - `--filter-services '/user/**,/post/**'` - include only API endpoints that start with `/user/` or `/post/`
85
88
  - `--filter-services '**,!/internal/**'` - include _all_ API endpoints _except_ those that start with `/internal/`
86
89
  - **`--operation-predefined-parameters <patterns...> `:** Predefined parameters for services. The specified services parameters will be optional. _(optional)_
87
90
 
91
+ - **Pattern syntax:**
92
+ - `<path glob>:<operation parameter>,...`
93
+ - `<method> <path glob>:<operation parameter>,...`
94
+ - Each modifier consists of an _optional_ **method**, a **path glob** pattern,
95
+ a colon, and a comma-separated list of **operation parameters** to be set as optional.
96
+ More than one predefined parameter option can be specified.
97
+
88
98
  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
99
 
90
100
  ```text
@@ -112,12 +122,23 @@ npx openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript http
112
122
 
113
123
  - **`--operation-name-modifier <patterns...>`:** Modifies operation names using a pattern.
114
124
 
125
+ - **Pattern syntax:**
126
+ - `<path glob>:<regular expression> ==> <new operation name>`
127
+ - `<method> <path glob>:<regular expression> ==> <new operation name>`
128
+ - Each modifier consists of an _optional_ **method**, a **path glob** pattern,
129
+ a colon, and a **regular expression** that matches the operation name. The part after `==>` is the new operation name.
130
+ More than one modifier option can be specified.
115
131
  - Examples:
116
132
  - `--operation-name-modifier 'get /**:[A-Za-z]+Id ==> findOne'` - will change all `GET` operations with `Id` suffix to `findOne`.
133
+ - `--operation-name-modifier 'get /**:get(.*) ==> find-$1'` - will change all `GET` operations with `get` prefix to `findById | findAll | ...`.
134
+ - The pattern is a regular expression that matches the operation name.
135
+ - The operation name is converted to Camel Case. Spaces, hyphens, and underscores are removed.
117
136
  - `--operation-name-modifier 'put,patch /**:[A-Za-z]+Id ==> updateOne'` - will change all `PUT` and `PATCH` operations with `Id` suffix to `updateOne`.
118
137
  - `--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
138
  - `--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`.
120
139
 
140
+ - **`--explicit-component-exports`:** Enabling this option will export API components as separate type aliases, alongside `components` interface.
141
+
121
142
  - **`--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. _(optional, default: `endpoint[0]`)_.
122
143
  - Examples:
123
144
  - `--service-name-base endpoint[0]` generates `services/FooService.ts` for the endpoint `/foo/bar/baz`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openapi-qraft/cli",
3
- "version": "1.14.0-beta.3",
3
+ "version": "1.14.0-beta.5",
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.3",
19
- "@openapi-qraft/plugin": "1.14.0-beta.3",
20
- "@openapi-qraft/tanstack-query-react-plugin": "1.14.0-beta.3",
18
+ "@openapi-qraft/openapi-typescript-plugin": "1.1.0-beta.5",
19
+ "@openapi-qraft/plugin": "1.14.0-beta.5",
20
+ "@openapi-qraft/tanstack-query-react-plugin": "1.14.0-beta.5",
21
21
  "commander": "^11.1.0"
22
22
  },
23
23
  "devDependencies": {