@kubb/plugin-react-query 3.1.0 → 3.2.0

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 (48) hide show
  1. package/dist/{chunk-YGWYQQ6H.js → chunk-5NA5VRXZ.js} +78 -47
  2. package/dist/chunk-5NA5VRXZ.js.map +1 -0
  3. package/dist/{chunk-GMONUHPD.js → chunk-A24GQ5ZN.js} +18 -3
  4. package/dist/chunk-A24GQ5ZN.js.map +1 -0
  5. package/dist/{chunk-WOYQTGDC.cjs → chunk-EZXV6KB3.cjs} +78 -47
  6. package/dist/chunk-EZXV6KB3.cjs.map +1 -0
  7. package/dist/{chunk-PBJIUPCN.cjs → chunk-VWLT4KLD.cjs} +33 -18
  8. package/dist/chunk-VWLT4KLD.cjs.map +1 -0
  9. package/dist/components.cjs +9 -9
  10. package/dist/components.d.cts +29 -15
  11. package/dist/components.d.ts +29 -15
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +6 -6
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +7 -5
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +5 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-BBt81Oun.d.cts → types-ClmUaz7P.d.cts} +13 -0
  24. package/dist/{types-BBt81Oun.d.ts → types-ClmUaz7P.d.ts} +13 -0
  25. package/package.json +11 -11
  26. package/src/components/InfiniteQuery.tsx +9 -3
  27. package/src/components/InfiniteQueryOptions.tsx +9 -4
  28. package/src/components/Mutation.tsx +18 -4
  29. package/src/components/MutationKey.tsx +5 -4
  30. package/src/components/Query.tsx +9 -3
  31. package/src/components/QueryKey.tsx +9 -6
  32. package/src/components/QueryOptions.tsx +9 -5
  33. package/src/components/SuspenseQuery.tsx +9 -3
  34. package/src/generators/__snapshots__/clientPostImportPath.ts +4 -4
  35. package/src/generators/__snapshots__/getPetIdCamelCase.ts +52 -0
  36. package/src/generators/__snapshots__/postAsQuery.ts +4 -4
  37. package/src/generators/__snapshots__/updatePetById.ts +4 -4
  38. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +4 -4
  39. package/src/generators/infiniteQueryGenerator.tsx +4 -0
  40. package/src/generators/mutationGenerator.tsx +3 -0
  41. package/src/generators/queryGenerator.tsx +4 -0
  42. package/src/generators/suspenseQueryGenerator.tsx +4 -0
  43. package/src/plugin.ts +2 -0
  44. package/src/types.ts +7 -0
  45. package/dist/chunk-GMONUHPD.js.map +0 -1
  46. package/dist/chunk-PBJIUPCN.cjs.map +0 -1
  47. package/dist/chunk-WOYQTGDC.cjs.map +0 -1
  48. package/dist/chunk-YGWYQQ6H.js.map +0 -1
