@kubb/ast 5.0.0-beta.28 → 5.0.0-beta.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/dist/index.cjs CHANGED
@@ -605,7 +605,9 @@ function* getChildren(node, recurse) {
605
605
  return;
606
606
  }
607
607
  if (node.kind === "Response") {
608
- if (node.schema) yield node.schema;
608
+ if (node.content) {
609
+ for (const c of node.content) if (c.schema) yield c.schema;
610
+ }
609
611
  return;
610
612
  }
611
613
  }
@@ -741,10 +743,13 @@ function transform(node, options) {
741
743
  const response = visitor.response?.(node, { parent }) ?? node;
742
744
  return {
743
745
  ...response,
744
- schema: transform(response.schema, {
745
- ...options,
746
- parent: response
747
- })
746
+ content: response.content?.map((entry) => ({
747
+ ...entry,
748
+ schema: entry.schema ? transform(entry.schema, {
749
+ ...options,
750
+ parent: response
751
+ }) : entry.schema
752
+ }))
748
753
  };
749
754
  }
750
755
  return node;
@@ -1664,19 +1669,28 @@ function createParameter(props) {
1664
1669
  /**
1665
1670
  * Creates a `ResponseNode`.
1666
1671
  *
1672
+ * Response body schemas live inside `content`. For convenience a single legacy `schema`
1673
+ * (with optional `mediaType`/`keysToOmit`) is normalized into one `content` entry, so the same
1674
+ * schema is never stored both at the node root and inside `content`.
1675
+ *
1667
1676
  * @example
1668
1677
  * ```ts
1669
1678
  * const response = createResponse({
1670
1679
  * statusCode: '200',
1671
- * description: 'Success',
1672
- * schema: createSchema({ type: 'object', properties: [] }),
1680
+ * content: [{ contentType: 'application/json', schema: createSchema({ type: 'object', properties: [] }) }],
1673
1681
  * })
1674
1682
  * ```
1675
1683
  */
1676
1684
  function createResponse(props) {
1685
+ const { schema, mediaType, keysToOmit, content, ...rest } = props;
1677
1686
  return {
1678
- ...props,
1679
- kind: "Response"
1687
+ ...rest,
1688
+ kind: "Response",
1689
+ content: content ?? (schema ? [{
1690
+ contentType: mediaType ?? "application/json",
1691
+ schema,
1692
+ keysToOmit: keysToOmit ?? null
1693
+ }] : void 0)
1680
1694
  };
1681
1695
  }
1682
1696
  /**