@tim-smart/openapi-gen 0.3.26 → 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 +22 -17
- 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 };
|
|
@@ -35479,7 +35493,7 @@ ${transformer.toTypes(options3.name, operations)}`;
|
|
|
35479
35493
|
options3?.typeOnly ? layerTransformerTs2 : layerTransformerSchema2
|
|
35480
35494
|
)
|
|
35481
35495
|
);
|
|
35482
|
-
return {
|
|
35496
|
+
return { generate };
|
|
35483
35497
|
});
|
|
35484
35498
|
var _OpenApi = class _OpenApi extends Tag3("OpenApi")() {
|
|
35485
35499
|
};
|
|
@@ -35601,7 +35615,7 @@ ${clientErrorSource(name2)}`;
|
|
|
35601
35615
|
pipeline.push(`withResponse(HttpClientResponse.matchStatus({
|
|
35602
35616
|
${decodes.join(",\n ")}
|
|
35603
35617
|
}))`);
|
|
35604
|
-
return `"${operation.id}": (${params}) => HttpClientRequest
|
|
35618
|
+
return `"${operation.id}": (${params}) => HttpClientRequest.${httpClientMethodNames[operation.method]}(${operation.pathTemplate}).pipe(
|
|
35605
35619
|
${pipeline.join(",\n ")}
|
|
35606
35620
|
)`;
|
|
35607
35621
|
};
|
|
@@ -35749,7 +35763,7 @@ ${clientErrorSource(name2)}`;
|
|
|
35749
35763
|
pipeline.push(
|
|
35750
35764
|
`onRequest([${singleSuccessCode ? `"2xx"` : successCodes}]${errorCodes ? `, ${JSON.stringify(errorCodes)}` : ""})`
|
|
35751
35765
|
);
|
|
35752
|
-
return `"${operation.id}": (${params}) => HttpClientRequest
|
|
35766
|
+
return `"${operation.id}": (${params}) => HttpClientRequest.${httpClientMethodNames[operation.method]}(${operation.pathTemplate}).pipe(
|
|
35753
35767
|
${pipeline.join(",\n ")}
|
|
35754
35768
|
)`;
|
|
35755
35769
|
};
|
|
@@ -35837,24 +35851,15 @@ var name = text8("name").pipe(
|
|
|
35837
35851
|
withDescription3("The name of the generated client"),
|
|
35838
35852
|
withDefault3("Client")
|
|
35839
35853
|
);
|
|
35840
|
-
var convert2 = boolean5("convert").pipe(
|
|
35841
|
-
withAlias2("c"),
|
|
35842
|
-
withDescription3("Convert from OpenAPI 2 to OpenAPI 3 first")
|
|
35843
|
-
);
|
|
35844
35854
|
var typeOnly = boolean5("type-only").pipe(
|
|
35845
35855
|
withAlias2("t"),
|
|
35846
35856
|
withDescription3("Generate a type-only client without schemas")
|
|
35847
35857
|
);
|
|
35848
|
-
var root = make63("openapigen", { spec,
|
|
35858
|
+
var root = make63("openapigen", { spec, typeOnly, name }).pipe(
|
|
35849
35859
|
withHandler2(
|
|
35850
|
-
|
|
35851
|
-
|
|
35852
|
-
|
|
35853
|
-
}
|
|
35854
|
-
return yield* OpenApi.generate(spec2, { name: name2, typeOnly: typeOnly2 }).pipe(
|
|
35855
|
-
flatMap9(log2)
|
|
35856
|
-
);
|
|
35857
|
-
})
|
|
35860
|
+
({ spec: spec2, typeOnly: typeOnly2, name: name2 }) => OpenApi.generate(spec2, { name: name2, typeOnly: typeOnly2 }).pipe(
|
|
35861
|
+
flatMap9(log2)
|
|
35862
|
+
)
|
|
35858
35863
|
)
|
|
35859
35864
|
);
|
|
35860
35865
|
var run9 = run8(root, {
|