@workos/oagen 0.28.1 → 0.29.0

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.
@@ -2255,20 +2255,24 @@ function extractBodyParameterGroups(op, operationContext) {
2255
2255
  if (Object.keys(groupDef.variants).length === 0) continue;
2256
2256
  const variants = Object.entries(groupDef.variants).map(([variantName, paramNames]) => {
2257
2257
  if (!Array.isArray(paramNames) || paramNames.length === 0) throw new Error(`Malformed x-mutually-exclusive-body-groups.${groupName}.variants.${variantName} in ${operationContext}: expected a non-empty array of parameter names.`);
2258
+ const parameters = paramNames.map((pName) => {
2259
+ const fieldSchema = variantFieldSchemas.get(pName);
2260
+ return {
2261
+ name: pName,
2262
+ type: fieldSchema ? schemaToTypeRef(fieldSchema, toPascalCase(pName)) : {
2263
+ kind: "primitive",
2264
+ type: "string"
2265
+ },
2266
+ required: false,
2267
+ description: fieldSchema?.description
2268
+ };
2269
+ });
2270
+ const rawOptionalFields = groupDef.optionalFields && typeof groupDef.optionalFields === "object" ? groupDef.optionalFields[variantName] : void 0;
2271
+ const optionalParameters = Array.isArray(rawOptionalFields) ? rawOptionalFields.filter((name) => typeof name === "string" && paramNames.includes(name)) : [];
2258
2272
  return {
2259
2273
  name: variantName,
2260
- parameters: paramNames.map((pName) => {
2261
- const fieldSchema = variantFieldSchemas.get(pName);
2262
- return {
2263
- name: pName,
2264
- type: fieldSchema ? schemaToTypeRef(fieldSchema, toPascalCase(pName)) : {
2265
- kind: "primitive",
2266
- type: "string"
2267
- },
2268
- required: false,
2269
- description: fieldSchema?.description
2270
- };
2271
- })
2274
+ parameters,
2275
+ ...optionalParameters.length > 0 ? { optionalParameters } : {}
2272
2276
  };
2273
2277
  });
2274
2278
  groups.push({