react-query-lightbase-codegen 2.0.4 → 2.0.6
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/dist/generator/clientGenerator.js +1 -1
- package/dist/generator/reactQueryGenerator.js +5 -2
- package/dist/generator/schemaGenerator.js +1 -1
- package/dist/utils.js +0 -1
- package/package.json +1 -1
- package/src/generator/clientGenerator.ts +1 -1
- package/src/generator/reactQueryGenerator.ts +5 -2
- package/src/generator/schemaGenerator.ts +1 -1
- package/src/utils.ts +0 -1
|
@@ -181,7 +181,7 @@ function generateApiClient(spec, config) {
|
|
|
181
181
|
operations.push({
|
|
182
182
|
method: method,
|
|
183
183
|
path,
|
|
184
|
-
operationId: `${
|
|
184
|
+
operationId: `${(0, utils_1.sanitizeTypeName)(operation.operationId || `${path.replace(/\W+/g, "_")}`)}`,
|
|
185
185
|
summary: operation.summary,
|
|
186
186
|
description: operation.description,
|
|
187
187
|
parameters: resolveParameters([...(pathItem.parameters || []), ...(operation.parameters || [])]),
|
|
@@ -29,7 +29,7 @@ function generateQueryOptions(operation, spec) {
|
|
|
29
29
|
: []),
|
|
30
30
|
];
|
|
31
31
|
const namedQueryOptions = `get${operationId}QueryOptions`;
|
|
32
|
-
const namedQuery = (0, utils_1.camelCase)(`${
|
|
32
|
+
const namedQuery = (0, utils_1.camelCase)(`${operationId}`);
|
|
33
33
|
return `
|
|
34
34
|
export const ${namedQueryOptions} = (
|
|
35
35
|
${hasData ? `params: Partial<Parameters<typeof apiClient.${namedQuery}>[0]>, config?: Partial<Parameters<typeof apiClient.${namedQuery}>[1]>` : `_: undefined, config?: Partial<Parameters<typeof apiClient.${namedQuery}>[1]>`}
|
|
@@ -57,7 +57,7 @@ function generateReactQuery(spec) {
|
|
|
57
57
|
operations.push({
|
|
58
58
|
method: method,
|
|
59
59
|
path,
|
|
60
|
-
operationId: `${
|
|
60
|
+
operationId: `${operation.operationId || `${path.replace(/\W+/g, "_")}`}`,
|
|
61
61
|
summary: operation.summary,
|
|
62
62
|
description: operation.description,
|
|
63
63
|
parameters: [
|
|
@@ -71,6 +71,9 @@ function generateReactQuery(spec) {
|
|
|
71
71
|
});
|
|
72
72
|
return `import { queryOptions, skipToken } from '@tanstack/react-query';
|
|
73
73
|
import * as apiClient from './${(0, utils_1.specTitle)(spec)}.client';
|
|
74
|
+
// TEMPORARY: allows for backward compatibility imports
|
|
75
|
+
export * from './${(0, utils_1.specTitle)(spec)}.client';
|
|
76
|
+
|
|
74
77
|
const hasDefinedProps = <T extends { [P in K]?: any }, K extends PropertyKey>(
|
|
75
78
|
obj: T,
|
|
76
79
|
...keys: K[]
|
|
@@ -86,7 +86,7 @@ function generateTypeDefinitions(spec) {
|
|
|
86
86
|
const operationObject = operation;
|
|
87
87
|
if (!operationObject)
|
|
88
88
|
continue;
|
|
89
|
-
const operationId = (0, utils_1.pascalCase)(`${
|
|
89
|
+
const operationId = (0, utils_1.pascalCase)(`${(0, utils_1.sanitizeTypeName)(operationObject.operationId || `${path.replace(/\W+/g, "_")}`)}`);
|
|
90
90
|
// Generate request body type
|
|
91
91
|
if (operationObject.requestBody) {
|
|
92
92
|
const content = operationObject.requestBody.content;
|
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -214,7 +214,7 @@ export function generateApiClient(spec: OpenAPIV3.Document, config: OpenAPIConfi
|
|
|
214
214
|
operations.push({
|
|
215
215
|
method: method,
|
|
216
216
|
path,
|
|
217
|
-
operationId: `${
|
|
217
|
+
operationId: `${sanitizeTypeName(operation.operationId || `${path.replace(/\W+/g, "_")}`)}`,
|
|
218
218
|
summary: operation.summary,
|
|
219
219
|
description: operation.description,
|
|
220
220
|
parameters: resolveParameters([...(pathItem.parameters || []), ...(operation.parameters || [])]),
|
|
@@ -36,7 +36,7 @@ function generateQueryOptions(operation: OperationInfo, spec: OpenAPIV3.Document
|
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
const namedQueryOptions = `get${operationId}QueryOptions`;
|
|
39
|
-
const namedQuery = camelCase(`${
|
|
39
|
+
const namedQuery = camelCase(`${operationId}`);
|
|
40
40
|
|
|
41
41
|
return `
|
|
42
42
|
export const ${namedQueryOptions} = (
|
|
@@ -66,7 +66,7 @@ export function generateReactQuery(spec: OpenAPIV3.Document): string {
|
|
|
66
66
|
operations.push({
|
|
67
67
|
method: method,
|
|
68
68
|
path,
|
|
69
|
-
operationId: `${
|
|
69
|
+
operationId: `${operation.operationId || `${path.replace(/\W+/g, "_")}`}`,
|
|
70
70
|
summary: operation.summary,
|
|
71
71
|
description: operation.description,
|
|
72
72
|
parameters: [
|
|
@@ -81,6 +81,9 @@ export function generateReactQuery(spec: OpenAPIV3.Document): string {
|
|
|
81
81
|
|
|
82
82
|
return `import { queryOptions, skipToken } from '@tanstack/react-query';
|
|
83
83
|
import * as apiClient from './${specTitle(spec)}.client';
|
|
84
|
+
// TEMPORARY: allows for backward compatibility imports
|
|
85
|
+
export * from './${specTitle(spec)}.client';
|
|
86
|
+
|
|
84
87
|
const hasDefinedProps = <T extends { [P in K]?: any }, K extends PropertyKey>(
|
|
85
88
|
obj: T,
|
|
86
89
|
...keys: K[]
|
|
@@ -106,7 +106,7 @@ export function generateTypeDefinitions(spec: OpenAPIV3.Document): string {
|
|
|
106
106
|
const operationObject = operation as OpenAPIV3.OperationObject;
|
|
107
107
|
if (!operationObject) continue;
|
|
108
108
|
const operationId = pascalCase(
|
|
109
|
-
`${
|
|
109
|
+
`${sanitizeTypeName(operationObject.operationId || `${path.replace(/\W+/g, "_")}`)}`
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
// Generate request body type
|
package/src/utils.ts
CHANGED