@pikku/openapi-parser 0.12.7 → 0.12.9
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/CHANGELOG.md +12 -0
- package/dist/codegen.js +10 -0
- package/package.json +1 -1
- package/src/codegen.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pikku/openapi-parser
|
|
2
2
|
|
|
3
|
+
## 0.12.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2ce0733: Fix credential services template variable passing, duplicate body/path param collision, and add credentialOverrides to wireAddon.
|
|
8
|
+
|
|
9
|
+
## 0.12.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 94ceecd: Fix duplicate property error in generated code when body and path/query/header params share the same name. Skips the body property with a warning.
|
|
14
|
+
|
|
3
15
|
## 0.12.7
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/codegen.js
CHANGED
|
@@ -179,11 +179,21 @@ function buildInputSchema(parsed, ctx) {
|
|
|
179
179
|
}
|
|
180
180
|
if (parsed.requestBody) {
|
|
181
181
|
if (parsed.requestBody.properties) {
|
|
182
|
+
const paramNames = new Set([
|
|
183
|
+
...parsed.pathParams.map((p) => p.name),
|
|
184
|
+
...parsed.queryParams.map((p) => p.name),
|
|
185
|
+
...parsed.headerParams.map((p) => p.name),
|
|
186
|
+
]);
|
|
182
187
|
const requiredSet = new Set(parsed.requestBody.required ?? []);
|
|
183
188
|
for (const [key, propSchema] of Object.entries(parsed.requestBody.properties)) {
|
|
184
189
|
// Skip readOnly properties from input
|
|
185
190
|
if (propSchema.readOnly)
|
|
186
191
|
continue;
|
|
192
|
+
// Skip body properties that collide with path/query/header params
|
|
193
|
+
if (paramNames.has(key)) {
|
|
194
|
+
console.warn(`[openapi] Skipping body property '${key}' — collides with path/query/header param`);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
187
197
|
const isOptional = !requiredSet.has(key);
|
|
188
198
|
const zodCode = schemaToZod(propSchema, ctx, { optional: isOptional });
|
|
189
199
|
props.push(` ${safeKey(key)}: ${zodCode},`);
|
package/package.json
CHANGED
package/src/codegen.ts
CHANGED
|
@@ -297,12 +297,24 @@ function buildInputSchema(
|
|
|
297
297
|
|
|
298
298
|
if (parsed.requestBody) {
|
|
299
299
|
if (parsed.requestBody.properties) {
|
|
300
|
+
const paramNames = new Set([
|
|
301
|
+
...parsed.pathParams.map((p) => p.name),
|
|
302
|
+
...parsed.queryParams.map((p) => p.name),
|
|
303
|
+
...parsed.headerParams.map((p) => p.name),
|
|
304
|
+
])
|
|
300
305
|
const requiredSet = new Set(parsed.requestBody.required ?? [])
|
|
301
306
|
for (const [key, propSchema] of Object.entries(
|
|
302
307
|
parsed.requestBody.properties
|
|
303
308
|
)) {
|
|
304
309
|
// Skip readOnly properties from input
|
|
305
310
|
if (propSchema.readOnly) continue
|
|
311
|
+
// Skip body properties that collide with path/query/header params
|
|
312
|
+
if (paramNames.has(key)) {
|
|
313
|
+
console.warn(
|
|
314
|
+
`[openapi] Skipping body property '${key}' — collides with path/query/header param`
|
|
315
|
+
)
|
|
316
|
+
continue
|
|
317
|
+
}
|
|
306
318
|
const isOptional = !requiredSet.has(key)
|
|
307
319
|
const zodCode = schemaToZod(propSchema, ctx, { optional: isOptional })
|
|
308
320
|
props.push(` ${safeKey(key)}: ${zodCode},`)
|