@@ -47,6 +47,11 @@ type Options$1 = {
47
47
  * @default 'data'
48
48
  */
49
49
  dataReturnType?: 'data' | 'full';
50
+ /**
51
+ * How to style your params, by default no casing is applied
52
+ * - 'camelcase' will use camelcase for the params names
53
+ */
54
+ paramsCasing?: 'camelcase';
50
55
  /**
51
56
  * How to pass your params
52
57
  * - 'object' will return the params and pathParams as an object.
@@ -87,12 +92,14 @@ type ResolvedOptions$1 = {
87
92
  dataReturnType: NonNullable<Options$1['dataReturnType']>;
88
93
  pathParamsType: NonNullable<Options$1['pathParamsType']>;
89
94
  paramsType: NonNullable<Options$1['paramsType']>;
95
+ paramsCasing: Options$1['paramsCasing'];
90
96
  };
91
97
  type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
92
98
 
93
99
  type TransformerProps = {
94
100
  operation: Operation;
95
101
  schemas: OperationSchemas;
102
+ casing: 'camelcase' | undefined;
96
103
  };
97
104
  type Transformer = (props: TransformerProps) => unknown[];
98
105
  type Suspense = object;
@@ -173,6 +180,11 @@ type Options = {
173
180
  * Array containing override parameters to override `options` based on tags/operations/methods/paths.
174
181
  */
175
182
  override?: Array<Override<ResolvedOptions>>;
183
+ /**
184
+ * How to style your params, by default no casing is applied
185
+ * - 'camelcase' will use camelcase for the params names
186
+ */
187
+ paramsCasing?: 'camelcase';
176
188
  /**
177
189
  * How to pass your params
178
190
  * - 'object' will return the params and pathParams as an object.
@@ -229,6 +241,7 @@ type ResolvedOptions = {
229
241
  };
230
242
  parser: Required<NonNullable<Options['parser']>>;
231
243
  pathParamsType: NonNullable<Options['pathParamsType']>;
244
+ paramsCasing: Options['paramsCasing'];
232
245
  paramsType: NonNullable<Options['paramsType']>;
233
246
  /**
234
247
  * Only used of infinite
@@ -47,6 +47,11 @@ type Options$1 = {
47
47
  * @default 'data'
48
48
  */
49
49
  dataReturnType?: 'data' | 'full';
50
+ /**
51
+ * How to style your params, by default no casing is applied
52
+ * - 'camelcase' will use camelcase for the params names
53
+ */
54
+ paramsCasing?: 'camelcase';
50
55
  /**
51
56
  * How to pass your params
52
57
  * - 'object' will return the params and pathParams as an object.
@@ -87,12 +92,14 @@ type ResolvedOptions$1 = {
87
92
  dataReturnType: NonNullable<Options$1['dataReturnType']>;
88
93
  pathParamsType: NonNullable<Options$1['pathParamsType']>;
89
94
  paramsType: NonNullable<Options$1['paramsType']>;
95
+ paramsCasing: Options$1['paramsCasing'];
90
96
  };
91
97
  type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
92
98
 
93
99
  type TransformerProps = {
94
100
  operation: Operation;
95
101
  schemas: OperationSchemas;
102
+ casing: 'camelcase' | undefined;
96
103
  };
97
104
  type Transformer = (props: TransformerProps) => unknown[];
98
105
  type Suspense = object;
@@ -173,6 +180,11 @@ type Options = {
173
180
  * Array containing override parameters to override `options` based on tags/operations/methods/paths.
174
181
  */
175
182
  override?: Array<Override<ResolvedOptions>>;
183
+ /**
184
+ * How to style your params, by default no casing is applied
185
+ * - 'camelcase' will use camelcase for the params names
186
+ */
187
+ paramsCasing?: 'camelcase';
176
188
  /**
177
189
  * How to pass your params
178
190
  * - 'object' will return the params and pathParams as an object.
@@ -229,6 +241,7 @@ type ResolvedOptions = {
229
241
  };
230
242
  parser: Required<NonNullable<Options['parser']>>;
231
243
  pathParamsType: NonNullable<Options['pathParamsType']>;
244
+ paramsCasing: Options['paramsCasing'];
232
245
  paramsType: NonNullable<Options['paramsType']>;
233
246
  /**
234
247
  * Only used of infinite
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-react-query",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "description": "Generator react-query hooks",
5
5
  "keywords": [
6
6
  "faker",
@@ -63,21 +63,21 @@
63
63
  ],
64
64
  "dependencies": {
65
65
  "remeda": "^2.17.4",
66
- "@kubb/core": "3.1.0",
67
- "@kubb/fs": "3.1.0",
68
- "@kubb/oas": "3.1.0",
69
- "@kubb/plugin-oas": "3.1.0",
70
- "@kubb/plugin-ts": "3.1.0",
71
- "@kubb/plugin-zod": "3.1.0",
72
- "@kubb/react": "3.1.0"
66
+ "@kubb/core": "3.2.0",
67
+ "@kubb/oas": "3.2.0",
68
+ "@kubb/fs": "3.2.0",
69
+ "@kubb/plugin-oas": "3.2.0",
70
+ "@kubb/plugin-ts": "3.2.0",
71
+ "@kubb/react": "3.2.0",
72
+ "@kubb/plugin-zod": "3.2.0"
73
73
  },
74
74
  "devDependencies": {
75
- "@types/react": "^18.3.13",
75
+ "@types/react": "^18.3.16",
76
76
  "react": "^18.3.1",
77
77
  "tsup": "^8.3.5",
78
78
  "typescript": "^5.7.2",
79
- "@kubb/config-ts": "3.1.0",
80
- "@kubb/config-tsup": "3.1.0"
79
+ "@kubb/config-tsup": "3.2.0",
80
+ "@kubb/config-ts": "3.2.0"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "@kubb/react": "^3.0.0"
@@ -18,6 +18,7 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
21
22
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
22
23
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
23
24
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
@@ -25,12 +26,13 @@ type Props = {
25
26
 
26
27
  type GetParamsProps = {
27
28
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
29
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
28
30
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
29
31
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
30
32
  typeSchemas: OperationSchemas
31
33
  }
32
34
 
33
- function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
35
+ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
34
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
37
 
36
38
  if (paramsType === 'object') {
@@ -38,7 +40,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
38
40
  data: {
39
41
  mode: 'object',
40
42
  children: {
41
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
43
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
42
44
  data: typeSchemas.request?.name
43
45
  ? {
44
46
  type: typeSchemas.request?.name,
@@ -75,7 +77,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
75
77
  pathParams: typeSchemas.pathParams?.name
76
78
  ? {
77
79
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
78
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
80
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
79
81
  optional: isOptional(typeSchemas.pathParams?.schema),
80
82
  }
81
83
  : undefined,
@@ -115,6 +117,7 @@ export function InfiniteQuery({
115
117
  queryOptionsName,
116
118
  queryKeyName,
117
119
  paramsType,
120
+ paramsCasing,
118
121
  pathParamsType,
119
122
  dataReturnType,
120
123
  typeSchemas,
@@ -127,13 +130,16 @@ export function InfiniteQuery({
127
130
  const queryKeyParams = QueryKey.getParams({
128
131
  pathParamsType,
129
132
  typeSchemas,
133
+ paramsCasing,
130
134
  })
131
135
  const queryOptionsParams = QueryOptions.getParams({
132
136
  paramsType,
133
137
  pathParamsType,
134
138
  typeSchemas,
139
+ paramsCasing,
135
140
  })
136
141
  const params = getParams({
142
+ paramsCasing,
137
143
  paramsType,
138
144
  pathParamsType,
139
145
  dataReturnType,
@@ -14,6 +14,7 @@ type Props = {
14
14
  clientName: string
15
15
  queryKeyName: string
16
16
  typeSchemas: OperationSchemas
17
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
17
18
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
18
19
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
19
20
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
@@ -23,18 +24,19 @@ type Props = {
23
24
  }
24
25
 
25
26
  type GetParamsProps = {
27
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
26
28
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
27
29
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
28
30
  typeSchemas: OperationSchemas
29
31
  }
30
32
 
31
- function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
33
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
32
34
  if (paramsType === 'object') {
33
35
  return FunctionParams.factory({
34
36
  data: {
35
37
  mode: 'object',
36
38
  children: {
37
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
39
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
38
40
  data: typeSchemas.request?.name
39
41
  ? {
40
42
  type: typeSchemas.request?.name,
@@ -66,7 +68,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
66
68
  pathParams: typeSchemas.pathParams?.name
67
69
  ? {
68
70
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
69
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
71
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
70
72
  optional: isOptional(typeSchemas.pathParams?.schema),
71
73
  }
72
74
  : undefined,
@@ -101,14 +103,16 @@ export function InfiniteQueryOptions({
101
103
  initialPageParam,
102
104
  cursorParam,
103
105
  typeSchemas,
106
+ paramsCasing,
104
107
  paramsType,
105
108
  dataReturnType,
106
109
  pathParamsType,
107
110
  queryParam,
108
111
  queryKeyName,
109
112
  }: Props): ReactNode {
110
- const params = getParams({ paramsType, pathParamsType, typeSchemas })
113
+ const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
111
114
  const clientParams = Client.getParams({
115
+ paramsCasing,
112
116
  typeSchemas,
113
117
  paramsType,
114
118
  pathParamsType,
@@ -116,6 +120,7 @@ export function InfiniteQueryOptions({
116
120
  const queryKeyParams = QueryKey.getParams({
117
121
  pathParamsType,
118
122
  typeSchemas,
123
+ paramsCasing,
119
124
  })
120
125
 
121
126
  const queryOptions = [
@@ -20,20 +20,22 @@ type Props = {
20
20
  typeSchemas: OperationSchemas
21
21
  operation: Operation
22
22
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
23
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
23
24
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
24
25
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
25
26
  }
26
27
 
27
28
  type GetParamsProps = {
29
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
28
30
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
29
31
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
30
32
  typeSchemas: OperationSchemas
31
33
  }
32
34
 
33
- function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
35
+ function getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {
34
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
37
  const mutationParams = FunctionParams.factory({
36
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
38
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
37
39
  data: typeSchemas.request?.name
38
40
  ? {
39
41
  type: typeSchemas.request?.name,
@@ -71,26 +73,38 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
71
73
  })
72
74
  }
73
75
 
74
- export function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
76
+ export function Mutation({
77
+ name,
78
+ clientName,
79
+ paramsCasing,
80
+ paramsType,
81
+ pathParamsType,
82
+ dataReturnType,
83
+ typeSchemas,
84
+ operation,
85
+ mutationKeyName,
86
+ }: Props): ReactNode {
75
87
  const mutationKeyParams = MutationKey.getParams({
76
88
  pathParamsType,
77
89
  typeSchemas,
78
90
  })
79
91
 
80
92
  const params = getParams({
93
+ paramsCasing,
81
94
  pathParamsType,
82
95
  dataReturnType,
83
96
  typeSchemas,
84
97
  })
85
98
 
86
99
  const clientParams = Client.getParams({
100
+ paramsCasing,
87
101
  paramsType,
88
102
  typeSchemas,
89
103
  pathParamsType,
90
104
  })
91
105
 
92
106
  const mutationParams = FunctionParams.factory({
93
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
107
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
94
108
  data: typeSchemas.request?.name
95
109
  ? {
96
110
  type: typeSchemas.request?.name,
@@ -11,6 +11,7 @@ type Props = {
11
11
  typeName: string
12
12
  typeSchemas: OperationSchemas
13
13
  operation: Operation
14
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
14
15
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
15
16
  transformer: Transformer | undefined
16
17
  }
@@ -24,15 +25,15 @@ function getParams({}: GetParamsProps) {
24
25
  return FunctionParams.factory({})
25
26
  }
26
27
 
27
- const getTransformer: Transformer = ({ operation }) => {
28
- const path = new URLPath(operation.path)
28
+ const getTransformer: Transformer = ({ operation, casing }) => {
29
+ const path = new URLPath(operation.path, { casing })
29
30
 
30
31
  return [JSON.stringify({ url: path.path })].filter(Boolean)
31
32
  }
32
33
 
33
- export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
34
+ export function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer }: Props): ReactNode {
34
35
  const params = getParams({ pathParamsType, typeSchemas })
35
- const keys = transformer({ operation, schemas: typeSchemas })
36
+ const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })
36
37
 
37
38
  return (
38
39
  <>
@@ -18,19 +18,21 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
21
22
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
22
23
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
23
24
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
24
25
  }
25
26
 
26
27
  type GetParamsProps = {
28
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
27
29
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
28
30
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
29
31
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
30
32
  typeSchemas: OperationSchemas
31
33
  }
32
34
 
33
- function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
35
+ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
34
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
37
 
36
38
  if (paramsType === 'object') {
@@ -38,7 +40,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
38
40
  data: {
39
41
  mode: 'object',
40
42
  children: {
41
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
43
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
42
44
  data: typeSchemas.request?.name
43
45
  ? {
44
46
  type: typeSchemas.request?.name,
@@ -75,7 +77,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
75
77
  pathParams: typeSchemas.pathParams?.name
76
78
  ? {
77
79
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
78
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
80
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
79
81
  optional: isOptional(typeSchemas.pathParams?.schema),
80
82
  }
81
83
  : undefined,
@@ -115,6 +117,7 @@ export function Query({
115
117
  queryOptionsName,
116
118
  queryKeyName,
117
119
  paramsType,
120
+ paramsCasing,
118
121
  pathParamsType,
119
122
  dataReturnType,
120
123
  typeSchemas,
@@ -127,13 +130,16 @@ export function Query({
127
130
  const queryKeyParams = QueryKey.getParams({
128
131
  pathParamsType,
129
132
  typeSchemas,
133
+ paramsCasing,
130
134
  })
131
135
  const queryOptionsParams = QueryOptions.getParams({
132
136
  paramsType,
133
137
  pathParamsType,
134
138
  typeSchemas,
139
+ paramsCasing,
135
140
  })
136
141
  const params = getParams({
142
+ paramsCasing,
137
143
  paramsType,
138
144
  pathParamsType,
139
145
  dataReturnType,
@@ -12,20 +12,22 @@ type Props = {
12
12
  typeName: string
13
13
  typeSchemas: OperationSchemas
14
14
  operation: Operation
15
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
15
16
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
16
17
  transformer: Transformer | undefined
17
18
  }
18
19
 
19
20
  type GetParamsProps = {
21
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
20
22
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
21
23
  typeSchemas: OperationSchemas
22
24
  }
23
25
 
24
- function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
26
+ function getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {
25
27
  return FunctionParams.factory({
26
28
  pathParams: {
27
29
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
28
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
30
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
29
31
  },
30
32
  data: typeSchemas.request?.name
31
33
  ? {
@@ -42,8 +44,8 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
42
44
  })
43
45
  }
44
46
 
45
- const getTransformer: Transformer = ({ operation, schemas }) => {
46
- const path = new URLPath(operation.path)
47
+ const getTransformer: Transformer = ({ operation, schemas, casing }) => {
48
+ const path = new URLPath(operation.path, { casing })
47
49
  const keys = [
48
50
  path.toObject({
49
51
  type: 'path',
@@ -56,11 +58,12 @@ const getTransformer: Transformer = ({ operation, schemas }) => {
56
58
  return keys
57
59
  }
58
60
 
59
- export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
60
- const params = getParams({ pathParamsType, typeSchemas })
61
+ export function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
62
+ const params = getParams({ pathParamsType, typeSchemas, paramsCasing })
61
63
  const keys = transformer({
62
64
  operation,
63
65
  schemas: typeSchemas,
66
+ casing: paramsCasing,
64
67
  })
65
68
 
66
69
  return (
@@ -14,23 +14,25 @@ type Props = {
14
14
  clientName: string
15
15
  queryKeyName: string
16
16
  typeSchemas: OperationSchemas
17
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
17
18
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
18
19
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
19
20
  }
20
21
 
21
22
  type GetParamsProps = {
23
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
22
24
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
23
25
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
24
26
  typeSchemas: OperationSchemas
25
27
  }
26
28
 
27
- function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
29
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
28
30
  if (paramsType === 'object') {
29
31
  return FunctionParams.factory({
30
32
  data: {
31
33
  mode: 'object',
32
34
  children: {
33
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
35
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
34
36
  data: typeSchemas.request?.name
35
37
  ? {
36
38
  type: typeSchemas.request?.name,
@@ -62,7 +64,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
62
64
  pathParams: typeSchemas.pathParams?.name
63
65
  ? {
64
66
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
65
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
67
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
66
68
  optional: isOptional(typeSchemas.pathParams?.schema),
67
69
  }
68
70
  : undefined,
@@ -91,16 +93,18 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
91
93
  })
92
94
  }
93
95
 
94
- export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
95
- const params = getParams({ paramsType, pathParamsType, typeSchemas })
96
+ export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
97
+ const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
96
98
  const clientParams = Client.getParams({
97
99
  typeSchemas,
100
+ paramsCasing,
98
101
  paramsType,
99
102
  pathParamsType,
100
103
  })
101
104
  const queryKeyParams = QueryKey.getParams({
102
105
  pathParamsType,
103
106
  typeSchemas,
107
+ paramsCasing,
104
108
  })
105
109
 
106
110
  const enabled = Object.entries(queryKeyParams.flatParams)
@@ -18,19 +18,21 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
21
22
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
22
23
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
23
24
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
24
25
  }
25
26
 
26
27
  type GetParamsProps = {
28
+ paramsCasing: PluginReactQuery['resolvedOptions']['paramsCasing']
27
29
  paramsType: PluginReactQuery['resolvedOptions']['paramsType']
28
30
  pathParamsType: PluginReactQuery['resolvedOptions']['pathParamsType']
29
31
  dataReturnType: PluginReactQuery['resolvedOptions']['client']['dataReturnType']
30
32
  typeSchemas: OperationSchemas
31
33
  }
32
34
 
33
- function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
35
+ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
34
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
37
 
36
38
  if (paramsType === 'object') {
@@ -38,7 +40,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
38
40
  data: {
39
41
  mode: 'object',
40
42
  children: {
41
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
43
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
42
44
  data: typeSchemas.request?.name
43
45
  ? {
44
46
  type: typeSchemas.request?.name,
@@ -75,7 +77,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
75
77
  pathParams: typeSchemas.pathParams?.name
76
78
  ? {
77
79
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
78
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
80
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
79
81
  optional: isOptional(typeSchemas.pathParams?.schema),
80
82
  }
81
83
  : undefined,
@@ -115,6 +117,7 @@ export function SuspenseQuery({
115
117
  queryOptionsName,
116
118
  queryKeyName,
117
119
  paramsType,
120
+ paramsCasing,
118
121
  pathParamsType,
119
122
  dataReturnType,
120
123
  typeSchemas,
@@ -127,13 +130,16 @@ export function SuspenseQuery({
127
130
  const queryKeyParams = QueryKey.getParams({
128
131
  pathParamsType,
129
132
  typeSchemas,
133
+ paramsCasing,
130
134
  })
131
135
  const queryOptionsParams = QueryOptions.getParams({
136
+ paramsCasing,
132
137
  paramsType,
133
138
  pathParamsType,
134
139
  typeSchemas,
135
140
  })
136
141
  const params = getParams({
142
+ paramsCasing,
137
143
  paramsType,
138
144
  pathParamsType,
139
145
  dataReturnType,
@@ -3,22 +3,22 @@ import type { UseMutationOptions } from "@tanstack/react-query";
3
3
  import type { RequestConfig } from "axios";
4
4
  import { useMutation } from "@tanstack/react-query";
5
5
 
6
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
6
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{pet_id}" }] as const;
7
7
 
8
8
  export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
9
9
 
10
10
  /**
11
11
  * @summary Updates a pet in the store with form data
12
- * {@link /pet/:petId}
12
+ * {@link /pet/:pet_id}
13
13
  */
14
14
  async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
15
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${pet_id}`, params, data, ...config });
16
16
  return updatePetWithFormMutationResponse.parse(res.data);
17
17
  }
18
18
 
19
19
  /**
20
20
  * @summary Updates a pet in the store with form data
21
- * {@link /pet/:petId}
21
+ * {@link /pet/:pet_id}
22
22
  */
23
23
  export function useUpdatePetWithForm(options: {
24
24
  mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {