@workos/oagen 0.25.1 → 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/cli/index.mjs +35 -0
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{diff-BQn8Nv2c.mjs → diff-B9wlNAVX.mjs} +2 -2
- package/dist/{diff-BQn8Nv2c.mjs.map → diff-B9wlNAVX.mjs.map} +1 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +37 -2
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +35 -0
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.mjs +35 -0
- package/dist/smoke.mjs.map +1 -1
- package/dist/verify/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -475,6 +475,14 @@ function extractInlineModelsFromProperties(schema, results, parentName) {
|
|
|
475
475
|
extractInlineModelsFromProperties(items, results, modelName);
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
|
+
if (fieldSchema.allOf && fieldSchema.allOf.every((s) => !s.$ref && !s.oneOf && !s.anyOf)) {
|
|
479
|
+
const merged = mergeAllOfObjectSchema(fieldSchema);
|
|
480
|
+
if (Object.keys(merged.properties ?? {}).length > 0) {
|
|
481
|
+
const modelName = qualifyInlineModelName(toPascalCase(fieldName), parentName);
|
|
482
|
+
results.push(buildInlineModel(modelName, merged));
|
|
483
|
+
extractInlineModelsFromProperties(merged, results, modelName);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
478
486
|
if (fieldSchema.oneOf) {
|
|
479
487
|
const inlineObjectVariants = fieldSchema.oneOf.filter((v) => !v.$ref && v.properties && (v.type === "object" || !v.type));
|
|
480
488
|
if (inlineObjectVariants.length > 0) {
|
|
@@ -534,6 +542,31 @@ function nameOneOfVariant(variant, parentName, alreadyEmitted, discriminatorProp
|
|
|
534
542
|
}
|
|
535
543
|
return `${parentName}${alreadyEmitted.length + 1}`;
|
|
536
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Merge the object members of an `allOf` (recursively) into a single
|
|
547
|
+
* object-shaped schema, so an inline object expressed via `allOf` can be
|
|
548
|
+
* materialized as one model — mirroring how schemaToTypeRef collapses such a
|
|
549
|
+
* field into a single merged model ref. Earlier members win on key conflicts,
|
|
550
|
+
* matching the merge order used elsewhere in the parser.
|
|
551
|
+
*/
|
|
552
|
+
function mergeAllOfObjectSchema(schema) {
|
|
553
|
+
const properties = {};
|
|
554
|
+
const required = [];
|
|
555
|
+
const visit = (s) => {
|
|
556
|
+
if (s.properties) {
|
|
557
|
+
for (const [key, value] of Object.entries(s.properties)) if (value && !(key in properties)) properties[key] = value;
|
|
558
|
+
}
|
|
559
|
+
if (s.required) required.push(...s.required);
|
|
560
|
+
if (s.allOf) for (const sub of s.allOf) visit(sub);
|
|
561
|
+
};
|
|
562
|
+
visit(schema);
|
|
563
|
+
return {
|
|
564
|
+
type: "object",
|
|
565
|
+
properties,
|
|
566
|
+
required,
|
|
567
|
+
description: schema.description
|
|
568
|
+
};
|
|
569
|
+
}
|
|
537
570
|
function buildInlineModel(name, schema) {
|
|
538
571
|
const requiredSet = new Set(schema.required ?? []);
|
|
539
572
|
const fields = [];
|
|
@@ -2417,6 +2450,7 @@ function extractRequestBody(body, op, inlineModels) {
|
|
|
2417
2450
|
description: void 0,
|
|
2418
2451
|
fields
|
|
2419
2452
|
});
|
|
2453
|
+
extractInlineModelsFromProperties(schema, inlineModels, contextName);
|
|
2420
2454
|
return {
|
|
2421
2455
|
body: {
|
|
2422
2456
|
kind: "model",
|
|
@@ -2443,6 +2477,7 @@ function extractRequestBody(body, op, inlineModels) {
|
|
|
2443
2477
|
description: variant.description,
|
|
2444
2478
|
fields
|
|
2445
2479
|
});
|
|
2480
|
+
extractInlineModelsFromProperties(variant, inlineModels, variantName);
|
|
2446
2481
|
variants.push({
|
|
2447
2482
|
kind: "model",
|
|
2448
2483
|
name: variantName
|