@workos/oagen 0.17.0 → 0.17.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.
- package/dist/cli/index.mjs +34 -5
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.mjs +34 -5
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +34 -5
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.mjs +34 -5
- package/dist/smoke.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -286,6 +286,14 @@ function buildInlineModel(name, schema) {
|
|
|
286
286
|
* to apply the same name transform to $ref model/enum references.
|
|
287
287
|
*/
|
|
288
288
|
let activeSchemaNameTransform = null;
|
|
289
|
+
/**
|
|
290
|
+
* Module-level set of resolved schema names whose components/schemas entry is
|
|
291
|
+
* an enum (i.e. has `enum:`). Populated by extractSchemas() so schemaToTypeRef()
|
|
292
|
+
* can classify a `$ref` to a top-level enum schema as `kind: 'enum'` instead of
|
|
293
|
+
* `kind: 'model'`. Without this, every `$ref` was naively returned as a model
|
|
294
|
+
* ref, even when the target was a shared enum like `PaginationOrder`.
|
|
295
|
+
*/
|
|
296
|
+
let activeEnumSchemaNames = /* @__PURE__ */ new Set();
|
|
289
297
|
/** Apply cleanSchemaName + the active transform (if any) to a raw schema name. */
|
|
290
298
|
function resolveSchemaName(rawName) {
|
|
291
299
|
let name = cleanSchemaName(toPascalCase(rawName));
|
|
@@ -311,6 +319,8 @@ function extractSchemas(schemas, options) {
|
|
|
311
319
|
for (const [, originals] of transformedToOriginals) if (originals.length > 1) for (const n of originals) unsafeToTransform.add(n);
|
|
312
320
|
activeSchemaNameTransform = (name) => unsafeToTransform.has(name) ? name : transform(name);
|
|
313
321
|
} else activeSchemaNameTransform = null;
|
|
322
|
+
activeEnumSchemaNames = /* @__PURE__ */ new Set();
|
|
323
|
+
for (const [name, schema] of Object.entries(schemas)) if (schema.enum) activeEnumSchemaNames.add(resolveSchemaName(name));
|
|
314
324
|
const modelsByCleanName = /* @__PURE__ */ new Map();
|
|
315
325
|
for (const [name, schema] of Object.entries(schemas)) {
|
|
316
326
|
const pascalName = resolveSchemaName(name);
|
|
@@ -345,6 +355,7 @@ function extractSchemas(schemas, options) {
|
|
|
345
355
|
/** Clear the module-level schemaNameTransform. Called by parseSpec() after all extraction phases. */
|
|
346
356
|
function clearSchemaNameTransform() {
|
|
347
357
|
activeSchemaNameTransform = null;
|
|
358
|
+
activeEnumSchemaNames = /* @__PURE__ */ new Set();
|
|
348
359
|
}
|
|
349
360
|
/**
|
|
350
361
|
* Walk a single TypeRef and extract inline enum refs as top-level enum definitions.
|
|
@@ -909,9 +920,14 @@ function schemaToTypeRef(schema, contextName, parentModelName) {
|
|
|
909
920
|
if (schema.$ref) {
|
|
910
921
|
const segments = schema.$ref.split("/");
|
|
911
922
|
const rawName = segments[segments.length - 1];
|
|
923
|
+
const resolved = resolveSchemaName(rawName);
|
|
924
|
+
if (activeEnumSchemaNames.has(resolved)) return {
|
|
925
|
+
kind: "enum",
|
|
926
|
+
name: resolved
|
|
927
|
+
};
|
|
912
928
|
return {
|
|
913
929
|
kind: "model",
|
|
914
|
-
name:
|
|
930
|
+
name: resolved
|
|
915
931
|
};
|
|
916
932
|
}
|
|
917
933
|
if (Array.isArray(schema.type)) {
|
|
@@ -1599,10 +1615,23 @@ function inferServiceName(path, tag) {
|
|
|
1599
1615
|
if (first.startsWith("{")) return "Default";
|
|
1600
1616
|
return toPascalCase(first);
|
|
1601
1617
|
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Strip overload indices (e.g. NestJS emits `Foo_bar[0]` when a controller
|
|
1620
|
+
* method handles multiple routes) from an operationId so derived names never
|
|
1621
|
+
* leak the bracketed digit. Without this, `authenticate[0]` would surface as
|
|
1622
|
+
* `authenticate0` in method names and `Authenticate0Request` in body model
|
|
1623
|
+
* names. Brackets at the end (or with trailing whitespace) are common in
|
|
1624
|
+
* NestJS-style backends; this regex is intentionally narrow to avoid eating
|
|
1625
|
+
* legitimate digits like `oauth2`.
|
|
1626
|
+
*/
|
|
1627
|
+
function normalizeOperationIdForNaming(operationId) {
|
|
1628
|
+
return operationId.replace(/\[\d+\]\s*$/, "");
|
|
1629
|
+
}
|
|
1602
1630
|
function inferOperationName(method, path, operationId, operationIdTransform) {
|
|
1603
1631
|
if (operationId) {
|
|
1604
|
-
|
|
1605
|
-
return
|
|
1632
|
+
const normalized = normalizeOperationIdForNaming(operationId);
|
|
1633
|
+
if (operationIdTransform) return operationIdTransform(normalized);
|
|
1634
|
+
return toCamelCase(normalized);
|
|
1606
1635
|
}
|
|
1607
1636
|
const verb = inferVerb(method, path);
|
|
1608
1637
|
const resource = inferResourceFromPath(path);
|
|
@@ -1920,7 +1949,7 @@ function extractRequestBody(body, op, inlineModels) {
|
|
|
1920
1949
|
};
|
|
1921
1950
|
return {};
|
|
1922
1951
|
}
|
|
1923
|
-
const contextName = cleanSchemaName(op?.operationId ? toPascalCase(op.operationId) + "Request" : "RequestBody");
|
|
1952
|
+
const contextName = cleanSchemaName(op?.operationId ? toPascalCase(normalizeOperationIdForNaming(op.operationId)) + "Request" : "RequestBody");
|
|
1924
1953
|
if (schema.properties && (schema.type === "object" || !schema.type)) {
|
|
1925
1954
|
const requiredSet = new Set(schema.required ?? []);
|
|
1926
1955
|
const fields = [];
|
|
@@ -2001,7 +2030,7 @@ function deriveOneOfVariantName(variant, baseName, existingModels) {
|
|
|
2001
2030
|
return name;
|
|
2002
2031
|
}
|
|
2003
2032
|
function deriveResponseName(op, path, method) {
|
|
2004
|
-
if (op?.operationId) return cleanSchemaName(toPascalCase(op.operationId) + "Response");
|
|
2033
|
+
if (op?.operationId) return cleanSchemaName(toPascalCase(normalizeOperationIdForNaming(op.operationId)) + "Response");
|
|
2005
2034
|
return toPascalCase(path.split("/").filter(Boolean)[0] ?? "Unknown") + toPascalCase(method) + "Response";
|
|
2006
2035
|
}
|
|
2007
2036
|
function extractResponses(responses, op, path, method) {
|