@workos/oagen 0.24.4 → 0.24.5
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 +37 -11
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.mjs +37 -11
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +37 -11
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.mjs +37 -11
- package/dist/smoke.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1344,7 +1344,7 @@ function detectPagination(response, queryParams, dataPath) {
|
|
|
1344
1344
|
}
|
|
1345
1345
|
//#endregion
|
|
1346
1346
|
//#region src/parser/responses.ts
|
|
1347
|
-
function classifyAndExtractResponse(schema, contextName) {
|
|
1347
|
+
function classifyAndExtractResponse(schema, contextName, componentSchemas) {
|
|
1348
1348
|
if (schema.$ref) return {
|
|
1349
1349
|
response: schemaToTypeRef(schema, contextName),
|
|
1350
1350
|
inlineModels: [],
|
|
@@ -1353,7 +1353,7 @@ function classifyAndExtractResponse(schema, contextName) {
|
|
|
1353
1353
|
const envelope = detectListEnvelope(schema);
|
|
1354
1354
|
if (envelope.isEnvelope) return extractListResponse(schema, contextName, envelope.dataPath);
|
|
1355
1355
|
if (isSingleResourceWrapper(schema)) return extractWrappedResource(schema, contextName);
|
|
1356
|
-
return extractDirectResource(schema, contextName);
|
|
1356
|
+
return extractDirectResource(schema, contextName, componentSchemas);
|
|
1357
1357
|
}
|
|
1358
1358
|
const KNOWN_DATA_PATHS = new Set([
|
|
1359
1359
|
"data",
|
|
@@ -1530,7 +1530,7 @@ function extractWrappedResource(schema, contextName) {
|
|
|
1530
1530
|
isPaginated: false
|
|
1531
1531
|
};
|
|
1532
1532
|
}
|
|
1533
|
-
function extractDirectResource(schema, contextName) {
|
|
1533
|
+
function extractDirectResource(schema, contextName, componentSchemas) {
|
|
1534
1534
|
const inlineModels = [];
|
|
1535
1535
|
if (schema.properties && (schema.type === "object" || !schema.type)) {
|
|
1536
1536
|
const modelName = deriveModelName(schema, contextName);
|
|
@@ -1547,17 +1547,43 @@ function extractDirectResource(schema, contextName) {
|
|
|
1547
1547
|
if (schema.allOf) {
|
|
1548
1548
|
const mergedProperties = {};
|
|
1549
1549
|
const mergedRequired = [];
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1550
|
+
const unresolvedRefs = [];
|
|
1551
|
+
const seenRefs = /* @__PURE__ */ new Set();
|
|
1552
|
+
let mergedRefFields = false;
|
|
1553
|
+
const mergeSubSchemas = (subs) => {
|
|
1554
|
+
for (const sub of subs) {
|
|
1555
|
+
let resolved = sub;
|
|
1556
|
+
if (sub.$ref) {
|
|
1557
|
+
if (seenRefs.has(sub.$ref)) continue;
|
|
1558
|
+
seenRefs.add(sub.$ref);
|
|
1559
|
+
const segments = sub.$ref.split("/");
|
|
1560
|
+
const refName = segments[segments.length - 1];
|
|
1561
|
+
const refSchema = refName ? componentSchemas?.[refName] : void 0;
|
|
1562
|
+
if (!refSchema) {
|
|
1563
|
+
unresolvedRefs.push(sub.$ref);
|
|
1564
|
+
continue;
|
|
1565
|
+
}
|
|
1566
|
+
resolved = refSchema;
|
|
1567
|
+
mergedRefFields = true;
|
|
1568
|
+
}
|
|
1569
|
+
if (resolved.allOf) mergeSubSchemas(resolved.allOf);
|
|
1570
|
+
if (resolved.properties) Object.assign(mergedProperties, resolved.properties);
|
|
1571
|
+
if (resolved.required) mergedRequired.push(...resolved.required);
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
mergeSubSchemas(schema.allOf);
|
|
1575
|
+
if (unresolvedRefs.length === 1 && !mergedRefFields) return {
|
|
1576
|
+
response: schemaToTypeRef({ $ref: unresolvedRefs[0] }, contextName),
|
|
1577
|
+
inlineModels,
|
|
1578
|
+
isPaginated: false
|
|
1579
|
+
};
|
|
1554
1580
|
if (Object.keys(mergedProperties).length > 0) {
|
|
1555
1581
|
const merged = {
|
|
1556
1582
|
type: "object",
|
|
1557
1583
|
properties: mergedProperties,
|
|
1558
1584
|
required: mergedRequired
|
|
1559
1585
|
};
|
|
1560
|
-
const modelName = deriveModelName(merged, contextName);
|
|
1586
|
+
const modelName = mergedRefFields ? toPascalCase(contextName) : deriveModelName(merged, contextName);
|
|
1561
1587
|
inlineModels.push(...extractInlineModel(modelName, merged));
|
|
1562
1588
|
return {
|
|
1563
1589
|
response: {
|
|
@@ -1960,7 +1986,7 @@ function buildOperation(method, path, op, pathLevelParams, operationIdTransform,
|
|
|
1960
1986
|
const cookieParams = extractParams(allParams, "cookie", opContext, componentSchemas);
|
|
1961
1987
|
const reqBodyModels = [];
|
|
1962
1988
|
const { body: requestBody, encoding: requestBodyEncoding } = extractRequestBody(op.requestBody, op, reqBodyModels);
|
|
1963
|
-
const { response, successResponses, errors, inlineModels, isPaginated, dataPath: responseDataPath, itemType: responseItemType } = extractResponses(op.responses, op, path, method);
|
|
1989
|
+
const { response, successResponses, errors, inlineModels, isPaginated, dataPath: responseDataPath, itemType: responseItemType } = extractResponses(op.responses, op, path, method, componentSchemas);
|
|
1964
1990
|
inlineModels.push(...reqBodyModels);
|
|
1965
1991
|
const paginationFromParams = detectPagination(response, queryParams, responseDataPath);
|
|
1966
1992
|
let pagination;
|
|
@@ -2253,7 +2279,7 @@ function deriveResponseName(op, path, method) {
|
|
|
2253
2279
|
if (op?.operationId) return cleanSchemaName(toPascalCase(normalizeOperationIdForNaming(op.operationId)) + "Response");
|
|
2254
2280
|
return toPascalCase(path.split("/").filter(Boolean)[0] ?? "Unknown") + toPascalCase(method) + "Response";
|
|
2255
2281
|
}
|
|
2256
|
-
function extractResponses(responses, op, path, method) {
|
|
2282
|
+
function extractResponses(responses, op, path, method, componentSchemas) {
|
|
2257
2283
|
const errors = [];
|
|
2258
2284
|
let response = {
|
|
2259
2285
|
kind: "primitive",
|
|
@@ -2280,7 +2306,7 @@ function extractResponses(responses, op, path, method) {
|
|
|
2280
2306
|
const jsonContent = resp.content?.["application/json"];
|
|
2281
2307
|
if (jsonContent?.schema) {
|
|
2282
2308
|
const contextName = deriveResponseName(op, path ?? "/", method ?? "get");
|
|
2283
|
-
const result = classifyAndExtractResponse(jsonContent.schema, contextName);
|
|
2309
|
+
const result = classifyAndExtractResponse(jsonContent.schema, contextName, componentSchemas);
|
|
2284
2310
|
extractedType = result.response;
|
|
2285
2311
|
inlineModels = result.inlineModels;
|
|
2286
2312
|
isPaginated = result.isPaginated;
|