@kubb/ast 5.0.0-alpha.10 → 5.0.0-alpha.12

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/src/visitor.ts CHANGED
@@ -95,7 +95,7 @@ function getChildren(node: Node, recurse: boolean): Array<Node> {
95
95
  case 'Root':
96
96
  return [...node.schemas, ...node.operations]
97
97
  case 'Operation':
98
- return [...node.parameters, ...(node.requestBody ? [node.requestBody] : []), ...node.responses]
98
+ return [...node.parameters, ...(node.requestBody?.schema ? [node.requestBody.schema] : []), ...node.responses]
99
99
  case 'Schema': {
100
100
  const children: Array<Node> = []
101
101
 
@@ -104,6 +104,7 @@ function getChildren(node: Node, recurse: boolean): Array<Node> {
104
104
  if ('properties' in node && node.properties.length > 0) children.push(...node.properties)
105
105
  if ('items' in node && node.items) children.push(...node.items)
106
106
  if ('members' in node && node.members) children.push(...node.members)
107
+ if ('additionalProperties' in node && node.additionalProperties && node.additionalProperties !== true) children.push(node.additionalProperties)
107
108
 
108
109
  return children
109
110
  }
@@ -196,7 +197,9 @@ export function transform(node: Node, visitor: Visitor, options: VisitorOptions
196
197
  return {
197
198
  ...op,
198
199
  parameters: op.parameters.map((p) => transform(p, visitor, options)),
199
- requestBody: op.requestBody ? transform(op.requestBody, visitor, options) : undefined,
200
+ requestBody: op.requestBody
201
+ ? { ...op.requestBody, schema: op.requestBody.schema ? transform(op.requestBody.schema, visitor, options) : undefined }
202
+ : undefined,
200
203
  responses: op.responses.map((r) => transform(r, visitor, options)),
201
204
  }
202
205
  }
@@ -210,6 +213,9 @@ export function transform(node: Node, visitor: Visitor, options: VisitorOptions
210
213
  ...('properties' in schema && recurse ? { properties: schema.properties.map((p) => transform(p, visitor, options)) } : {}),
211
214
  ...('items' in schema && recurse ? { items: schema.items?.map((i) => transform(i, visitor, options)) } : {}),
212
215
  ...('members' in schema && recurse ? { members: schema.members?.map((m) => transform(m, visitor, options)) } : {}),
216
+ ...('additionalProperties' in schema && recurse && schema.additionalProperties && schema.additionalProperties !== true
217
+ ? { additionalProperties: transform(schema.additionalProperties, visitor, options) }
218
+ : {}),
213
219
  }
214
220
  }
215
221
  case 'Property': {