swaggie 1.0.2-test.3 → 1.0.2-test.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.
- package/README.md +7 -7
- package/dist/cli.js +4 -1
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
- package/templates/{tanstack-query → tsq-xior}/queryOperation.ejs +6 -3
- /package/templates/{tanstack-query → tsq-xior}/barrel.ejs +0 -0
- /package/templates/{tanstack-query → tsq-xior}/baseClient.ejs +0 -0
- /package/templates/{tanstack-query → tsq-xior}/client.ejs +0 -0
- /package/templates/{tanstack-query → tsq-xior}/operation.ejs +0 -0
package/README.md
CHANGED
|
@@ -116,13 +116,13 @@ Sample configuration looks like this:
|
|
|
116
116
|
The following templates are bundled with Swaggie:
|
|
117
117
|
|
|
118
118
|
```
|
|
119
|
-
axios
|
|
120
|
-
xior
|
|
121
|
-
swr-axios
|
|
122
|
-
|
|
123
|
-
fetch
|
|
124
|
-
ng1
|
|
125
|
-
ng2
|
|
119
|
+
axios Default template. Recommended for React / Vue / similar frameworks. Uses axios
|
|
120
|
+
xior Lightweight and modern alternative to axios. Uses [xior](https://github.com/suhaotian/xior#intro)
|
|
121
|
+
swr-axios SWR for GET requests with axios as backend
|
|
122
|
+
tsq-xior TanStack Query for GET requests with xior as backend
|
|
123
|
+
fetch Barebone fetch API. Recommended for React / Vue / similar frameworks
|
|
124
|
+
ng1 Angular 1 client (this is for the old one)
|
|
125
|
+
ng2 Angular 2+ client (uses HttpClient, InjectionTokens, etc)
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
If you want to use your own template, you can use the path to your template for the `-t` parameter:
|
package/dist/cli.js
CHANGED
|
@@ -32,7 +32,10 @@ program
|
|
|
32
32
|
process.env.OPEN_API_OUT
|
|
33
33
|
)
|
|
34
34
|
.option('-b, --baseUrl <string>', 'Base URL that will be used as a default value in the clients')
|
|
35
|
-
.option(
|
|
35
|
+
.option(
|
|
36
|
+
'-t, --template <string>',
|
|
37
|
+
'Template used forgenerating API client. Default: "axios". Other: "fetch", "ng1", "ng2", "swr-axios", "xior", "tsq-xior"'
|
|
38
|
+
)
|
|
36
39
|
.option('--preferAny', 'Use "any" type instead of "unknown"')
|
|
37
40
|
.option(
|
|
38
41
|
'--servicePrefix <string>',
|
package/dist/types.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface FullAppOptions extends ClientOptions {
|
|
|
29
29
|
/** Path to the configuration file that contains actual config to be used */
|
|
30
30
|
config?: string;
|
|
31
31
|
}
|
|
32
|
-
export type Template = 'axios' | 'fetch' | 'ng1' | 'ng2' | 'swr-axios' | 'xior' | '
|
|
32
|
+
export type Template = 'axios' | 'fetch' | 'ng1' | 'ng2' | 'swr-axios' | 'xior' | 'tsq-xior';
|
|
33
33
|
export type HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch';
|
|
34
34
|
export type DateSupport = 'string' | 'Date';
|
|
35
35
|
export type ArrayFormat = 'indices' | 'repeat' | 'brackets';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "swaggie",
|
|
3
|
-
"version": "1.0.2-test.
|
|
3
|
+
"version": "1.0.2-test.5",
|
|
4
4
|
"description": "Generate TypeScript REST client code from an OpenAPI spec",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Piotr Dabrowski",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@types/chai": "5.0.1",
|
|
62
62
|
"@types/js-yaml": "4.0.9",
|
|
63
63
|
"@types/mocha": "10.0.10",
|
|
64
|
-
"@types/node": "22.13.
|
|
65
|
-
"chai": "5.
|
|
64
|
+
"@types/node": "22.13.4",
|
|
65
|
+
"chai": "5.2.0",
|
|
66
66
|
"mocha": "11.1.0",
|
|
67
67
|
"openapi-types": "^12.1.3",
|
|
68
68
|
"sucrase": "3.35.0",
|
|
@@ -6,13 +6,16 @@
|
|
|
6
6
|
* @param $config (optional) Additional configuration for TanStack Query
|
|
7
7
|
* @param $httpConfig (optional) Additional configuration for xior request (actually executes the request)
|
|
8
8
|
*/
|
|
9
|
-
export function <%= it.rqOpName
|
|
9
|
+
export function <%= it.rqOpName %><TData = <%~ it.returnType %>, TError = Error>(<% it.parameters.forEach((parameter) => { %>
|
|
10
10
|
<%= parameter.name %>: <%~ parameter.type %> <%= parameter.optional ? ' | null | undefined' : '' %>,
|
|
11
11
|
<% }); %>
|
|
12
|
-
$config?:
|
|
12
|
+
$config?: Omit<
|
|
13
|
+
UseQueryOptions<<%~ it.returnType %>, TError, TData>,
|
|
14
|
+
'queryKey' | 'queryFn'
|
|
15
|
+
>,
|
|
13
16
|
$httpConfig?: XiorRequestConfig
|
|
14
17
|
) {
|
|
15
|
-
return useQuery({
|
|
18
|
+
return useQuery<<%~ it.returnType %>, TError, TData>({
|
|
16
19
|
queryKey: ['<%= it.clientName %>', '<%= it.opKey %>', <% it.query.forEach((parameter) => { %><%= parameter.name %>, <% }); %>],
|
|
17
20
|
queryFn: () => <%= it.clientName %>Client.<%= it.name %>(<% it.parameters.forEach((parameter) => { %>
|
|
18
21
|
<%= parameter.name %>, <% }); %>$httpConfig).then(res => res.data),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|