@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/cli/index.mjs
CHANGED
|
@@ -1614,7 +1614,7 @@ function detectPagination(response, queryParams, dataPath) {
|
|
|
1614
1614
|
}
|
|
1615
1615
|
//#endregion
|
|
1616
1616
|
//#region src/parser/responses.ts
|
|
1617
|
-
function classifyAndExtractResponse(schema, contextName) {
|
|
1617
|
+
function classifyAndExtractResponse(schema, contextName, componentSchemas) {
|
|
1618
1618
|
if (schema.$ref) return {
|
|
1619
1619
|
response: schemaToTypeRef(schema, contextName),
|
|
1620
1620
|
inlineModels: [],
|
|
@@ -1623,7 +1623,7 @@ function classifyAndExtractResponse(schema, contextName) {
|
|
|
1623
1623
|
const envelope = detectListEnvelope(schema);
|
|
1624
1624
|
if (envelope.isEnvelope) return extractListResponse(schema, contextName, envelope.dataPath);
|
|
1625
1625
|
if (isSingleResourceWrapper(schema)) return extractWrappedResource(schema, contextName);
|
|
1626
|
-
return extractDirectResource(schema, contextName);
|
|
1626
|
+
return extractDirectResource(schema, contextName, componentSchemas);
|
|
1627
1627
|
}
|
|
1628
1628
|
const KNOWN_DATA_PATHS = new Set([
|
|
1629
1629
|
"data",
|
|
@@ -1800,7 +1800,7 @@ function extractWrappedResource(schema, contextName) {
|
|
|
1800
1800
|
isPaginated: false
|
|
1801
1801
|
};
|
|
1802
1802
|
}
|
|
1803
|
-
function extractDirectResource(schema, contextName) {
|
|
1803
|
+
function extractDirectResource(schema, contextName, componentSchemas) {
|
|
1804
1804
|
const inlineModels = [];
|
|
1805
1805
|
if (schema.properties && (schema.type === "object" || !schema.type)) {
|
|
1806
1806
|
const modelName = deriveModelName(schema, contextName);
|
|
@@ -1817,17 +1817,43 @@ function extractDirectResource(schema, contextName) {
|
|
|
1817
1817
|
if (schema.allOf) {
|
|
1818
1818
|
const mergedProperties = {};
|
|
1819
1819
|
const mergedRequired = [];
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1820
|
+
const unresolvedRefs = [];
|
|
1821
|
+
const seenRefs = /* @__PURE__ */ new Set();
|
|
1822
|
+
let mergedRefFields = false;
|
|
1823
|
+
const mergeSubSchemas = (subs) => {
|
|
1824
|
+
for (const sub of subs) {
|
|
1825
|
+
let resolved = sub;
|
|
1826
|
+
if (sub.$ref) {
|
|
1827
|
+
if (seenRefs.has(sub.$ref)) continue;
|
|
1828
|
+
seenRefs.add(sub.$ref);
|
|
1829
|
+
const segments = sub.$ref.split("/");
|
|
1830
|
+
const refName = segments[segments.length - 1];
|
|
1831
|
+
const refSchema = refName ? componentSchemas?.[refName] : void 0;
|
|
1832
|
+
if (!refSchema) {
|
|
1833
|
+
unresolvedRefs.push(sub.$ref);
|
|
1834
|
+
continue;
|
|
1835
|
+
}
|
|
1836
|
+
resolved = refSchema;
|
|
1837
|
+
mergedRefFields = true;
|
|
1838
|
+
}
|
|
1839
|
+
if (resolved.allOf) mergeSubSchemas(resolved.allOf);
|
|
1840
|
+
if (resolved.properties) Object.assign(mergedProperties, resolved.properties);
|
|
1841
|
+
if (resolved.required) mergedRequired.push(...resolved.required);
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
mergeSubSchemas(schema.allOf);
|
|
1845
|
+
if (unresolvedRefs.length === 1 && !mergedRefFields) return {
|
|
1846
|
+
response: schemaToTypeRef({ $ref: unresolvedRefs[0] }, contextName),
|
|
1847
|
+
inlineModels,
|
|
1848
|
+
isPaginated: false
|
|
1849
|
+
};
|
|
1824
1850
|
if (Object.keys(mergedProperties).length > 0) {
|
|
1825
1851
|
const merged = {
|
|
1826
1852
|
type: "object",
|
|
1827
1853
|
properties: mergedProperties,
|
|
1828
1854
|
required: mergedRequired
|
|
1829
1855
|
};
|
|
1830
|
-
const modelName = deriveModelName(merged, contextName);
|
|
1856
|
+
const modelName = mergedRefFields ? toPascalCase(contextName) : deriveModelName(merged, contextName);
|
|
1831
1857
|
inlineModels.push(...extractInlineModel(modelName, merged));
|
|
1832
1858
|
return {
|
|
1833
1859
|
response: {
|
|
@@ -2230,7 +2256,7 @@ function buildOperation(method, path, op, pathLevelParams, operationIdTransform,
|
|
|
2230
2256
|
const cookieParams = extractParams(allParams, "cookie", opContext, componentSchemas);
|
|
2231
2257
|
const reqBodyModels = [];
|
|
2232
2258
|
const { body: requestBody, encoding: requestBodyEncoding } = extractRequestBody(op.requestBody, op, reqBodyModels);
|
|
2233
|
-
const { response, successResponses, errors, inlineModels, isPaginated, dataPath: responseDataPath, itemType: responseItemType } = extractResponses(op.responses, op, path, method);
|
|
2259
|
+
const { response, successResponses, errors, inlineModels, isPaginated, dataPath: responseDataPath, itemType: responseItemType } = extractResponses(op.responses, op, path, method, componentSchemas);
|
|
2234
2260
|
inlineModels.push(...reqBodyModels);
|
|
2235
2261
|
const paginationFromParams = detectPagination(response, queryParams, responseDataPath);
|
|
2236
2262
|
let pagination;
|
|
@@ -2523,7 +2549,7 @@ function deriveResponseName(op, path, method) {
|
|
|
2523
2549
|
if (op?.operationId) return cleanSchemaName(toPascalCase(normalizeOperationIdForNaming(op.operationId)) + "Response");
|
|
2524
2550
|
return toPascalCase(path.split("/").filter(Boolean)[0] ?? "Unknown") + toPascalCase(method) + "Response";
|
|
2525
2551
|
}
|
|
2526
|
-
function extractResponses(responses, op, path, method) {
|
|
2552
|
+
function extractResponses(responses, op, path, method, componentSchemas) {
|
|
2527
2553
|
const errors = [];
|
|
2528
2554
|
let response = {
|
|
2529
2555
|
kind: "primitive",
|
|
@@ -2550,7 +2576,7 @@ function extractResponses(responses, op, path, method) {
|
|
|
2550
2576
|
const jsonContent = resp.content?.["application/json"];
|
|
2551
2577
|
if (jsonContent?.schema) {
|
|
2552
2578
|
const contextName = deriveResponseName(op, path ?? "/", method ?? "get");
|
|
2553
|
-
const result = classifyAndExtractResponse(jsonContent.schema, contextName);
|
|
2579
|
+
const result = classifyAndExtractResponse(jsonContent.schema, contextName, componentSchemas);
|
|
2554
2580
|
extractedType = result.response;
|
|
2555
2581
|
inlineModels = result.inlineModels;
|
|
2556
2582
|
isPaginated = result.isPaginated;
|