@tim-smart/openapi-gen 0.3.17 → 0.3.18

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 +18 -8
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -35186,7 +35186,7 @@ export type ${name2} = (typeof ${name2})[keyof typeof ${name2}];` : `${toComment
35186
35186
  },
35187
35187
  propertySeparator: ";\n ",
35188
35188
  onProperty(options3) {
35189
- return `${toComment(options3.description)}readonly "${options3.key}"${options3.isOptional ? "?" : ""}: ${options3.source}${options3.isNullable ? " | null" : ""}`;
35189
+ return `${toComment(options3.description)}readonly "${options3.key}"${options3.isOptional ? "?" : ""}: ${options3.source}${options3.isNullable ? " | null" : ""}${options3.isOptional ? " | undefined" : ""}`;
35190
35190
  },
35191
35191
  onRef({ name: name2 }) {
35192
35192
  return name2;
@@ -35347,7 +35347,8 @@ var make64 = gen2(function* () {
35347
35347
  headers: [],
35348
35348
  cookies: [],
35349
35349
  successSchemas: /* @__PURE__ */ new Map(),
35350
- errorSchemas: /* @__PURE__ */ new Map()
35350
+ errorSchemas: /* @__PURE__ */ new Map(),
35351
+ paramsOptional: true
35351
35352
  };
35352
35353
  const schemaId = identifier2(operation.operationId);
35353
35354
  const validParameters = operation.parameters?.filter(
@@ -35399,6 +35400,7 @@ var make64 = gen2(function* () {
35399
35400
  context7,
35400
35401
  true
35401
35402
  );
35403
+ op.paramsOptional = !schema.required || schema.required.length === 0;
35402
35404
  }
35403
35405
  if (operation.requestBody?.content?.["application/json"]?.schema) {
35404
35406
  op.payload = gen3.addSchema(
@@ -35469,9 +35471,13 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
35469
35471
  }
35470
35472
  let options3 = [];
35471
35473
  if (operation.params && !operation.payload) {
35472
- args2.push(`options: typeof ${operation.params}.Encoded`);
35474
+ args2.push(
35475
+ `options${operation.paramsOptional ? "?" : ""}: typeof ${operation.params}.Encoded${operation.paramsOptional ? " | undefined" : ""}`
35476
+ );
35473
35477
  } else if (operation.params) {
35474
- options3.push(`readonly params: typeof ${operation.params}.Encoded`);
35478
+ options3.push(
35479
+ `readonly params${operation.paramsOptional ? "?" : ""}: typeof ${operation.params}.Encoded${operation.paramsOptional ? " | undefined" : ""}`
35480
+ );
35475
35481
  }
35476
35482
  if (operation.payload) {
35477
35483
  const type2 = operation.payload === "FormData" ? "globalThis.FormData" : `typeof ${operation.payload}.Encoded`;
@@ -35532,7 +35538,7 @@ var layerTransformerSchema2 = sync6(OpenApiTransformer, () => {
35532
35538
  const params = `${args2.join(", ")}`;
35533
35539
  const pipeline = [];
35534
35540
  if (operation.params) {
35535
- const varName = operation.payload ? "options.params" : "options";
35541
+ const varName = operation.payload ? "options.params?." : "options?.";
35536
35542
  if (operation.urlParams.length > 0) {
35537
35543
  const props = operation.urlParams.map(
35538
35544
  (param) => `"${param}": ${varName}["${param}"] as UrlParams.Coercible`
@@ -35615,9 +35621,13 @@ export const ${name2}Error = <Tag extends string, E>(
35615
35621
  }
35616
35622
  let options3 = [];
35617
35623
  if (operation.params && !operation.payload) {
35618
- args2.push(`options: ${operation.params}`);
35624
+ args2.push(
35625
+ `options${operation.paramsOptional ? "?" : ""}: ${operation.params}${operation.paramsOptional ? " | undefined" : ""}`
35626
+ );
35619
35627
  } else if (operation.params) {
35620
- options3.push(`readonly params: ${operation.params}`);
35628
+ options3.push(
35629
+ `readonly params${operation.paramsOptional ? "?" : ""}: ${operation.params}${operation.paramsOptional ? " | undefined" : ""}`
35630
+ );
35621
35631
  }
35622
35632
  if (operation.payload) {
35623
35633
  const type2 = operation.payload === "FormData" ? "globalThis.FormData" : operation.payload;
@@ -35721,7 +35731,7 @@ export const ${name2}Error = <Tag extends string, E>(
35721
35731
  const params = `${args2.join(", ")}`;
35722
35732
  const pipeline = [];
35723
35733
  if (operation.params) {
35724
- const varName = operation.payload ? "options.params" : "options";
35734
+ const varName = operation.payload ? "options.params?." : "options?.";
35725
35735
  if (operation.urlParams.length > 0) {
35726
35736
  const props = operation.urlParams.map(
35727
35737
  (param) => `"${param}": ${varName}["${param}"] as UrlParams.Coercible`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tim-smart/openapi-gen",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "Generate Effect http clients from OpenAPI specs",
5
5
  "bin": "main.js",
6
6
  "repository": {