@workos/oagen 0.28.1 → 0.29.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.
@@ -2182,20 +2182,24 @@ function extractBodyParameterGroups(op, operationContext) {
2182
2182
  if (Object.keys(groupDef.variants).length === 0) continue;
2183
2183
  const variants = Object.entries(groupDef.variants).map(([variantName, paramNames]) => {
2184
2184
  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.`);
2185
+ const parameters = paramNames.map((pName) => {
2186
+ const fieldSchema = variantFieldSchemas.get(pName);
2187
+ return {
2188
+ name: pName,
2189
+ type: fieldSchema ? schemaToTypeRef(fieldSchema, toPascalCase(pName)) : {
2190
+ kind: "primitive",
2191
+ type: "string"
2192
+ },
2193
+ required: false,
2194
+ description: fieldSchema?.description
2195
+ };
2196
+ });
2197
+ const rawOptionalFields = groupDef.optionalFields && typeof groupDef.optionalFields === "object" ? groupDef.optionalFields[variantName] : void 0;
2198
+ const optionalParameters = Array.isArray(rawOptionalFields) ? rawOptionalFields.filter((name) => typeof name === "string" && paramNames.includes(name)) : [];
2185
2199
  return {
2186
2200
  name: variantName,
2187
- parameters: paramNames.map((pName) => {
2188
- const fieldSchema = variantFieldSchemas.get(pName);
2189
- return {
2190
- name: pName,
2191
- type: fieldSchema ? schemaToTypeRef(fieldSchema, toPascalCase(pName)) : {
2192
- kind: "primitive",
2193
- type: "string"
2194
- },
2195
- required: false,
2196
- description: fieldSchema?.description
2197
- };
2198
- })
2201
+ parameters,
2202
+ ...optionalParameters.length > 0 ? { optionalParameters } : {}
2199
2203
  };
2200
2204
  });
2201
2205
  groups.push({