@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/index.mjs CHANGED
@@ -205,6 +205,14 @@ function extractInlineModelsFromProperties(schema, results, parentName) {
205
205
  extractInlineModelsFromProperties(items, results, modelName);
206
206
  }
207
207
  }
208
+ if (fieldSchema.allOf && fieldSchema.allOf.every((s) => !s.$ref && !s.oneOf && !s.anyOf)) {
209
+ const merged = mergeAllOfObjectSchema(fieldSchema);
210
+ if (Object.keys(merged.properties ?? {}).length > 0) {
211
+ const modelName = qualifyInlineModelName(toPascalCase(fieldName), parentName);
212
+ results.push(buildInlineModel(modelName, merged));
213
+ extractInlineModelsFromProperties(merged, results, modelName);
214
+ }
215
+ }
208
216
  if (fieldSchema.oneOf) {
209
217
  const inlineObjectVariants = fieldSchema.oneOf.filter((v) => !v.$ref && v.properties && (v.type === "object" || !v.type));
210
218
  if (inlineObjectVariants.length > 0) {
@@ -264,6 +272,31 @@ function nameOneOfVariant(variant, parentName, alreadyEmitted, discriminatorProp
264
272
  }
265
273
  return `${parentName}${alreadyEmitted.length + 1}`;
266
274
  }
275
+ /**
276
+ * Merge the object members of an `allOf` (recursively) into a single
277
+ * object-shaped schema, so an inline object expressed via `allOf` can be
278
+ * materialized as one model — mirroring how schemaToTypeRef collapses such a
279
+ * field into a single merged model ref. Earlier members win on key conflicts,
280
+ * matching the merge order used elsewhere in the parser.
281
+ */
282
+ function mergeAllOfObjectSchema(schema) {
283
+ const properties = {};
284
+ const required = [];
285
+ const visit = (s) => {
286
+ if (s.properties) {
287
+ for (const [key, value] of Object.entries(s.properties)) if (value && !(key in properties)) properties[key] = value;
288
+ }
289
+ if (s.required) required.push(...s.required);
290
+ if (s.allOf) for (const sub of s.allOf) visit(sub);
291
+ };
292
+ visit(schema);
293
+ return {
294
+ type: "object",
295
+ properties,
296
+ required,
297
+ description: schema.description
298
+ };
299
+ }
267
300
  function buildInlineModel(name, schema) {
268
301
  const requiredSet = new Set(schema.required ?? []);
269
302
  const fields = [];
@@ -2147,6 +2180,7 @@ function extractRequestBody(body, op, inlineModels) {
2147
2180
  description: void 0,
2148
2181
  fields
2149
2182
  });
2183
+ extractInlineModelsFromProperties(schema, inlineModels, contextName);
2150
2184
  return {
2151
2185
  body: {
2152
2186
  kind: "model",
@@ -2173,6 +2207,7 @@ function extractRequestBody(body, op, inlineModels) {
2173
2207
  description: variant.description,
2174
2208
  fields
2175
2209
  });
2210
+ extractInlineModelsFromProperties(variant, inlineModels, variantName);
2176
2211
  variants.push({
2177
2212
  kind: "model",
2178
2213
  name: variantName