react-query-lightbase-codegen 2.0.3 → 2.0.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.
@@ -181,7 +181,7 @@ function generateApiClient(spec, config) {
181
181
  operations.push({
182
182
  method: method,
183
183
  path,
184
- operationId: `${method}_${(0, utils_1.sanitizeTypeName)(operation.operationId || `${path.replace(/\W+/g, "_")}`)}`,
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 || [])]),
@@ -28,8 +28,8 @@ function generateQueryOptions(operation, spec) {
28
28
  })
29
29
  : []),
30
30
  ];
31
- const namedQueryOptions = (0, utils_1.camelCase)(`get_${operationId}_Query_Options`);
32
- const namedQuery = (0, utils_1.camelCase)(`${method}_${operationId}`);
31
+ const namedQueryOptions = `get${operationId}QueryOptions`;
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: `${(0, utils_1.sanitizeTypeName)(operation.operationId || `${path.replace(/\W+/g, "_")}`)}`,
60
+ operationId: `${operation.operationId || `${path.replace(/\W+/g, "_")}`}`,
61
61
  summary: operation.summary,
62
62
  description: operation.description,
63
63
  parameters: [
@@ -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)(`${method}_${(0, utils_1.sanitizeTypeName)(operationObject.operationId || `${path.replace(/\W+/g, "_")}`)}`);
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
@@ -7,7 +7,6 @@ exports.sanitizeTypeName = sanitizeTypeName;
7
7
  exports.specTitle = specTitle;
8
8
  function camelCase(str) {
9
9
  return str
10
- .toLowerCase()
11
10
  .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase())
12
11
  .replace(/^[A-Z]/, (c) => c.toLowerCase());
13
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-query-lightbase-codegen",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "license": "MIT",
5
5
  "description": "Generate Axios API clients and React Query options from OpenAPI specifications",
6
6
  "exports": "./dist/index.js",
@@ -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: `${method}_${sanitizeTypeName(operation.operationId || `${path.replace(/\W+/g, "_")}`)}`,
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 || [])]),
@@ -35,8 +35,8 @@ function generateQueryOptions(operation: OperationInfo, spec: OpenAPIV3.Document
35
35
  : []),
36
36
  ];
37
37
 
38
- const namedQueryOptions = camelCase(`get_${operationId}_Query_Options`);
39
- const namedQuery = camelCase(`${method}_${operationId}`);
38
+ const namedQueryOptions = `get${operationId}QueryOptions`;
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: `${sanitizeTypeName(operation.operationId || `${path.replace(/\W+/g, "_")}`)}`,
69
+ operationId: `${operation.operationId || `${path.replace(/\W+/g, "_")}`}`,
70
70
  summary: operation.summary,
71
71
  description: operation.description,
72
72
  parameters: [
@@ -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
- `${method}_${sanitizeTypeName(operationObject.operationId || `${path.replace(/\W+/g, "_")}`)}`
109
+ `${sanitizeTypeName(operationObject.operationId || `${path.replace(/\W+/g, "_")}`)}`
110
110
  );
111
111
 
112
112
  // Generate request body type
package/src/utils.ts CHANGED
@@ -2,7 +2,6 @@ import type { OpenAPIV3 } from "openapi-types";
2
2
 
3
3
  export function camelCase(str: string): string {
4
4
  return str
5
- .toLowerCase()
6
5
  .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase())
7
6
  .replace(/^[A-Z]/, (c) => c.toLowerCase());
8
7
  }