@workos/oagen 0.21.0 → 0.21.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
@@ -382,7 +382,7 @@ function qualifyInlineModelName(baseName, parentName) {
382
382
  function extractInlineModelsFromSchemas(schemas) {
383
383
  if (!schemas) return [];
384
384
  const inlineModels = [];
385
- for (const [schemaName, schema] of Object.entries(schemas)) extractInlineModelsFromProperties(schema, inlineModels, cleanSchemaName(toPascalCase(schemaName)));
385
+ for (const [schemaName, schema] of Object.entries(schemas)) extractInlineModelsFromProperties(schema, inlineModels, resolveSchemaName(schemaName));
386
386
  return inlineModels;
387
387
  }
388
388
  function extractInlineModelsFromProperties(schema, results, parentName) {
@@ -2566,6 +2566,27 @@ function collapseJsonSuffixModels(models, services) {
2566
2566
  rewriteModelRefs(normalizedModels, services, jsonModel.name, baseModel.name);
2567
2567
  console.warn(`[oagen] Merged "${jsonModel.name}" into "${baseModel.name}" (${jsonModel.fields.length} fields, superset)`);
2568
2568
  }
2569
+ for (const { jsonModel, baseModel } of mergeCandidates) {
2570
+ const jsonPrefix = jsonModel.name;
2571
+ const basePrefix = baseModel.name;
2572
+ for (const model of normalizedModels) {
2573
+ if (toRemove.has(model.name)) continue;
2574
+ if (model.name.length <= jsonPrefix.length) continue;
2575
+ if (!model.name.startsWith(jsonPrefix)) continue;
2576
+ const newName = basePrefix + model.name.slice(jsonPrefix.length);
2577
+ const existing = byName.get(newName);
2578
+ if (existing && !toRemove.has(existing.name)) {
2579
+ toRemove.add(model.name);
2580
+ rewriteModelRefs(normalizedModels, services, model.name, newName);
2581
+ console.warn(`[oagen] Collapsed child "${model.name}" into existing "${newName}"`);
2582
+ } else {
2583
+ rewriteModelRefs(normalizedModels, services, model.name, newName);
2584
+ model.name = newName;
2585
+ byName.set(newName, model);
2586
+ console.warn(`[oagen] Renamed child "${jsonPrefix}…" → "${newName}"`);
2587
+ }
2588
+ }
2589
+ }
2569
2590
  return normalizedModels.filter((m) => !toRemove.has(m.name));
2570
2591
  }
2571
2592
  //#endregion
@@ -2618,8 +2639,10 @@ async function parseSpec(specPath, options) {
2618
2639
  if (!version.startsWith("3.")) throw new SpecParseError(`Unsupported OpenAPI version: ${version}. oagen requires OpenAPI 3.x`, `Update the spec to OpenAPI 3.0 or 3.1. If you are using Swagger 2.x, convert it first with \`npx swagger2openapi ${specPath}\`.`);
2619
2640
  const { models, enums } = extractSchemas(spec.components?.schemas, { schemaNameTransform: options?.schemaNameTransform });
2620
2641
  const { services, inlineModels } = extractOperations(spec.paths, options?.operationIdTransform, spec.components?.schemas);
2642
+ const responseNormalizedModels = mergeInlineResponseModels(models, inlineModels);
2643
+ const fieldInlineModels = extractInlineModelsFromSchemas(spec.components?.schemas);
2621
2644
  clearSchemaNameTransform();
2622
- const finalModels = collapseJsonSuffixModels(mergeFieldInlineModels(mergeInlineResponseModels(models, inlineModels), extractInlineModelsFromSchemas(spec.components?.schemas)), services);
2645
+ const finalModels = collapseJsonSuffixModels(mergeFieldInlineModels(responseNormalizedModels, fieldInlineModels), services);
2623
2646
  collectInlineEnumsFromModels(finalModels, enums);
2624
2647
  collectInlineEnumsFromOperations(services, enums);
2625
2648
  const auth = extractAuthSchemes(spec.components?.securitySchemes);