@workos/oagen 0.18.0 → 0.18.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 +150 -39
- package/dist/cli/index.mjs.map +1 -1
- package/dist/{diff-DLqJSVYR.mjs → diff-JU1bdT5_.mjs} +107 -17
- package/dist/{diff-DLqJSVYR.mjs.map → diff-JU1bdT5_.mjs.map} +1 -1
- package/dist/index.d.mts +33 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +45 -24
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/smoke/baseline.mjs +44 -23
- package/dist/scripts/smoke/baseline.mjs.map +1 -1
- package/dist/smoke.mjs +44 -23
- package/dist/smoke.mjs.map +1 -1
- package/dist/verify/index.mjs +1 -1
- package/package.json +1 -1
package/dist/smoke.mjs
CHANGED
|
@@ -1760,7 +1760,7 @@ const HTTP_METHODS = [
|
|
|
1760
1760
|
"options",
|
|
1761
1761
|
"trace"
|
|
1762
1762
|
];
|
|
1763
|
-
function extractOperations(paths, operationIdTransform) {
|
|
1763
|
+
function extractOperations(paths, operationIdTransform, componentSchemas) {
|
|
1764
1764
|
if (!paths) return {
|
|
1765
1765
|
services: [],
|
|
1766
1766
|
inlineModels: []
|
|
@@ -1773,7 +1773,7 @@ function extractOperations(paths, operationIdTransform) {
|
|
|
1773
1773
|
const op = pathItem[method];
|
|
1774
1774
|
if (!op) continue;
|
|
1775
1775
|
const serviceName = inferServiceName(path, op.tags?.[0]);
|
|
1776
|
-
const { operation, inlineModels: opModels } = buildOperation(method, path, op, pathLevelParams, operationIdTransform, serviceName);
|
|
1776
|
+
const { operation, inlineModels: opModels } = buildOperation(method, path, op, pathLevelParams, operationIdTransform, serviceName, componentSchemas);
|
|
1777
1777
|
inlineModels.push(...opModels);
|
|
1778
1778
|
const ops = serviceMap.get(serviceName) ?? [];
|
|
1779
1779
|
ops.push(operation);
|
|
@@ -2016,14 +2016,14 @@ function extractBodyParameterGroups(op, operationContext) {
|
|
|
2016
2016
|
}
|
|
2017
2017
|
return groups.length > 0 ? groups : void 0;
|
|
2018
2018
|
}
|
|
2019
|
-
function buildOperation(method, path, op, pathLevelParams, operationIdTransform, serviceName) {
|
|
2019
|
+
function buildOperation(method, path, op, pathLevelParams, operationIdTransform, serviceName, componentSchemas) {
|
|
2020
2020
|
const allParams = [...pathLevelParams, ...op.parameters ?? []];
|
|
2021
2021
|
const hasIdempotencyHeader = allParams.some((p) => p.in === "header" && p.name.toLowerCase() === "idempotency-key");
|
|
2022
2022
|
const opContext = serviceName;
|
|
2023
|
-
const pathParams = extractParams(allParams, "path", opContext);
|
|
2024
|
-
const queryParams = extractParams(allParams, "query", opContext);
|
|
2025
|
-
const headerParams = extractParams(allParams, "header", opContext).filter((p) => p.name.toLowerCase() !== "idempotency-key");
|
|
2026
|
-
const cookieParams = extractParams(allParams, "cookie", opContext);
|
|
2023
|
+
const pathParams = extractParams(allParams, "path", opContext, componentSchemas);
|
|
2024
|
+
const queryParams = extractParams(allParams, "query", opContext, componentSchemas);
|
|
2025
|
+
const headerParams = extractParams(allParams, "header", opContext, componentSchemas).filter((p) => p.name.toLowerCase() !== "idempotency-key");
|
|
2026
|
+
const cookieParams = extractParams(allParams, "cookie", opContext, componentSchemas);
|
|
2027
2027
|
const reqBodyModels = [];
|
|
2028
2028
|
const { body: requestBody, encoding: requestBodyEncoding } = extractRequestBody(op.requestBody, op, reqBodyModels);
|
|
2029
2029
|
const { response, successResponses, errors, inlineModels, isPaginated, dataPath: responseDataPath, itemType: responseItemType } = extractResponses(op.responses, op, path, method);
|
|
@@ -2095,21 +2095,42 @@ function buildDescription(summary, description) {
|
|
|
2095
2095
|
if (summary && description && summary !== description) return `${summary}\n\n${description}`;
|
|
2096
2096
|
return description ?? summary;
|
|
2097
2097
|
}
|
|
2098
|
-
function extractParams(params, location, operationContext) {
|
|
2099
|
-
return params.filter((p) => p.in === location).map((p) =>
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
type:
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2098
|
+
function extractParams(params, location, operationContext, componentSchemas) {
|
|
2099
|
+
return params.filter((p) => p.in === location).map((p) => {
|
|
2100
|
+
const refTarget = resolveParamSchemaRef(p.schema, componentSchemas);
|
|
2101
|
+
return {
|
|
2102
|
+
name: p.name,
|
|
2103
|
+
type: p.schema ? schemaToTypeRef(p.schema, p.name, operationContext ? toPascalCase(operationContext) : void 0) : {
|
|
2104
|
+
kind: "primitive",
|
|
2105
|
+
type: "string"
|
|
2106
|
+
},
|
|
2107
|
+
required: p.required ?? false,
|
|
2108
|
+
description: p.description,
|
|
2109
|
+
deprecated: p.deprecated || p.schema?.deprecated || refTarget?.deprecated || void 0,
|
|
2110
|
+
default: p.schema?.default ?? refTarget?.default,
|
|
2111
|
+
example: p.example ?? p.schema?.example ?? refTarget?.example,
|
|
2112
|
+
style: p.style,
|
|
2113
|
+
explode: p.explode
|
|
2114
|
+
};
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* If a parameter's schema is a `$ref` to `#/components/schemas/X`, return the
|
|
2119
|
+
* referenced component schema. Used to surface schema-level metadata (default,
|
|
2120
|
+
* example, deprecated) that wouldn't otherwise be visible at the param level.
|
|
2121
|
+
*
|
|
2122
|
+
* Refs are not pre-resolved by the bundler (`dereference: false` in refs.ts),
|
|
2123
|
+
* so without this, a param like `schema: { $ref: '.../PaginationOrder' }`
|
|
2124
|
+
* silently loses the target's `default: desc` and the SDK stops emitting the
|
|
2125
|
+
* spec-mandated default value in generated method signatures.
|
|
2126
|
+
*/
|
|
2127
|
+
function resolveParamSchemaRef(schema, componentSchemas) {
|
|
2128
|
+
if (!schema || !componentSchemas) return void 0;
|
|
2129
|
+
const ref = schema.$ref;
|
|
2130
|
+
if (!ref) return void 0;
|
|
2131
|
+
const match = /^#\/components\/schemas\/(.+)$/.exec(ref);
|
|
2132
|
+
if (!match) return void 0;
|
|
2133
|
+
return componentSchemas[match[1]];
|
|
2113
2134
|
}
|
|
2114
2135
|
function extractRequestBody(body, op, inlineModels) {
|
|
2115
2136
|
if (!body?.content) return {};
|
|
@@ -2463,7 +2484,7 @@ async function parseSpec(specPath, options) {
|
|
|
2463
2484
|
const version = spec.openapi ?? "";
|
|
2464
2485
|
if (!version.startsWith("3.")) throw new SpecParseError(`Unsupported OpenAPI version: ${version}. oagen requires OpenAPI 3.x`, `Update the spec to OpenAPI 3.0 or 3.1. If you are using Swagger 2.x, convert it first with \`npx swagger2openapi ${specPath}\`.`);
|
|
2465
2486
|
const { models, enums } = extractSchemas(spec.components?.schemas, { schemaNameTransform: options?.schemaNameTransform });
|
|
2466
|
-
const { services, inlineModels } = extractOperations(spec.paths, options?.operationIdTransform);
|
|
2487
|
+
const { services, inlineModels } = extractOperations(spec.paths, options?.operationIdTransform, spec.components?.schemas);
|
|
2467
2488
|
clearSchemaNameTransform();
|
|
2468
2489
|
const finalModels = collapseJsonSuffixModels(mergeFieldInlineModels(mergeInlineResponseModels(models, inlineModels), extractInlineModelsFromSchemas(spec.components?.schemas)), services);
|
|
2469
2490
|
collectInlineEnumsFromModels(finalModels, enums);
|