@tim-smart/openapi-gen 0.3.26 → 0.4.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.
Files changed (2) hide show
  1. package/main.js +24 -18
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -34919,7 +34919,8 @@ var make64 = gen2(function* () {
34919
34919
  key,
34920
34920
  source,
34921
34921
  isOptional,
34922
- isNullable: "nullable" in fullSchema && fullSchema.nullable === true || "default" in fullSchema && fullSchema.default === null
34922
+ isNullable: "nullable" in fullSchema && fullSchema.nullable === true || "default" in fullSchema && fullSchema.default === null,
34923
+ default: fullSchema.default
34923
34924
  })
34924
34925
  )
34925
34926
  );
@@ -35323,8 +35324,19 @@ var methodNames = [
35323
35324
  "patch",
35324
35325
  "trace"
35325
35326
  ];
35327
+ var httpClientMethodNames = {
35328
+ get: "get",
35329
+ put: "put",
35330
+ post: "post",
35331
+ delete: "del",
35332
+ options: "options",
35333
+ head: "head",
35334
+ patch: "patch",
35335
+ trace: `make("TRACE")`
35336
+ };
35326
35337
  var make65 = gen2(function* () {
35327
- const convert3 = fn("OpenApi.convert")(
35338
+ const isV2 = (spec2) => "swagger" in spec2;
35339
+ const convert2 = fn("OpenApi.convert")(
35328
35340
  (v2Spec) => async2((resume2) => {
35329
35341
  (0, import_swagger2openapi.convertObj)(
35330
35342
  v2Spec,
@@ -35341,6 +35353,9 @@ var make65 = gen2(function* () {
35341
35353
  );
35342
35354
  const generate = fnUntraced2(
35343
35355
  function* (spec2, options3) {
35356
+ if (isV2(spec2)) {
35357
+ spec2 = yield* convert2(spec2);
35358
+ }
35344
35359
  const gen3 = yield* JsonSchemaGen;
35345
35360
  const components = spec2.components ? { ...spec2.components } : { schemas: {} };
35346
35361
  const context7 = { components };
@@ -35479,7 +35494,7 @@ ${transformer.toTypes(options3.name, operations)}`;
35479
35494
  options3?.typeOnly ? layerTransformerTs2 : layerTransformerSchema2
35480
35495
  )
35481
35496
  );
35482
- return { convert: convert3, generate };
35497
+ return { generate };
35483
35498
  });
35484
35499
  var _OpenApi = class _OpenApi extends Tag3("OpenApi")() {
35485
35500
  };
@@ -35601,7 +35616,7 @@ ${clientErrorSource(name2)}`;
35601
35616
  pipeline.push(`withResponse(HttpClientResponse.matchStatus({
35602
35617
  ${decodes.join(",\n ")}
35603
35618
  }))`);
35604
- return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
35619
+ return `"${operation.id}": (${params}) => HttpClientRequest.${httpClientMethodNames[operation.method]}(${operation.pathTemplate}).pipe(
35605
35620
  ${pipeline.join(",\n ")}
35606
35621
  )`;
35607
35622
  };
@@ -35749,7 +35764,7 @@ ${clientErrorSource(name2)}`;
35749
35764
  pipeline.push(
35750
35765
  `onRequest([${singleSuccessCode ? `"2xx"` : successCodes}]${errorCodes ? `, ${JSON.stringify(errorCodes)}` : ""})`
35751
35766
  );
35752
- return `"${operation.id}": (${params}) => HttpClientRequest.make("${operation.method.toUpperCase()}")(${operation.pathTemplate}).pipe(
35767
+ return `"${operation.id}": (${params}) => HttpClientRequest.${httpClientMethodNames[operation.method]}(${operation.pathTemplate}).pipe(
35753
35768
  ${pipeline.join(",\n ")}
35754
35769
  )`;
35755
35770
  };
@@ -35837,24 +35852,15 @@ var name = text8("name").pipe(
35837
35852
  withDescription3("The name of the generated client"),
35838
35853
  withDefault3("Client")
35839
35854
  );
35840
- var convert2 = boolean5("convert").pipe(
35841
- withAlias2("c"),
35842
- withDescription3("Convert from OpenAPI 2 to OpenAPI 3 first")
35843
- );
35844
35855
  var typeOnly = boolean5("type-only").pipe(
35845
35856
  withAlias2("t"),
35846
35857
  withDescription3("Generate a type-only client without schemas")
35847
35858
  );
35848
- var root = make63("openapigen", { spec, convert: convert2, typeOnly, name }).pipe(
35859
+ var root = make63("openapigen", { spec, typeOnly, name }).pipe(
35849
35860
  withHandler2(
35850
- fnUntraced2(function* ({ spec: spec2, convert: convert3, typeOnly: typeOnly2, name: name2 }) {
35851
- if (convert3) {
35852
- spec2 = yield* OpenApi.convert(spec2);
35853
- }
35854
- return yield* OpenApi.generate(spec2, { name: name2, typeOnly: typeOnly2 }).pipe(
35855
- flatMap9(log2)
35856
- );
35857
- })
35861
+ ({ spec: spec2, typeOnly: typeOnly2, name: name2 }) => OpenApi.generate(spec2, { name: name2, typeOnly: typeOnly2 }).pipe(
35862
+ flatMap9(log2)
35863
+ )
35858
35864
  )
35859
35865
  );
35860
35866
  var run9 = run8(root, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tim-smart/openapi-gen",
3
- "version": "0.3.26",
3
+ "version": "0.4.1",
4
4
  "description": "Generate Effect http clients from OpenAPI specs",
5
5
  "bin": "main.js",
6
6
  "repository": {