@workos/oagen 0.6.0 → 0.8.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.
- package/dist/cli/index.mjs +1339 -451
- package/dist/cli/index.mjs.map +1 -1
- package/dist/compat/index.d.mts +144 -57
- package/dist/compat/index.d.mts.map +1 -1
- package/dist/compat/index.mjs +365 -35
- package/dist/compat/index.mjs.map +1 -1
- package/dist/{diff-CltJMcwG.mjs → diff-BaH9qa8k.mjs} +100 -23
- package/dist/diff-BaH9qa8k.mjs.map +1 -0
- package/dist/differ-CTl98yoS.d.mts +116 -0
- package/dist/differ-CTl98yoS.d.mts.map +1 -0
- package/dist/index.d.mts +4 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +177 -4
- package/dist/index.mjs.map +1 -1
- package/dist/{differ-CG5ZErKl.mjs → overlay-TYxHOCow.mjs} +1112 -553
- package/dist/overlay-TYxHOCow.mjs.map +1 -0
- package/dist/scripts/smoke/baseline.mjs +176 -3
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.d.mts +43 -0
- package/dist/smoke.d.mts.map +1 -1
- package/dist/smoke.mjs +176 -3
- package/dist/smoke.mjs.map +1 -1
- package/dist/tree-sitter-C53w_0WE.mjs.map +1 -1
- package/dist/{types-C7g5sLuX.d.mts → types-mTtkgy_h.d.mts} +213 -2
- package/dist/types-mTtkgy_h.d.mts.map +1 -0
- package/dist/verify/index.d.mts +4 -3
- package/dist/verify/index.d.mts.map +1 -1
- package/dist/verify/index.mjs +12 -10
- package/dist/verify/index.mjs.map +1 -1
- package/docs/architecture/emitter-contract.md +2 -2
- package/docs/architecture/extractor-contract.md +6 -5
- package/docs/architecture/pipeline.md +4 -3
- package/docs/architecture/workflows.md +5 -3
- package/docs/cli.md +148 -6
- package/docs/contributor/public-api.md +1 -1
- package/docs/core/compatibility-ir.md +200 -0
- package/docs/core/compatibility-policy.md +170 -0
- package/docs/core/compatibility.md +83 -0
- package/docs/core/index.md +5 -0
- package/docs/core/manifest-schema.md +76 -0
- package/docs/core/quickstart.md +9 -2
- package/docs/core/verify-compat.md +235 -0
- package/package.json +1 -1
- package/skills/generate-emitter/SKILL.md +12 -7
- package/skills/generate-emitter/references/project-scaffold.md +27 -6
- package/skills/generate-extractor/SKILL.md +14 -8
- package/skills/generate-sdk/SKILL.md +2 -2
- package/skills/generate-smoke-test/SKILL.md +9 -5
- package/skills/review-operations/SKILL.md +2 -2
- package/skills/verify-compat/SKILL.md +1 -1
- package/dist/diff-CltJMcwG.mjs.map +0 -1
- package/dist/differ-CG5ZErKl.mjs.map +0 -1
- package/dist/types-C7g5sLuX.d.mts.map +0 -1
package/dist/smoke.d.mts
CHANGED
|
@@ -190,6 +190,39 @@ interface Operation {
|
|
|
190
190
|
async?: boolean;
|
|
191
191
|
/** Per-operation security overrides. When present, overrides the global spec-level security. */
|
|
192
192
|
security?: SecurityRequirement[];
|
|
193
|
+
/**
|
|
194
|
+
* Mutually-exclusive parameter groups parsed from `x-mutually-exclusive-parameter-groups`.
|
|
195
|
+
* Each group represents a logical choice the caller must (or may) make between
|
|
196
|
+
* several subsets of query/path/header parameters. The grouped parameters remain
|
|
197
|
+
* in their original arrays (queryParams, pathParams, etc.) for wire-format purposes;
|
|
198
|
+
* this field adds the grouping metadata so emitters can render sum types.
|
|
199
|
+
*/
|
|
200
|
+
parameterGroups?: ParameterGroup[];
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* A mutually-exclusive parameter group. The caller must supply exactly one
|
|
204
|
+
* variant (when `optional` is false) or may omit the group entirely (when true).
|
|
205
|
+
*/
|
|
206
|
+
interface ParameterGroup {
|
|
207
|
+
/** Group name from the extension (e.g. "parent_resource"). */
|
|
208
|
+
name: string;
|
|
209
|
+
/** True when the whole group may be omitted. */
|
|
210
|
+
optional: boolean;
|
|
211
|
+
/** Ordered variants (insertion order matches the spec). */
|
|
212
|
+
variants: ParameterGroupVariant[];
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* One variant within a mutually-exclusive parameter group.
|
|
216
|
+
*/
|
|
217
|
+
interface ParameterGroupVariant {
|
|
218
|
+
/** Variant name from the extension (e.g. "by_id", "by_external_id"). */
|
|
219
|
+
name: string;
|
|
220
|
+
/**
|
|
221
|
+
* References to the actual parameter IR nodes. These are the same
|
|
222
|
+
* objects that live in operation.queryParams / .pathParams / .headerParams --
|
|
223
|
+
* shared by identity, not duplicated.
|
|
224
|
+
*/
|
|
225
|
+
parameters: Parameter[];
|
|
193
226
|
}
|
|
194
227
|
/** Structured pagination metadata for auto-paging iterator generation */
|
|
195
228
|
interface PaginationMeta {
|
|
@@ -272,6 +305,16 @@ interface Model {
|
|
|
272
305
|
fields: Field[];
|
|
273
306
|
/** Generic type parameters. Empty/undefined for non-generic models. */
|
|
274
307
|
typeParams?: TypeParam[];
|
|
308
|
+
/**
|
|
309
|
+
* When set, this model is a discriminated union over allOf+oneOf variants.
|
|
310
|
+
* Emitters should generate a dispatcher (factory) instead of a regular dataclass.
|
|
311
|
+
* The `property` field is the discriminator key (e.g. "event"), and `mapping`
|
|
312
|
+
* maps each discriminator value to the concrete variant model name.
|
|
313
|
+
*/
|
|
314
|
+
discriminator?: {
|
|
315
|
+
property: string;
|
|
316
|
+
mapping: Record<string, string>;
|
|
317
|
+
};
|
|
275
318
|
}
|
|
276
319
|
interface Field {
|
|
277
320
|
name: string;
|
package/dist/smoke.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smoke.d.mts","names":[],"sources":["../src/ir/sdk-behavior.ts","../src/ir/types.ts","../src/parser/parse.ts","../src/utils/naming.ts","../scripts/smoke/shared.ts"],"mappings":";;;;AAYA;;;;;;UAAiB,WAAA;EAQf;EANA,oBAAA;EAQS;EANT,UAAA;EAMwB;EAJxB,sBAAA;EAY8B;EAV9B,cAAA;EAU8B;EAR9B,OAAA,EAAS,eAAA;AAAA;;;;;AAsBX;UAdiB,eAAA;;EAEf,Y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AAA;EACV,MAAA,EAAQ,KAAA;EACR,KAAA,EAAO,IAAA;EACP,IAAA,GAAO,UAAA;EDsBP;ECpBA,GAAA,EAAK,WAAA;AAAA;;UAIU,OAAA;EACf,IAAA;EACA,WAAA;EACA,UAAA,EAAY,SAAA;AAAA;;;UAKG,mBAAA;EACf,UAAA;EACA,MAAA;AAAA;AAAA,UAGe,SAAA;EACf,IAAA;EACA,WAAA;EACA,UAAA,EAAY,UAAA;EACZ,IAAA;EACA,UAAA,EAAY,SAAA;EACZ,WAAA,EAAa,SAAA;EACb,YAAA,EAAc,SAAA;EACd,YAAA,GAAe,SAAA;EACf,WAAA,GAAc,OAAA;EACd,mBAAA;EACA,QAAA,EAAU,OAAA;EACV,gBAAA,GAAmB,eAAA;EACnB,MAAA,EAAQ,aAAA;EACR,UAAA,GAAa,cAAA;EACb,oBAAA;EACA,UAAA;EACA,KAAA;EDiCgB;EC/BhB,QAAA,GAAW,mBAAA;AAAA;;
|
|
1
|
+
{"version":3,"file":"smoke.d.mts","names":[],"sources":["../src/ir/sdk-behavior.ts","../src/ir/types.ts","../src/parser/parse.ts","../src/utils/naming.ts","../scripts/smoke/shared.ts"],"mappings":";;;;AAYA;;;;;;UAAiB,WAAA;EAQf;EANA,oBAAA;EAQS;EANT,UAAA;EAMwB;EAJxB,sBAAA;EAY8B;EAV9B,cAAA;EAU8B;EAR9B,OAAA,EAAS,eAAA;AAAA;;;;;AAsBX;UAdiB,eAAA;;EAEf,YAAA;EAeA;EAbA,UAAA;EAeA;EAbA,QAAA;EAkBA;EAhBA,YAAA;AAAA;AAsBF;AAAA,UAhBiB,WAAA;;;EAGf,aAAA,EAAe,MAAA;EAiBf;EAfA,eAAA;EAiBe;EAff,eAAA;EAqBe;;EAlBf,mBAAA;AAAA;;UAMe,eAAA;EAoBiB;EAlBhC,gBAAA;EAoBA;EAlBA,UAAA;EA0Be;EAxBf,eAAA;AAAA;;UAMe,gBAAA;EAsBf;EApBA,eAAA;AAAA;;UAMe,iBA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AW,IAAA,EAAM,OAAA,GAAU,MAAA;;iBAsBnD,wBAAA,CAAyB,EAAA,EAAI,SAAA,EAAW,IAAA,EAAM,OAAA,GAAU,MAAA;AAAA,cAoB3D,UAAA;EAAA,QACH,GAAA;EAER,GAAA,CAAI,OAAA,UAAiB,KAAA,UAAe,KAAA;EAIpC,GAAA,CAAI,OAAA,UAAiB,KAAA;EJvSR;EI4Sb,iBAAA,CAAkB,EAAA,EAAI,SAAA,EAAW,OAAA,WAAkB,MAAA;EJ3S1C;EAAA,QI4TD,kBAAA;EJ3TG;;;;;;EAAA,QI+UH,oBAAA;;;;AH7eV;UGohBU,mBAAA;;;;;UAgBA,kBAAA;EHliB+C;;;;;EG+iBvD,eAAA,CAAgB,OAAA,UAAiB,YAAA,WAAuB,UAAA;EH1iBzC;EAAA,QGglBP,gBAAA;AAAA;;iBAiBM,sBAAA,CAAuB,EAAA,EAAI,SAAA;AH3lB3C;AAAA,iBGinBgB,kBAAA,CAAmB,MAAA,UAAgB,EAAA,EAAI,SAAA;AAAA,iBAUvC,WAAA,CAAY,EAAA,EAAI,SAAA,EAAW,UAAA,EAAY,MAAA;AAAA,iBAYvC,KAAA,CAAM,EAAA,WAAa,OAAA;AAAA,iBAInB,YAAA,CAAA;EAAkB,IAAA;EAAc,OAAA;EAAkB,WAAA;AAAA"}
|
package/dist/smoke.mjs
CHANGED
|
@@ -550,7 +550,7 @@ function findSchemaByName(pascalName, schemas) {
|
|
|
550
550
|
for (const [k, v] of Object.entries(schemas)) if (resolveSchemaName(k) === pascalName) return v;
|
|
551
551
|
return null;
|
|
552
552
|
}
|
|
553
|
-
/** Walk into a schema to find a field's sub-schema, resolving allOf. */
|
|
553
|
+
/** Walk into a schema to find a field's sub-schema, resolving allOf and oneOf/anyOf. */
|
|
554
554
|
function findNestedFieldSchema(fieldName, parentSchema, schemas) {
|
|
555
555
|
if (parentSchema.properties?.[fieldName]) return parentSchema.properties[fieldName];
|
|
556
556
|
if (parentSchema.allOf) for (const sub of parentSchema.allOf) {
|
|
@@ -562,6 +562,15 @@ function findNestedFieldSchema(fieldName, parentSchema, schemas) {
|
|
|
562
562
|
}
|
|
563
563
|
if (resolved.properties?.[fieldName]) return resolved.properties[fieldName];
|
|
564
564
|
}
|
|
565
|
+
for (const variant of [...parentSchema.oneOf ?? [], ...parentSchema.anyOf ?? []]) {
|
|
566
|
+
let resolved = variant;
|
|
567
|
+
if (variant.$ref) {
|
|
568
|
+
const segments = variant.$ref.split("/");
|
|
569
|
+
const refName = segments[segments.length - 1];
|
|
570
|
+
if (refName && schemas[refName]) resolved = schemas[refName];
|
|
571
|
+
}
|
|
572
|
+
if (resolved.properties?.[fieldName]) return resolved.properties[fieldName];
|
|
573
|
+
}
|
|
565
574
|
return null;
|
|
566
575
|
}
|
|
567
576
|
/** Extract a model (and nested models) from an inline field schema. */
|
|
@@ -727,6 +736,19 @@ function extractModel(name, schema, schemas) {
|
|
|
727
736
|
if (!fieldSchema) continue;
|
|
728
737
|
fields.push(buildFieldFromSchema(fieldName, fieldSchema, name, requiredSet));
|
|
729
738
|
}
|
|
739
|
+
if (fields.length === 0 && (schema.oneOf || schema.anyOf)) {
|
|
740
|
+
const variants = schema.oneOf ?? schema.anyOf ?? [];
|
|
741
|
+
const emptyRequired = /* @__PURE__ */ new Set();
|
|
742
|
+
const seenFieldNames = /* @__PURE__ */ new Set();
|
|
743
|
+
for (const variant of variants) {
|
|
744
|
+
if (!variant.properties) continue;
|
|
745
|
+
for (const [fieldName, fieldSchema] of Object.entries(variant.properties)) {
|
|
746
|
+
if (!fieldSchema || seenFieldNames.has(fieldName)) continue;
|
|
747
|
+
seenFieldNames.add(fieldName);
|
|
748
|
+
fields.push(buildFieldFromSchema(fieldName, fieldSchema, name, emptyRequired));
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
730
752
|
if (schema.additionalProperties && typeof schema.additionalProperties === "object" && schema.properties) {
|
|
731
753
|
if (Object.keys(schema.additionalProperties).length > 0) {
|
|
732
754
|
const valueType = schemaToTypeRef(schema.additionalProperties, "additionalProperties", name);
|
|
@@ -750,6 +772,7 @@ function extractModel(name, schema, schemas) {
|
|
|
750
772
|
function extractAllOfModel(name, schema, schemas) {
|
|
751
773
|
const fields = [];
|
|
752
774
|
const requiredSet = /* @__PURE__ */ new Set();
|
|
775
|
+
let resultDiscriminator;
|
|
753
776
|
for (const subSchema of schema.allOf ?? []) {
|
|
754
777
|
let resolved = subSchema;
|
|
755
778
|
if (subSchema.$ref && schemas) {
|
|
@@ -766,6 +789,22 @@ function extractAllOfModel(name, schema, schemas) {
|
|
|
766
789
|
});
|
|
767
790
|
if (f.required) requiredSet.add(f.name);
|
|
768
791
|
}
|
|
792
|
+
} else if (resolved.oneOf || resolved.anyOf) {
|
|
793
|
+
const variants = resolved.oneOf ?? resolved.anyOf ?? [];
|
|
794
|
+
const discriminatorInfo = detectAllOfVariantDiscriminator(variants, name);
|
|
795
|
+
if (discriminatorInfo) resultDiscriminator = discriminatorInfo;
|
|
796
|
+
else {
|
|
797
|
+
const emptyRequired = /* @__PURE__ */ new Set();
|
|
798
|
+
const seenFieldNames = new Set(fields.map((f) => f.name));
|
|
799
|
+
for (const variant of variants) {
|
|
800
|
+
if (!variant.properties) continue;
|
|
801
|
+
for (const [fieldName, fieldSchema] of Object.entries(variant.properties)) {
|
|
802
|
+
if (!fieldSchema || seenFieldNames.has(fieldName)) continue;
|
|
803
|
+
seenFieldNames.add(fieldName);
|
|
804
|
+
fields.push(buildFieldFromSchema(fieldName, fieldSchema, name, emptyRequired));
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
769
808
|
} else {
|
|
770
809
|
if (resolved.required) for (const r of resolved.required) requiredSet.add(r);
|
|
771
810
|
if (resolved.properties) {
|
|
@@ -782,7 +821,42 @@ function extractAllOfModel(name, schema, schemas) {
|
|
|
782
821
|
return {
|
|
783
822
|
name,
|
|
784
823
|
description: schema.description,
|
|
785
|
-
fields
|
|
824
|
+
fields,
|
|
825
|
+
...resultDiscriminator ? { discriminator: resultDiscriminator } : {}
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Detect an implicit discriminator on an allOf+oneOf where every variant is an
|
|
830
|
+
* object that pins the same property to a distinct const value. Unlike
|
|
831
|
+
* detectConstPropertyDiscriminator (which requires $ref or title for variant
|
|
832
|
+
* model names), this version derives model names from the const value itself
|
|
833
|
+
* using deriveDiscriminatedVariantName — matching how extractDiscriminatedAllOfVariantModels
|
|
834
|
+
* names those models.
|
|
835
|
+
*
|
|
836
|
+
* Returns null when no discriminator can be reliably detected.
|
|
837
|
+
*/
|
|
838
|
+
function detectAllOfVariantDiscriminator(variants, fallbackName) {
|
|
839
|
+
if (variants.length < 2) return null;
|
|
840
|
+
const candidates = Object.keys(variants[0]?.properties ?? {});
|
|
841
|
+
let candidateProperty = null;
|
|
842
|
+
for (const propName of candidates) if (variants.every((v) => getConstPropertyValue(v, propName) !== null)) {
|
|
843
|
+
candidateProperty = propName;
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
if (!candidateProperty) return null;
|
|
847
|
+
const mapping = {};
|
|
848
|
+
const seenModelNames = /* @__PURE__ */ new Set();
|
|
849
|
+
for (const v of variants) {
|
|
850
|
+
const value = getConstPropertyValue(v, candidateProperty);
|
|
851
|
+
if (value === null) return null;
|
|
852
|
+
const modelName = deriveDiscriminatedVariantName(v, fallbackName);
|
|
853
|
+
if (seenModelNames.has(modelName)) return null;
|
|
854
|
+
seenModelNames.add(modelName);
|
|
855
|
+
mapping[value] = modelName;
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
property: candidateProperty,
|
|
859
|
+
mapping
|
|
786
860
|
};
|
|
787
861
|
}
|
|
788
862
|
function extractDiscriminatedAllOfVariantModels(schema, fallbackName) {
|
|
@@ -1622,6 +1696,94 @@ function inferDeeperContext(path) {
|
|
|
1622
1696
|
if (nonParams.length >= 3) return toPascalCase(nonParams.slice(1, -1).join("_"));
|
|
1623
1697
|
return null;
|
|
1624
1698
|
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Extract mutually-exclusive parameter groups from the `x-mutually-exclusive-parameter-groups`
|
|
1701
|
+
* operation extension. Cross-references grouped parameter names against the already-extracted
|
|
1702
|
+
* IR parameter arrays so emitters get object-identity references.
|
|
1703
|
+
*/
|
|
1704
|
+
function extractParameterGroups(op, allIRParams, operationContext) {
|
|
1705
|
+
const raw = op["x-mutually-exclusive-parameter-groups"];
|
|
1706
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
1707
|
+
const paramByName = /* @__PURE__ */ new Map();
|
|
1708
|
+
for (const p of allIRParams) paramByName.set(p.name, p);
|
|
1709
|
+
const groups = [];
|
|
1710
|
+
for (const [groupName, groupDef] of Object.entries(raw)) {
|
|
1711
|
+
if (!groupDef || typeof groupDef !== "object") throw new Error(`Malformed x-mutually-exclusive-parameter-groups.${groupName} in ${operationContext}: expected an object with "optional" and "variants".`);
|
|
1712
|
+
if (typeof groupDef.optional !== "boolean") throw new Error(`Malformed x-mutually-exclusive-parameter-groups.${groupName}.optional in ${operationContext}: expected a boolean.`);
|
|
1713
|
+
if (!groupDef.variants || typeof groupDef.variants !== "object") throw new Error(`Malformed x-mutually-exclusive-parameter-groups.${groupName}.variants in ${operationContext}: expected an object mapping variant names to parameter name arrays.`);
|
|
1714
|
+
if (Object.keys(groupDef.variants).length === 0) throw new Error(`Malformed x-mutually-exclusive-parameter-groups.${groupName} in ${operationContext}: group has zero variants.`);
|
|
1715
|
+
const variants = Object.entries(groupDef.variants).map(([variantName, paramNames]) => {
|
|
1716
|
+
if (!Array.isArray(paramNames) || paramNames.length === 0) throw new Error(`Malformed x-mutually-exclusive-parameter-groups.${groupName}.variants.${variantName} in ${operationContext}: expected a non-empty array of parameter names.`);
|
|
1717
|
+
return {
|
|
1718
|
+
name: variantName,
|
|
1719
|
+
parameters: paramNames.map((pName) => {
|
|
1720
|
+
const irParam = paramByName.get(pName);
|
|
1721
|
+
if (!irParam) throw new Error(`x-mutually-exclusive-parameter-groups.${groupName}.variants.${variantName} references parameter "${pName}" which does not exist in the operation's parameters[] (${operationContext}).`);
|
|
1722
|
+
return irParam;
|
|
1723
|
+
})
|
|
1724
|
+
};
|
|
1725
|
+
});
|
|
1726
|
+
groups.push({
|
|
1727
|
+
name: groupName,
|
|
1728
|
+
optional: groupDef.optional,
|
|
1729
|
+
variants
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
return groups.length > 0 ? groups : void 0;
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Extract mutually-exclusive body parameter groups from the
|
|
1736
|
+
* `x-mutually-exclusive-body-groups` operation extension. Unlike query
|
|
1737
|
+
* parameter groups (whose parameters live in operation.queryParams), body
|
|
1738
|
+
* group parameters are synthetic — built from the oneOf variant schemas in
|
|
1739
|
+
* the request body. Emitters use the group's presence to generate sum-type
|
|
1740
|
+
* interfaces and custom JSON marshalling instead of flat optional fields.
|
|
1741
|
+
*/
|
|
1742
|
+
function extractBodyParameterGroups(op, operationContext) {
|
|
1743
|
+
const raw = op["x-mutually-exclusive-body-groups"];
|
|
1744
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
1745
|
+
const bodySchema = op.requestBody?.content?.["application/json"]?.schema;
|
|
1746
|
+
const variantFieldSchemas = /* @__PURE__ */ new Map();
|
|
1747
|
+
if (bodySchema) {
|
|
1748
|
+
for (const sub of bodySchema.allOf ?? []) for (const variant of sub.oneOf ?? []) if (variant.properties) {
|
|
1749
|
+
for (const [name, fieldSchema] of Object.entries(variant.properties)) if (fieldSchema) variantFieldSchemas.set(name, fieldSchema);
|
|
1750
|
+
}
|
|
1751
|
+
for (const variant of bodySchema.oneOf ?? []) if (variant.properties) {
|
|
1752
|
+
for (const [name, fieldSchema] of Object.entries(variant.properties)) if (fieldSchema) variantFieldSchemas.set(name, fieldSchema);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
const groups = [];
|
|
1756
|
+
for (const [groupName, groupDef] of Object.entries(raw)) {
|
|
1757
|
+
if (!groupDef || typeof groupDef !== "object") continue;
|
|
1758
|
+
if (typeof groupDef.optional !== "boolean") continue;
|
|
1759
|
+
if (!groupDef.variants || typeof groupDef.variants !== "object") continue;
|
|
1760
|
+
if (Object.keys(groupDef.variants).length === 0) continue;
|
|
1761
|
+
const variants = Object.entries(groupDef.variants).map(([variantName, paramNames]) => {
|
|
1762
|
+
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.`);
|
|
1763
|
+
return {
|
|
1764
|
+
name: variantName,
|
|
1765
|
+
parameters: paramNames.map((pName) => {
|
|
1766
|
+
const fieldSchema = variantFieldSchemas.get(pName);
|
|
1767
|
+
return {
|
|
1768
|
+
name: pName,
|
|
1769
|
+
type: fieldSchema ? schemaToTypeRef(fieldSchema, toPascalCase(pName)) : {
|
|
1770
|
+
kind: "primitive",
|
|
1771
|
+
type: "string"
|
|
1772
|
+
},
|
|
1773
|
+
required: false,
|
|
1774
|
+
description: fieldSchema?.description
|
|
1775
|
+
};
|
|
1776
|
+
})
|
|
1777
|
+
};
|
|
1778
|
+
});
|
|
1779
|
+
groups.push({
|
|
1780
|
+
name: groupName,
|
|
1781
|
+
optional: groupDef.optional,
|
|
1782
|
+
variants
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
return groups.length > 0 ? groups : void 0;
|
|
1786
|
+
}
|
|
1625
1787
|
function buildOperation(method, path, op, pathLevelParams, operationIdTransform, serviceName) {
|
|
1626
1788
|
const allParams = [...pathLevelParams, ...op.parameters ?? []];
|
|
1627
1789
|
const hasIdempotencyHeader = allParams.some((p) => p.in === "header" && p.name.toLowerCase() === "idempotency-key");
|
|
@@ -1647,6 +1809,16 @@ function buildOperation(method, path, op, pathLevelParams, operationIdTransform,
|
|
|
1647
1809
|
};
|
|
1648
1810
|
} else if (paginationFromParams) pagination = paginationFromParams;
|
|
1649
1811
|
const security = extractOperationSecurity(op.security);
|
|
1812
|
+
const allIRParams = [
|
|
1813
|
+
...pathParams,
|
|
1814
|
+
...queryParams,
|
|
1815
|
+
...headerParams,
|
|
1816
|
+
...cookieParams
|
|
1817
|
+
];
|
|
1818
|
+
const opLabel = op.operationId ?? `${method.toUpperCase()} ${path}`;
|
|
1819
|
+
const queryParamGroups = extractParameterGroups(op, allIRParams, opLabel);
|
|
1820
|
+
const bodyParamGroups = extractBodyParameterGroups(op, opLabel);
|
|
1821
|
+
const parameterGroups = queryParamGroups || bodyParamGroups ? [...queryParamGroups ?? [], ...bodyParamGroups ?? []] : void 0;
|
|
1650
1822
|
return {
|
|
1651
1823
|
operation: {
|
|
1652
1824
|
name: inferOperationName(method, path, op.operationId, operationIdTransform),
|
|
@@ -1666,7 +1838,8 @@ function buildOperation(method, path, op, pathLevelParams, operationIdTransform,
|
|
|
1666
1838
|
injectIdempotencyKey: hasIdempotencyHeader,
|
|
1667
1839
|
deprecated: op.deprecated || void 0,
|
|
1668
1840
|
async: op["x-oagen-async"],
|
|
1669
|
-
security
|
|
1841
|
+
security,
|
|
1842
|
+
parameterGroups
|
|
1670
1843
|
},
|
|
1671
1844
|
inlineModels
|
|
1672
1845
|
};
|