@kubb/core 5.0.0-alpha.28 → 5.0.0-alpha.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/core",
3
- "version": "5.0.0-alpha.28",
3
+ "version": "5.0.0-alpha.29",
4
4
  "description": "Core functionality for Kubb's plugin-based code generation system, providing the foundation for transforming OpenAPI specifications.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -71,7 +71,7 @@
71
71
  "remeda": "^2.33.7",
72
72
  "semver": "^7.7.4",
73
73
  "tinyexec": "^1.0.4",
74
- "@kubb/ast": "5.0.0-alpha.28"
74
+ "@kubb/ast": "5.0.0-alpha.29"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/semver": "^7.7.1",
@@ -44,6 +44,8 @@ function matchesOperationPattern(node: OperationNode, type: string, pattern: str
44
44
  return !!node.path.match(pattern)
45
45
  case 'method':
46
46
  return !!(node.method.toLowerCase() as string).match(pattern)
47
+ case 'contentType':
48
+ return !!node.requestBody?.contentType?.match(pattern)
47
49
  default:
48
50
  return false
49
51
  }
@@ -316,13 +318,17 @@ export function buildDefaultBanner({
316
318
  /**
317
319
  * Default banner resolver — returns the banner string for a generated file.
318
320
  *
319
- * - When `output.banner` is a function and `node` is provided, calls it with the node.
320
- * - When `output.banner` is a function and `node` is absent, falls back to the default Kubb banner.
321
+ * A user-supplied `output.banner` overrides the default Kubb "Generated by Kubb" notice.
322
+ * When no `output.banner` is set, the Kubb notice is used (including `title` and `version`
323
+ * from the OAS spec when a `node` is provided).
324
+ *
325
+ * - When `output.banner` is a function and `node` is provided, returns `output.banner(node)`.
326
+ * - When `output.banner` is a function and `node` is absent, falls back to the Kubb notice.
321
327
  * - When `output.banner` is a string, returns it directly.
322
328
  * - When `config.output.defaultBanner` is `false`, returns `undefined`.
323
- * - Otherwise returns the default "Generated by Kubb" banner.
329
+ * - Otherwise returns the Kubb "Generated by Kubb" notice.
324
330
  *
325
- * @example String banner
331
+ * @example String banner overrides default
326
332
  * ```ts
327
333
  * defaultResolveBanner(undefined, { output: { banner: '// my banner' }, config })
328
334
  * // → '// my banner'
@@ -334,7 +340,13 @@ export function buildDefaultBanner({
334
340
  * // → '// v3.0.0'
335
341
  * ```
336
342
  *
337
- * @example Disabled banner
343
+ * @example No user banner — Kubb notice with OAS metadata
344
+ * ```ts
345
+ * defaultResolveBanner(rootNode, { config })
346
+ * // → '/** Generated by Kubb ... Title: Pet Store ... *\/'
347
+ * ```
348
+ *
349
+ * @example Disabled default banner
338
350
  * ```ts
339
351
  * defaultResolveBanner(undefined, { config: { output: { defaultBanner: false }, ...config } })
340
352
  * // → undefined
@@ -342,15 +354,18 @@ export function buildDefaultBanner({
342
354
  */
343
355
  export function defaultResolveBanner(node: RootNode | undefined, { output, config }: ResolveBannerContext): string | undefined {
344
356
  if (typeof output?.banner === 'function') {
345
- return node ? output.banner(node) : buildDefaultBanner({ config })
357
+ return output.banner(node)
346
358
  }
359
+
347
360
  if (typeof output?.banner === 'string') {
348
361
  return output.banner
349
362
  }
363
+
350
364
  if (config.output.defaultBanner === false) {
351
365
  return undefined
352
366
  }
353
- return buildDefaultBanner({ config })
367
+
368
+ return buildDefaultBanner({ title: node?.meta?.title, version: node?.meta?.version, config })
354
369
  }
355
370
 
356
371
  /**
package/src/types.ts CHANGED
@@ -587,11 +587,11 @@ export type Output<_TOptions = unknown> = {
587
587
  /**
588
588
  * Add a banner text in the beginning of every file
589
589
  */
590
- banner?: string | ((node: RootNode) => string)
590
+ banner?: string | ((node?: RootNode) => string)
591
591
  /**
592
592
  * Add a footer text in the beginning of every file
593
593
  */
594
- footer?: string | ((node: RootNode) => string)
594
+ footer?: string | ((node?: RootNode) => string)
595
595
  /**
596
596
  * Whether to override existing external files if they already exist.
597
597
  * @default false