@tim-smart/openapi-gen 0.3.25 → 0.4.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/main.js +25 -18
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -35323,8 +35323,19 @@ var methodNames = [
|
|
|
35323
35323
|
"patch",
|
|
35324
35324
|
"trace"
|
|
35325
35325
|
];
|
|
35326
|
+
var httpClientMethodNames = {
|
|
35327
|
+
get: "get",
|
|
35328
|
+
put: "put",
|
|
35329
|
+
post: "post",
|
|
35330
|
+
delete: "del",
|
|
35331
|
+
options: "options",
|
|
35332
|
+
head: "head",
|
|
35333
|
+
patch: "patch",
|
|
35334
|
+
trace: `make("TRACE")`
|
|
35335
|
+
};
|
|
35326
35336
|
var make65 = gen2(function* () {
|
|
35327
|
-
const
|
|
35337
|
+
const isV2 = (spec2) => "swagger" in spec2;
|
|
35338
|
+
const convert2 = fn("OpenApi.convert")(
|
|
35328
35339
|
(v2Spec) => async2((resume2) => {
|
|
35329
35340
|
(0, import_swagger2openapi.convertObj)(
|
|
35330
35341
|
v2Spec,
|
|
@@ -35341,6 +35352,9 @@ var make65 = gen2(function* () {
|
|
|
35341
35352
|
);
|
|
35342
35353
|
const generate = fnUntraced2(
|
|
35343
35354
|
function* (spec2, options3) {
|
|
35355
|
+
if (isV2(spec2)) {
|
|
35356
|
+
spec2 = yield* convert2(spec2);
|
|
35357
|
+
}
|
|
35344
35358
|
const gen3 = yield* JsonSchemaGen;
|
|
35345
35359
|
const components = spec2.components ? { ...spec2.components } : { schemas: {} };
|
|
35346
35360
|
const context7 = { components };
|
|
@@ -35448,7 +35462,9 @@ var make65 = gen2(function* () {
|
|
|
35448
35462
|
);
|
|
35449
35463
|
const statusLower = status2.toLowerCase();
|
|
35450
35464
|
const statusMajorNumber = Number(status2[0]);
|
|
35451
|
-
if (statusMajorNumber
|
|
35465
|
+
if (isNaN(statusMajorNumber)) {
|
|
35466
|
+
return;
|
|
35467
|
+
} else if (statusMajorNumber < 4) {
|
|
35452
35468
|
op.successSchemas.set(statusLower, schemaName);
|
|
35453
35469
|
} else {
|
|
35454
35470
|
op.errorSchemas.set(statusLower, schemaName);
|
|
@@ -35477,7 +35493,7 @@ ${transformer.toTypes(options3.name, operations)}`;
|
|
|
35477
35493
|
options3?.typeOnly ? layerTransformerTs2 : layerTransformerSchema2
|
|
35478
35494
|
)
|
|
35479
35495
|
);
|
|
35480
|
-
return {
|
|
35496
|
+
return { generate };
|
|
35481
35497
|
});
|
|
35482
35498
|
var _OpenApi = class _OpenApi extends Tag3("OpenApi")() {
|
|
35483
35499
|
};
|
|
@@ -35599,7 +35615,7 @@ ${clientErrorSource(name2)}`;
|
|
|
35599
35615
|
pipeline.push(`withResponse(HttpClientResponse.matchStatus({
|
|
35600
35616
|
${decodes.join(",\n ")}
|
|
35601
35617
|
}))`);
|
|
35602
|
-
return `"${operation.id}": (${params}) => HttpClientRequest
|
|
35618
|
+
return `"${operation.id}": (${params}) => HttpClientRequest.${httpClientMethodNames[operation.method]}(${operation.pathTemplate}).pipe(
|
|
35603
35619
|
${pipeline.join(",\n ")}
|
|
35604
35620
|
)`;
|
|
35605
35621
|
};
|
|
@@ -35747,7 +35763,7 @@ ${clientErrorSource(name2)}`;
|
|
|
35747
35763
|
pipeline.push(
|
|
35748
35764
|
`onRequest([${singleSuccessCode ? `"2xx"` : successCodes}]${errorCodes ? `, ${JSON.stringify(errorCodes)}` : ""})`
|
|
35749
35765
|
);
|
|
35750
|
-
return `"${operation.id}": (${params}) => HttpClientRequest
|
|
35766
|
+
return `"${operation.id}": (${params}) => HttpClientRequest.${httpClientMethodNames[operation.method]}(${operation.pathTemplate}).pipe(
|
|
35751
35767
|
${pipeline.join(",\n ")}
|
|
35752
35768
|
)`;
|
|
35753
35769
|
};
|
|
@@ -35835,24 +35851,15 @@ var name = text8("name").pipe(
|
|
|
35835
35851
|
withDescription3("The name of the generated client"),
|
|
35836
35852
|
withDefault3("Client")
|
|
35837
35853
|
);
|
|
35838
|
-
var convert2 = boolean5("convert").pipe(
|
|
35839
|
-
withAlias2("c"),
|
|
35840
|
-
withDescription3("Convert from OpenAPI 2 to OpenAPI 3 first")
|
|
35841
|
-
);
|
|
35842
35854
|
var typeOnly = boolean5("type-only").pipe(
|
|
35843
35855
|
withAlias2("t"),
|
|
35844
35856
|
withDescription3("Generate a type-only client without schemas")
|
|
35845
35857
|
);
|
|
35846
|
-
var root = make63("openapigen", { spec,
|
|
35858
|
+
var root = make63("openapigen", { spec, typeOnly, name }).pipe(
|
|
35847
35859
|
withHandler2(
|
|
35848
|
-
|
|
35849
|
-
|
|
35850
|
-
|
|
35851
|
-
}
|
|
35852
|
-
return yield* OpenApi.generate(spec2, { name: name2, typeOnly: typeOnly2 }).pipe(
|
|
35853
|
-
flatMap9(log2)
|
|
35854
|
-
);
|
|
35855
|
-
})
|
|
35860
|
+
({ spec: spec2, typeOnly: typeOnly2, name: name2 }) => OpenApi.generate(spec2, { name: name2, typeOnly: typeOnly2 }).pipe(
|
|
35861
|
+
flatMap9(log2)
|
|
35862
|
+
)
|
|
35856
35863
|
)
|
|
35857
35864
|
);
|
|
35858
35865
|
var run9 = run8(root, {
|