@pikku/openapi-parser 0.12.24 → 0.12.26
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/codegen.js +12 -2
- package/package.json +1 -1
package/dist/codegen.js
CHANGED
|
@@ -416,11 +416,17 @@ function topoSortSchemas(schemas, schemaIdentityMap) {
|
|
|
416
416
|
}
|
|
417
417
|
return { sorted, cyclicEdges };
|
|
418
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Collapse every whitespace run — including the line terminators `\n`, `\r`,
|
|
421
|
+
* U+2028 and U+2029, all matched by `\s` — to a single space, so a value taken
|
|
422
|
+
* from the spec cannot end a `//` comment and start a line of code.
|
|
423
|
+
*/
|
|
424
|
+
const inLineComment = (value) => String(value).replace(/\s+/g, ' ').trim();
|
|
419
425
|
function generateTypesFile(spec, ctx, schemaIdentityMap) {
|
|
420
426
|
const lines = [];
|
|
421
427
|
lines.push("import { z } from 'zod'");
|
|
422
428
|
lines.push('');
|
|
423
|
-
lines.push(`// Shared schemas from ${spec.info.title} v${spec.info.version}`);
|
|
429
|
+
lines.push(`// Shared schemas from ${inLineComment(spec.info.title)} v${inLineComment(spec.info.version)}`);
|
|
424
430
|
lines.push('');
|
|
425
431
|
const { sorted, cyclicEdges } = topoSortSchemas(spec.componentSchemas, schemaIdentityMap);
|
|
426
432
|
// Track emitted variable names and type names to deduplicate collisions
|
|
@@ -510,11 +516,12 @@ function generateFunctionFile(named, parsed, vars, ctx, spec, flags, inlineSchem
|
|
|
510
516
|
const tag = parsed.tags[0];
|
|
511
517
|
const tagDesc = spec.tagDescriptions[tag];
|
|
512
518
|
if (tagDesc) {
|
|
519
|
+
const cleanTag = String(tag).replace(/\s+/g, ' ').trim();
|
|
513
520
|
const cleanDesc = tagDesc
|
|
514
521
|
.replace(/\r?\n/g, ' ')
|
|
515
522
|
.replace(/\s+/g, ' ')
|
|
516
523
|
.trim();
|
|
517
|
-
lines.push(`// ${
|
|
524
|
+
lines.push(`// ${cleanTag} — ${cleanDesc}`);
|
|
518
525
|
lines.push('');
|
|
519
526
|
}
|
|
520
527
|
}
|
|
@@ -667,6 +674,9 @@ function generateFunctionFile(named, parsed, vars, ctx, spec, flags, inlineSchem
|
|
|
667
674
|
if (flags.mcp) {
|
|
668
675
|
funcConfig.push(' mcp: true,');
|
|
669
676
|
}
|
|
677
|
+
// Eligible for a host's `wireAddon({ expose })` list, which decides what is
|
|
678
|
+
// actually reachable; without this no list could open an operation.
|
|
679
|
+
funcConfig.push(' expose: true,');
|
|
670
680
|
// Bug 3: Avoid duplicate identifier when camelName is 'data' (TS2300)
|
|
671
681
|
const inputParamName = camelName === 'data' ? 'inputData' : 'data';
|
|
672
682
|
const funcParams = hasInput
|