@workos/oagen 0.26.0 → 0.26.1

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/smoke.mjs CHANGED
@@ -402,6 +402,14 @@ function extractInlineModelsFromProperties(schema, results, parentName) {
402
402
  extractInlineModelsFromProperties(items, results, modelName);
403
403
  }
404
404
  }
405
+ if (fieldSchema.allOf && fieldSchema.allOf.every((s) => !s.$ref && !s.oneOf && !s.anyOf)) {
406
+ const merged = mergeAllOfObjectSchema(fieldSchema);
407
+ if (Object.keys(merged.properties ?? {}).length > 0) {
408
+ const modelName = qualifyInlineModelName(toPascalCase(fieldName), parentName);
409
+ results.push(buildInlineModel(modelName, merged));
410
+ extractInlineModelsFromProperties(merged, results, modelName);
411
+ }
412
+ }
405
413
  if (fieldSchema.oneOf) {
406
414
  const inlineObjectVariants = fieldSchema.oneOf.filter((v) => !v.$ref && v.properties && (v.type === "object" || !v.type));
407
415
  if (inlineObjectVariants.length > 0) {
@@ -461,6 +469,31 @@ function nameOneOfVariant(variant, parentName, alreadyEmitted, discriminatorProp
461
469
  }
462
470
  return `${parentName}${alreadyEmitted.length + 1}`;
463
471
  }
472
+ /**
473
+ * Merge the object members of an `allOf` (recursively) into a single
474
+ * object-shaped schema, so an inline object expressed via `allOf` can be
475
+ * materialized as one model — mirroring how schemaToTypeRef collapses such a
476
+ * field into a single merged model ref. Earlier members win on key conflicts,
477
+ * matching the merge order used elsewhere in the parser.
478
+ */
479
+ function mergeAllOfObjectSchema(schema) {
480
+ const properties = {};
481
+ const required = [];
482
+ const visit = (s) => {
483
+ if (s.properties) {
484
+ for (const [key, value] of Object.entries(s.properties)) if (value && !(key in properties)) properties[key] = value;
485
+ }
486
+ if (s.required) required.push(...s.required);
487
+ if (s.allOf) for (const sub of s.allOf) visit(sub);
488
+ };
489
+ visit(schema);
490
+ return {
491
+ type: "object",
492
+ properties,
493
+ required,
494
+ description: schema.description
495
+ };
496
+ }
464
497
  function buildInlineModel(name, schema) {
465
498
  const requiredSet = new Set(schema.required ?? []);
466
499
  const fields = [];
@@ -2344,6 +2377,7 @@ function extractRequestBody(body, op, inlineModels) {
2344
2377
  description: void 0,
2345
2378
  fields
2346
2379
  });
2380
+ extractInlineModelsFromProperties(schema, inlineModels, contextName);
2347
2381
  return {
2348
2382
  body: {
2349
2383
  kind: "model",
@@ -2370,6 +2404,7 @@ function extractRequestBody(body, op, inlineModels) {
2370
2404
  description: variant.description,
2371
2405
  fields
2372
2406
  });
2407
+ extractInlineModelsFromProperties(variant, inlineModels, variantName);
2373
2408
  variants.push({
2374
2409
  kind: "model",
2375
2410
  name: variantName