@tim-smart/openapi-gen 0.3.3 → 0.3.4

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 +22 -10
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -29405,7 +29405,7 @@ var make65 = gen2(function* () {
29405
29405
  current = current[key];
29406
29406
  }
29407
29407
  refStore.set(schema.$ref, current);
29408
- addRefs(current, "properties" in current ? name2 : void 0);
29408
+ addRefs(current, name2);
29409
29409
  store.set(name2, current);
29410
29410
  if (!asStruct2) {
29411
29411
  classes.add(name2);
@@ -29416,16 +29416,22 @@ var make65 = gen2(function* () {
29416
29416
  );
29417
29417
  } else if ("type" in schema && schema.type === "array") {
29418
29418
  if (Array.isArray(schema.items)) {
29419
- schema.items.forEach((s) => addRefs(s, childName));
29419
+ schema.items.forEach((s) => addRefs(s, void 0));
29420
29420
  } else if (schema.items) {
29421
- addRefs(schema.items, childName);
29421
+ addRefs(schema.items, void 0);
29422
29422
  }
29423
29423
  } else if ("allOf" in schema) {
29424
- schema.allOf.forEach((s) => addRefs(s, childName));
29424
+ schema.allOf.forEach(
29425
+ (s) => addRefs(s, childName ? childName + "Enum" : void 0)
29426
+ );
29425
29427
  } else if ("anyOf" in schema) {
29426
- schema.anyOf.forEach((s) => addRefs(s, childName));
29428
+ schema.anyOf.forEach(
29429
+ (s) => addRefs(s, childName ? childName + "Enum" : void 0)
29430
+ );
29427
29431
  } else if ("oneOf" in schema) {
29428
- schema.oneOf.forEach((s) => addRefs(s, childName));
29432
+ schema.oneOf.forEach(
29433
+ (s) => addRefs(s, childName ? childName + "Enum" : void 0)
29434
+ );
29429
29435
  } else if ("enum" in schema) {
29430
29436
  if (childName !== void 0) {
29431
29437
  store.set(childName, schema);
@@ -29450,6 +29456,12 @@ var make65 = gen2(function* () {
29450
29456
  const isEnum = enums.has(name);
29451
29457
  return toSource(S, schema, name, isClass || isEnum).pipe(
29452
29458
  map((source) => {
29459
+ if (name === "Model") {
29460
+ console.error({
29461
+ name,
29462
+ source
29463
+ });
29464
+ }
29453
29465
  const isObject2 = "properties" in schema;
29454
29466
  if (!isObject2 || !isClass) {
29455
29467
  return `export class ${name} extends ${source} {}`;
@@ -29497,7 +29509,7 @@ var make65 = gen2(function* () {
29497
29509
  }
29498
29510
  const items = schema.enum.map((_) => JSON.stringify(_)).join(", ");
29499
29511
  return some2(`${S}.Literal(${items})`);
29500
- } else if ("type" in schema) {
29512
+ } else if ("type" in schema && schema.type) {
29501
29513
  switch (schema.type) {
29502
29514
  case "string": {
29503
29515
  const modifiers = [];
@@ -29570,7 +29582,7 @@ var make65 = gen2(function* () {
29570
29582
  } else if ("allOf" in schema) {
29571
29583
  const sources = pipe(
29572
29584
  schema.allOf,
29573
- filterMap2((_) => toSource(S, _, currentIdentifier))
29585
+ filterMap2((_) => toSource(S, _, currentIdentifier + "Enum"))
29574
29586
  );
29575
29587
  if (sources.length === 0) {
29576
29588
  return none2();
@@ -29586,7 +29598,7 @@ var make65 = gen2(function* () {
29586
29598
  } else if ("anyOf" in schema || "oneOf" in schema) {
29587
29599
  const sources = pipe(
29588
29600
  "anyOf" in schema ? schema.anyOf : schema.oneOf,
29589
- filterMap2((_) => toSource(S, _, currentIdentifier))
29601
+ filterMap2((_) => toSource(S, _, currentIdentifier + "Enum"))
29590
29602
  );
29591
29603
  if (sources.length === 0) return none2();
29592
29604
  else if (sources.length === 1) return some2(sources[0]);
@@ -29857,7 +29869,7 @@ var operationToImpl = (operation) => {
29857
29869
  }
29858
29870
  if (operation.headers.length > 0) {
29859
29871
  const props = operation.headers.map(
29860
- (param) => `"${param}": ${varName}["${param}"]`
29872
+ (param) => `"${param}": ${varName}["${param}"] ?? undefined`
29861
29873
  );
29862
29874
  pipeline.push(`HttpClientRequest.setHeaders({ ${props.join(", ")} })`);
29863
29875
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tim-smart/openapi-gen",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "Generate Effect http clients from OpenAPI specs",
5
5
  "bin": "main.js",
6
6
  "repository": {