@pikku/openapi-parser 0.12.25 → 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.
Files changed (2) hide show
  1. package/dist/codegen.js +9 -2
  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(`// ${tag} — ${cleanDesc}`);
524
+ lines.push(`// ${cleanTag} — ${cleanDesc}`);
518
525
  lines.push('');
519
526
  }
520
527
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/openapi-parser",
3
- "version": "0.12.25",
3
+ "version": "0.12.26",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",