hono-takibi 0.32.5 → 0.32.6

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/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
5
5
  import { Console, Effect, FileSystem, Option, Path, Ref, Schema, Stream } from "effect";
6
6
  import { Argument, CliError, Command, Flag } from "effect/cli";
7
7
  // package.json
8
- var version = "0.32.5";
8
+ var version = "0.32.6";
9
9
  var description = "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi";
10
10
  // src/cli/index.ts
11
11
  const COMMAND_NAME = "hono-takibi";
@@ -41,7 +41,7 @@ function runJobs(config) {
41
41
  const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob, openAPI3, packageRoots }] = yield* Effect.promise(() => Promise.all([
42
42
  import("./openapi-BxSVfs_l.js").then((n) => n.t),
43
43
  import("./format-BF7SbaMP.js").then((n) => n.r),
44
- import("./shared-Bu8uDxYC.js").then((n) => n.o)
44
+ import("./shared-BmIHrl_h.js").then((n) => n.o)
45
45
  ]));
46
46
  const openAPI = yield* openAPI3(yield* parseOpenAPI(config.input), config.input);
47
47
  const jobs = makeJob(openAPI, config, yield* packageRoots(openAPI, config));
@@ -79,7 +79,7 @@ function reportJobs(config, previous) {
79
79
  onFailure: (error) => Console.error(`❌ ${error.message}`),
80
80
  onSuccess: (report) => Console.log(report)
81
81
  }));
82
- const { outsideSources } = yield* Effect.promise(() => import("./shared-Bu8uDxYC.js").then((n) => n.o));
82
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-BmIHrl_h.js").then((n) => n.o));
83
83
  const inputDirectory = path.dirname(path.resolve(config.input));
84
84
  return {
85
85
  inputDirectory,
@@ -208,8 +208,8 @@ function generate(args) {
208
208
  if (input !== void 0 && output !== void 0) {
209
209
  const [{ parseOpenAPI }, { takibi }, { openAPI3 }] = yield* Effect.promise(() => Promise.all([
210
210
  import("./openapi-BxSVfs_l.js").then((n) => n.t),
211
- import("./core-BkLkX1Sz.js").then((n) => n.t),
212
- import("./shared-Bu8uDxYC.js").then((n) => n.o)
211
+ import("./core-CT8AnDwr.js").then((n) => n.t),
212
+ import("./shared-BmIHrl_h.js").then((n) => n.o)
213
213
  ]));
214
214
  const document = yield* openAPI3(yield* parseOpenAPI(input), input);
215
215
  return yield* Console.log(yield* takibi(document, output));
@@ -2,9 +2,9 @@ import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
2
  import { $ as HTTP_METHODS, G as isValidIdent, M as isRecord, O as isPathItem, S as isOperation, k as isPathItemEntry, m as isHttpMethod, q as COMPONENT_NAMES, u as isCallbacks, x as isOpenAPIPaths } from "./guard-Rvg4ztIZ.js";
3
3
  import { i as GenerateError, n as fmt } from "./format-BF7SbaMP.js";
4
4
  import { S as zodToOpenAPISchema, _ as routeName, a as ensureSuffix, b as uncapitalize, c as escapeRegexLiteral, h as renderNamedImport, l as makeBarrel, x as uncapitalizeWord, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
5
- import { C as makePathItem, D as makeWebhookEntries, E as makeRouteProperties, O as resolveParameter, S as makeCallback, T as makeRouteEntries, _ as identifierNames, a as requestBodiesCode, b as textOf, c as makeSplitSchemaFile, d as makeImports, f as makeModuleSpec, g as descendantsWhere, h as declarationOf, i as responsesCode, k as resolvePathItem, l as makeConst, m as ast, n as componentsCode, o as parametersCode, p as analyzeCircularSchemas, r as schemasCode, s as headersCode, u as makeExportConst, v as parseModule, w as makeRef, x as zodToOpenAPI, y as parseSource } from "./routes-bLfLekY5.js";
6
- import { t as zodOpenAPIHono } from "./openapi-Cgz-hHsD.js";
7
- import { t as makeMock } from "./mock-DHeN1Nr9.js";
5
+ import { C as makePathItem, D as makeWebhookEntries, E as makeRouteProperties, O as resolveParameter, S as makeCallback, T as makeRouteEntries, _ as identifierNames, a as requestBodiesCode, b as textOf, c as makeSplitSchemaFile, d as makeImports, f as makeModuleSpec, g as descendantsWhere, h as declarationOf, i as responsesCode, k as resolvePathItem, l as makeConst, m as ast, n as componentsCode, o as parametersCode, p as analyzeCircularSchemas, r as schemasCode, s as headersCode, u as makeExportConst, v as parseModule, w as makeRef, x as zodToOpenAPI, y as parseSource } from "./routes-936pvd-W.js";
6
+ import { t as zodOpenAPIHono } from "./openapi-DWSCULWR.js";
7
+ import { t as makeMock } from "./mock-Db6ltVgv.js";
8
8
  import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-yhnsv_ji.js";
9
9
  import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-hO_bjDys.js";
10
10
  import { t as emit } from "./emit-8SmO5pHF.js";
@@ -1,7 +1,7 @@
1
1
  import { parseConfig } from "../index.js";
2
2
  import { t as FormatOptions } from "../format-BF7SbaMP.js";
3
3
  import { n as parseOpenAPI } from "../openapi-BxSVfs_l.js";
4
- import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-Bu8uDxYC.js";
4
+ import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BmIHrl_h.js";
5
5
  import * as NodeServices from "@effect/platform-node/NodeServices";
6
6
  import { Effect } from "effect";
7
7
  // src/generate/index.ts
@@ -1 +1 @@
1
- export { t as makeMock } from "../../mock-DHeN1Nr9.js";
1
+ export { t as makeMock } from "../../mock-Db6ltVgv.js";
@@ -1 +1 @@
1
- export { t as zodOpenAPIHono } from "../../../openapi-Cgz-hHsD.js";
1
+ export { t as zodOpenAPIHono } from "../../../openapi-DWSCULWR.js";
@@ -1,6 +1,6 @@
1
1
  import { $ as HTTP_METHODS, A as isPathItemRef, B as isSecurityArray, J as COMPONENT_REF_PREFIX, L as isSchemaArray, N as isRefObject, R as isSchemaObject, S as isOperation, V as isSecurityScheme, a as hasNumericConstraint, at as TEXT_MEDIA_TYPE, g as isInlineMedia, j as isPresent, k as isPathItemEntry, m as isHttpMethod, nt as JSON_MEDIA_TYPE, o as hasRequestBodyContent, w as isParameter, y as isMediaWithSchema } from "./guard-Rvg4ztIZ.js";
2
2
  import { _ as routeName, a as ensureSuffix, d as makeSafeKey, f as makeStringLiteral, p as normalizeTypes, r as cyclicNodes, v as statusCodeToNumber, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
3
- import { n as componentsCode, t as routeCode } from "./routes-bLfLekY5.js";
3
+ import { n as componentsCode, t as routeCode } from "./routes-936pvd-W.js";
4
4
  // src/helper/faker.ts
5
5
  const FORMAT_TO_FAKER = {
6
6
  date: "faker.date.past().toISOString().slice(0, 10)",
@@ -1,6 +1,6 @@
1
1
  import { $ as HTTP_METHODS, M as isRecord, Y as COMPONENT_SUFFIXES, q as COMPONENT_NAMES } from "./guard-Rvg4ztIZ.js";
2
2
  import { a as ensureSuffix, i as decodePercent, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
3
- import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-bLfLekY5.js";
3
+ import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-936pvd-W.js";
4
4
  // src/helper/names.ts
5
5
  /**
6
6
  * Renames the components whose identifiers would collide, and every `$ref` to them.
@@ -2030,20 +2030,22 @@ function collectBranchBody(sub, recurse, schemas, reading = /* @__PURE__ */ new
2030
2030
  ...makeDepSchemaStmts(sub)
2031
2031
  ].filter((s) => s !== void 0).join(";") || void 0;
2032
2032
  }
2033
- function conditionalBranchStmt(sub, recurse, schemas, reading = /* @__PURE__ */ new Set()) {
2033
+ function conditionalBranchStmt(sub, recurse, schemas, reading = /* @__PURE__ */ new Set(), countVar) {
2034
2034
  const body = collectBranchBody(sub, recurse, schemas, reading);
2035
- return body ? `if(${recurse(sub)}.safeParse(o).success){${body}}` : void 0;
2035
+ if (body === void 0 && countVar === void 0) return void 0;
2036
+ const counted = countVar === void 0 ? "" : `${countVar}++;`;
2037
+ return `if(${recurse(sub)}.safeParse(o).success){${counted}${body ?? ""}}`;
2036
2038
  }
2037
- function makeUnevaluatedEvaluationStmts(schema, recurse, schemas) {
2038
- const branchStmts = (branches) => branches ? branches.map((sub) => conditionalBranchStmt(sub, recurse, schemas)).filter((s) => s !== void 0) : [];
2039
+ function makeUnevaluatedEvaluationStmts(schema, recurse, schemas, track) {
2040
+ const branchStmts = (branches, countVar) => branches ? branches.map((sub) => conditionalBranchStmt(sub, recurse, schemas, void 0, countVar)).filter((s) => s !== void 0) : [];
2039
2041
  return [
2040
2042
  "const e=new Set()",
2041
2043
  makeOwnPropsStmt(schema),
2042
2044
  makePatternPropsStmt(schema),
2043
2045
  makeAdditionalPropsStmt(schema),
2044
2046
  ...schema.allOf ? collectAllOfStmts(schema.allOf, schemas) : [],
2045
- ...branchStmts(schema.anyOf),
2046
- ...branchStmts(schema.oneOf),
2047
+ ...branchStmts(schema.anyOf, track?.anyOf),
2048
+ ...branchStmts(schema.oneOf, track?.oneOf),
2047
2049
  ...makeIfStmts(schema, recurse),
2048
2050
  ...makeDepSchemaStmts(schema)
2049
2051
  ].filter((s) => s !== void 0);
@@ -2081,12 +2083,20 @@ const ISSUE_CODES = [
2081
2083
  function makeIssueForwarding(pushArg) {
2082
2084
  return ISSUE_CODES.map((code, i) => `${i === 0 ? "" : "else "}if(issue.code==='${code}'){ctx.issues.push(${pushArg})}`).join("");
2083
2085
  }
2084
- function makeUnevaluatedPropertiesCheck(schema, recurse, messageOverride, schemas) {
2086
+ function makeUnevaluatedPropertiesCheck(schema, recurse, messageOverride, schemas, guard) {
2085
2087
  const up = schema.unevaluatedProperties;
2086
2088
  if (up === void 0 || up === true) return "";
2087
2089
  const messageField = makeUnevaluatedMessageField(schema, messageOverride);
2088
2090
  const finalStmt = up === false ? `for(const k of Object.keys(o)){if(!e.has(k)){ctx.issues.push({code:"custom",path:[k],input:o${messageField}})}}` : `const Schema=${recurse(up)};for(const [k,val] of Object.entries(o)){if(e.has(k)){continue}const result=Schema.safeParse(val);if(!result.success){for(const issue of result.error.issues){${makeIssueForwarding("{...issue,path:[k,...issue.path],input:issue.input}")}}}}`;
2089
- return `(ctx)=>{const o=ctx.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;${[...makeUnevaluatedEvaluationStmts(schema, recurse, schemas), finalStmt].join(";")}}`;
2091
+ const hasAnyOf = guard !== void 0 ? guard.anyOf === true : schema.anyOf !== void 0 && schema.anyOf.length > 0;
2092
+ const hasOneOf = guard !== void 0 ? guard.oneOf === true : schema.oneOf !== void 0 && schema.oneOf.length > 0;
2093
+ const counters = `${hasAnyOf ? "let mA=0;" : ""}${hasOneOf ? "let mO=0;" : ""}`;
2094
+ const evalStmts = makeUnevaluatedEvaluationStmts(schema, recurse, schemas, {
2095
+ ...hasAnyOf ? { anyOf: "mA" } : {},
2096
+ ...hasOneOf ? { oneOf: "mO" } : {}
2097
+ });
2098
+ const guardedFinal = !hasAnyOf && !hasOneOf ? finalStmt : `if(${[...hasAnyOf ? ["mA>0"] : [], ...hasOneOf ? ["mO===1"] : []].join("&&")}){${finalStmt}}`;
2099
+ return `(ctx)=>{const o=ctx.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;${counters}${[...evalStmts, guardedFinal].join(";")}}`;
2090
2100
  }
2091
2101
  function makeBoundErrorArgs(schema, bound, errorMessage) {
2092
2102
  const message = schema[`x-${bound}-message`] ?? errorMessage;
@@ -2551,7 +2561,10 @@ function string(schema, options) {
2551
2561
  // src/generator/zod-to-openapi/index.ts
2552
2562
  function withUnevaluatedCheck(zod, unevalCheck) {
2553
2563
  if (unevalCheck === "") return zod;
2554
- return `(()=>{const Schema=${zod};return z.preprocess((val: z.input<typeof Schema>,ctx)=>{const result=Schema.safeParse(val);if(result.success){(${unevalCheck})(ctx)}return val},Schema)})()`;
2564
+ return `(()=>{const Schema=${zod};return z.preprocess((val: z.input<typeof Schema>,ctx)=>{(${unevalCheck})(ctx);return val},Schema)})()`;
2565
+ }
2566
+ function hasOwnWrapping(branch) {
2567
+ return branch.nullable === true || normalizeTypes(branch.type).includes("null") || branch.default !== void 0 || branch["x-prefault"] !== void 0 || branch["x-catch"] !== void 0;
2555
2568
  }
2556
2569
  function zodToOpenAPI(schema, meta, options) {
2557
2570
  if (schema === true) return wrap("z.any()", {}, meta, options);
@@ -2597,10 +2610,50 @@ function zodToOpenAPI(schema, meta, options) {
2597
2610
  };
2598
2611
  const child = (s) => childOptions?.coerce !== true && isRefOnly(s) ? makeRef(s.$ref ?? "") : zodToOpenAPI(s, void 0, childOptions);
2599
2612
  const referenced = (s) => childOptions?.coerce !== true && s.$ref ? makeRef(s.$ref) : zodToOpenAPI(s, void 0, childOptions);
2600
- const distribute = (branch, shapeZ, shapeRefine, shapeHasProperties) => {
2613
+ const conformMerged = (coreSchema, shapeSchema, value) => {
2614
+ const core = conformDefault(coreSchema, value, childOptions?.schemas);
2615
+ const shape = conformDefault(shapeSchema, value, childOptions?.schemas);
2616
+ if (!core.ok || !shape.ok) return { ok: false };
2617
+ if (JSON.stringify(core.value) !== JSON.stringify(shape.value)) {
2618
+ if (isRecord(core.value) && isRecord(shape.value)) {
2619
+ for (const key of Object.keys(core.value)) if (Object.hasOwn(shape.value, key) && JSON.stringify(core.value[key]) !== JSON.stringify(shape.value[key])) return { ok: false };
2620
+ return {
2621
+ ok: true,
2622
+ value: {
2623
+ ...core.value,
2624
+ ...shape.value
2625
+ }
2626
+ };
2627
+ }
2628
+ return { ok: false };
2629
+ }
2630
+ return core;
2631
+ };
2632
+ const distributeAdmitting = (branch, shapeZ, shapeRefine, shapeHasProperties, shapeSchema) => {
2633
+ if (branch["x-preprocess"] !== void 0 || branch["x-transform"] !== void 0 || branch["x-pipe"] !== void 0 || branch["x-codec"] !== void 0 || branch["x-refine"] !== void 0 || branch["x-superRefine"] !== void 0 || branch["x-brand"] !== void 0 || branch["x-readonly"] === true || branch["x-catch"] !== void 0) return null;
2634
+ const { nullable: _nullable, default: _default, "x-prefault": _prefault, "x-catch": _catch, type: branchType, ...coreRest } = branch;
2635
+ const [first, ...rest] = normalizeTypes(branchType).filter((type) => type !== "null");
2636
+ const coreSchema = first === void 0 ? { ...coreRest } : {
2637
+ ...coreRest,
2638
+ type: rest.length === 0 ? first : [first, ...rest]
2639
+ };
2640
+ if (canAdmitNullOrUndefined(coreSchema, childOptions?.schemas)) return null;
2641
+ const andZ = `${child(coreSchema)}.and(${shapeZ})`;
2642
+ const distributed = shapeHasProperties ? andZ : `${andZ}.superRefine(${shapeRefine})`;
2643
+ const mergedDefault = branch.default === void 0 ? void 0 : conformMerged(coreSchema, shapeSchema, branch.default);
2644
+ const mergedPrefault = branch["x-prefault"] === void 0 ? void 0 : conformMerged(coreSchema, shapeSchema, branch["x-prefault"]);
2645
+ const defaultIsNull = mergedDefault !== void 0 && mergedDefault.ok && mergedDefault.value === null;
2646
+ const nullable = branch.nullable === true || normalizeTypes(branch.type).includes("null") || defaultIsNull;
2647
+ let out = distributed;
2648
+ if (nullable) out = `${out}.nullable()`;
2649
+ if (mergedDefault?.ok) out = `${out}.default(${JSON.stringify(mergedDefault.value)})`;
2650
+ if (mergedPrefault?.ok) out = `${out}.prefault(${JSON.stringify(mergedPrefault.value)})`;
2651
+ return out;
2652
+ };
2653
+ const distribute = (branch, shapeZ, shapeRefine, shapeHasProperties, shapeSchema) => {
2601
2654
  if (shapeRefine === void 0) return child(branch);
2602
2655
  if (requiresObject(branch, childOptions?.schemas)) {
2603
- if (canAdmitNullOrUndefined(branch, childOptions?.schemas)) return null;
2656
+ if (canAdmitNullOrUndefined(branch, childOptions?.schemas) || hasOwnWrapping(branch)) return distributeAdmitting(branch, shapeZ, shapeRefine, shapeHasProperties, shapeSchema);
2604
2657
  const andZ = `${child(branch)}.and(${shapeZ})`;
2605
2658
  return shapeHasProperties ? andZ : `${andZ}.superRefine(${shapeRefine})`;
2606
2659
  }
@@ -2608,18 +2661,18 @@ function zodToOpenAPI(schema, meta, options) {
2608
2661
  if (branch.allOf !== void 0) return emitsStrippingObject(branch, childOptions?.schemas) ? null : `${child(branch)}.superRefine(${shapeRefine})`;
2609
2662
  if (branch.anyOf !== void 0 && !(isBinaryFile(branch) && hasMimeAlternatives(branch))) {
2610
2663
  if (branch.anyOf.length === 0) return child(branch);
2611
- const parts = branch.anyOf.map((b) => distribute(b, shapeZ, shapeRefine, shapeHasProperties));
2664
+ const parts = branch.anyOf.map((b) => distribute(b, shapeZ, shapeRefine, shapeHasProperties, shapeSchema));
2612
2665
  if (parts.some((part) => part === null)) return null;
2613
2666
  const message = branch["x-implication-message"] ?? branch["x-anyOf-message"] ?? branch["x-error-message"];
2614
- const branchUnevalCheck = makeUnevaluatedPropertiesCheck(branch, (s) => zodToOpenAPI(s, void 0, childOptions), branch["x-error-message"], childOptions?.schemas);
2667
+ const branchUnevalCheck = makeUnevaluatedPropertiesCheck(branch, (s) => zodToOpenAPI(s, void 0, childOptions), branch["x-error-message"], childOptions?.schemas, { anyOf: true });
2615
2668
  return wrap(withUnevaluatedCheck(`z.union([${parts.join(",")}]${message ? `,${error(message)}` : ""})`, branchUnevalCheck), branch, void 0, childOptions?.schemas === void 0 ? {} : { schemas: childOptions.schemas });
2616
2669
  }
2617
2670
  if (branch.oneOf !== void 0) {
2618
2671
  if (branch.oneOf.length === 0) return child(branch);
2619
- const parts = branch.oneOf.map((b) => distribute(b, shapeZ, shapeRefine, shapeHasProperties));
2672
+ const parts = branch.oneOf.map((b) => distribute(b, shapeZ, shapeRefine, shapeHasProperties, shapeSchema));
2620
2673
  if (parts.some((part) => part === null)) return null;
2621
2674
  const message = branch["x-oneOf-message"] ?? branch["x-error-message"];
2622
- const branchUnevalCheck = makeUnevaluatedPropertiesCheck(branch, (s) => zodToOpenAPI(s, void 0, childOptions), branch["x-error-message"], childOptions?.schemas);
2675
+ const branchUnevalCheck = makeUnevaluatedPropertiesCheck(branch, (s) => zodToOpenAPI(s, void 0, childOptions), branch["x-error-message"], childOptions?.schemas, { oneOf: true });
2623
2676
  return wrap(withUnevaluatedCheck(`z.xor([${parts.join(",")}]${message ? `,${error(message)}` : ""})`, branchUnevalCheck), branch, void 0, childOptions?.schemas === void 0 ? {} : { schemas: childOptions.schemas });
2624
2677
  }
2625
2678
  if (normalizeTypes(branch.type).filter((type) => type !== "null").length > 1) return null;
@@ -2659,7 +2712,9 @@ function zodToOpenAPI(schema, meta, options) {
2659
2712
  ...schema.properties ? { properties: schema.properties } : {},
2660
2713
  ...schema.required ? { required: schema.required } : {}
2661
2714
  } : void 0;
2662
- const shapeMember = (objectOnly || membersRequireObject) && schema.properties !== void 0;
2715
+ const intersectionAdmitsNullOrUndefined = (schema.type === void 0 || normalizeTypes(schema.type).includes("null")) && schema.allOf.length > 0 && schema.allOf.every((member) => canAdmitNullOrUndefined(member, childOptions?.schemas) || hasOwnWrapping(member));
2716
+ const parentReAdmitsNull = schema.nullable === true || normalizeTypes(schema.type).includes("null") || schema.allOf.some((s) => s.type === "null" || s.nullable === true && isAnnotationOnly(s));
2717
+ const shapeMember = (objectOnly || membersRequireObject) && schema.properties !== void 0 && !(intersectionAdmitsNullOrUndefined && !parentReAdmitsNull);
2663
2718
  const shapeRefine = shapeSchema === void 0 || shapeMember ? void 0 : emitObjectShapeRefine(shapeSchema, child);
2664
2719
  const shapeCheck = shapeSchema === void 0 || shapeMember ? void 0 : emitObjectShapeCheck(shapeSchema, child);
2665
2720
  const effectiveAllOf = schema.properties !== void 0 ? [...schema.allOf, {
@@ -2690,7 +2745,7 @@ function zodToOpenAPI(schema, meta, options) {
2690
2745
  for (let index = 0; index < members.length; index += 1) {
2691
2746
  const member = members[index];
2692
2747
  if (member === void 0) continue;
2693
- const distributed = distribute(member, shapeZ, shapeRefine, schema.properties !== void 0);
2748
+ const distributed = distribute(member, shapeZ, shapeRefine, schema.properties !== void 0, shapeSchema);
2694
2749
  if (distributed === null || distributed === schemas[index]) continue;
2695
2750
  return schemas.map((s, position) => position === index ? distributed : s).reduce((acc, s, i) => i === 0 ? s : `${acc}.and(${s})`);
2696
2751
  }
@@ -2700,7 +2755,7 @@ function zodToOpenAPI(schema, meta, options) {
2700
2755
  const unevalCheck = makeUnevaluatedPropertiesCheck({
2701
2756
  ...schema,
2702
2757
  allOf: effectiveAllOf
2703
- }, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"], childOptions?.schemas);
2758
+ }, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"], childOptions?.schemas, {});
2704
2759
  if (allOfMessage || unevalCheck) return done(`(()=>{const Schema=${shaped};return z.unknown().check((ctx)=>{${(() => {
2705
2760
  const isArrow = allOfMessage ? ARROW_FUNCTION_PATTERN.test(allOfMessage) : false;
2706
2761
  const msgExpr = allOfMessage ? isArrow ? `(${allOfMessage})(issue)` : JSON.stringify(allOfMessage) : void 0;
@@ -2714,7 +2769,7 @@ function zodToOpenAPI(schema, meta, options) {
2714
2769
  const anyOfMessage = schema["x-implication-message"] ?? schema["x-anyOf-message"] ?? schema["x-error-message"];
2715
2770
  const anyOfErrorArg = anyOfMessage ? `,${error(anyOfMessage)}` : "";
2716
2771
  const unionZ = `z.union([${anyOfSchemas.join(",")}]${anyOfErrorArg})`;
2717
- const unevalCheck = makeUnevaluatedPropertiesCheck(schema, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"], childOptions?.schemas);
2772
+ const unevalCheck = makeUnevaluatedPropertiesCheck(schema, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"], childOptions?.schemas, { anyOf: true });
2718
2773
  if (schema.properties !== void 0 && Object.keys(schema.properties).length > 0 || Array.isArray(schema.required) && schema.required.length > 0) {
2719
2774
  const shapeSchema = {
2720
2775
  type: "object",
@@ -2723,7 +2778,7 @@ function zodToOpenAPI(schema, meta, options) {
2723
2778
  };
2724
2779
  const objectOnly = normalizeTypes(schema.type).includes("object") && normalizeTypes(schema.type).every((type) => type === "object" || type === "null");
2725
2780
  const branchesRequireObject = schema.anyOf.every((branch) => requiresObject(branch, childOptions?.schemas));
2726
- const branchesAdmitNullOrUndefined = (schema.type === void 0 || normalizeTypes(schema.type).includes("null")) && schema.anyOf.some((branch) => canAdmitNullOrUndefined(branch, childOptions?.schemas));
2781
+ const branchesAdmitNullOrUndefined = (schema.type === void 0 || normalizeTypes(schema.type).includes("null")) && schema.anyOf.some((branch) => canAdmitNullOrUndefined(branch, childOptions?.schemas) || hasOwnWrapping(branch));
2727
2782
  if ((objectOnly || branchesRequireObject) && !branchesAdmitNullOrUndefined) {
2728
2783
  const andZ = `${unionZ}.and(${zodToOpenAPI(shapeSchema, void 0, childOptions)})`;
2729
2784
  if (schema.properties === void 0) {
@@ -2734,7 +2789,7 @@ function zodToOpenAPI(schema, meta, options) {
2734
2789
  }
2735
2790
  const shapeZ = zodToOpenAPI(shapeSchema, void 0, childOptions);
2736
2791
  const shapeRefine = emitObjectShapeRefine(shapeSchema, child);
2737
- const distributed = schema.anyOf.map((branch) => distribute(branch, shapeZ, shapeRefine, schema.properties !== void 0));
2792
+ const distributed = schema.anyOf.map((branch) => distribute(branch, shapeZ, shapeRefine, schema.properties !== void 0, shapeSchema));
2738
2793
  if (!distributed.some((part) => part === null)) return done(withUnevaluatedCheck(`z.union([${distributed.join(",")}]${anyOfErrorArg})`, unevalCheck), schema);
2739
2794
  const shapeCheck = emitObjectShapeCheck(shapeSchema, child);
2740
2795
  return done(withUnevaluatedCheck(shapeCheck === void 0 ? unionZ : `z.unknown().check(${shapeCheck}).pipe(${unionZ})`, unevalCheck), schema);
@@ -2748,7 +2803,7 @@ function zodToOpenAPI(schema, meta, options) {
2748
2803
  const oneOfMessage = schema["x-oneOf-message"] ?? schema["x-error-message"];
2749
2804
  const oneOfErrorArg = oneOfMessage ? `,${error(oneOfMessage)}` : "";
2750
2805
  const z = discriminator !== void 0 && discriminatedBranches(schema, options?.schemas) !== void 0 ? `z.discriminatedUnion(${makeStringLiteral(discriminator)},[${oneOfSchemas.join(",")}]${oneOfErrorArg})` : `z.xor([${oneOfSchemas.join(",")}]${oneOfErrorArg})`;
2751
- const unevalCheck = makeUnevaluatedPropertiesCheck(schema, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"], childOptions?.schemas);
2806
+ const unevalCheck = makeUnevaluatedPropertiesCheck(schema, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"], childOptions?.schemas, { oneOf: true });
2752
2807
  if (schema.properties !== void 0 && Object.keys(schema.properties).length > 0 || Array.isArray(schema.required) && schema.required.length > 0) {
2753
2808
  const shapeSchema = {
2754
2809
  type: "object",
@@ -2757,7 +2812,7 @@ function zodToOpenAPI(schema, meta, options) {
2757
2812
  };
2758
2813
  const objectOnly = normalizeTypes(schema.type).includes("object") && normalizeTypes(schema.type).every((type) => type === "object" || type === "null");
2759
2814
  const branchesRequireObject = schema.oneOf.every((branch) => requiresObject(branch, childOptions?.schemas));
2760
- const branchesAdmitNullOrUndefined = (schema.type === void 0 || normalizeTypes(schema.type).includes("null")) && schema.oneOf.some((branch) => canAdmitNullOrUndefined(branch, childOptions?.schemas));
2815
+ const branchesAdmitNullOrUndefined = (schema.type === void 0 || normalizeTypes(schema.type).includes("null")) && schema.oneOf.some((branch) => canAdmitNullOrUndefined(branch, childOptions?.schemas) || hasOwnWrapping(branch));
2761
2816
  if ((objectOnly || branchesRequireObject) && !branchesAdmitNullOrUndefined) {
2762
2817
  const andZ = `${z}.and(${zodToOpenAPI(shapeSchema, void 0, childOptions)})`;
2763
2818
  if (schema.properties === void 0) {
@@ -2768,7 +2823,7 @@ function zodToOpenAPI(schema, meta, options) {
2768
2823
  }
2769
2824
  const shapeZ = zodToOpenAPI(shapeSchema, void 0, childOptions);
2770
2825
  const shapeRefine = emitObjectShapeRefine(shapeSchema, child);
2771
- const distributed = schema.oneOf.map((branch) => distribute(branch, shapeZ, shapeRefine, schema.properties !== void 0));
2826
+ const distributed = schema.oneOf.map((branch) => distribute(branch, shapeZ, shapeRefine, schema.properties !== void 0, shapeSchema));
2772
2827
  if (!distributed.some((part) => part === null)) return done(withUnevaluatedCheck(`z.xor([${distributed.join(",")}]${oneOfErrorArg})`, unevalCheck), schema);
2773
2828
  const shapeCheck = emitObjectShapeCheck(shapeSchema, child);
2774
2829
  return done(withUnevaluatedCheck(shapeCheck === void 0 ? z : `z.unknown().check(${shapeCheck}).pipe(${z})`, unevalCheck), schema);
@@ -1,13 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
2
  import { Q as HOOK_LIBRARIES, q as COMPONENT_NAMES } from "./guard-Rvg4ztIZ.js";
3
- import { C as isInsideDirectory, E as makeGeneratedImport, S as appEntryOutput, T as makeAppEntryImport, _ as headers, a as takibi, b as client, c as securitySchemes, d as requestBodies, f as pathItems, g as links, h as mediaTypes, i as defineTemplate, l as schemas, m as components, n as webhooks, o as route, p as parameters, r as template, s as mock, u as responses, v as examples, w as makeAppEntryFile, x as handlerGroupOf, y as callbacks } from "./core-BkLkX1Sz.js";
3
+ import { C as isInsideDirectory, E as makeGeneratedImport, S as appEntryOutput, T as makeAppEntryImport, _ as headers, a as takibi, b as client, c as securitySchemes, d as requestBodies, f as pathItems, g as links, h as mediaTypes, i as defineTemplate, l as schemas, m as components, n as webhooks, o as route, p as parameters, r as template, s as mock, u as responses, v as examples, w as makeAppEntryFile, x as handlerGroupOf, y as callbacks } from "./core-CT8AnDwr.js";
4
4
  import { t as docs } from "./docs-DC7Q_-PY.js";
5
5
  import { t as hooks } from "./hooks-B2Fcpr_z.js";
6
6
  import { rpc } from "./core/rpc/index.js";
7
7
  import { type } from "./core/type/index.js";
8
8
  import { i as GenerateError } from "./format-BF7SbaMP.js";
9
9
  import { a as unlink, i as readdir, t as exists } from "./file-hO_bjDys.js";
10
- import { n as normalizeOpenAPI } from "./openapi-Cgz-hHsD.js";
10
+ import { n as normalizeOpenAPI } from "./openapi-DWSCULWR.js";
11
11
  import { Effect, FileSystem, Schema } from "effect";
12
12
  import path from "node:path";
13
13
  import SwaggerParser from "@apidevtools/swagger-parser";
@@ -1,9 +1,9 @@
1
1
  import { parseConfig } from "../index.js";
2
2
  import { M as isRecord, tt as INPUT_EXTENSIONS } from "../guard-Rvg4ztIZ.js";
3
3
  import { t as FormatOptions } from "../format-BF7SbaMP.js";
4
- import { C as isInsideDirectory, S as appEntryOutput } from "../core-BkLkX1Sz.js";
4
+ import { C as isInsideDirectory, S as appEntryOutput } from "../core-CT8AnDwr.js";
5
5
  import { n as parseOpenAPI } from "../openapi-BxSVfs_l.js";
6
- import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-Bu8uDxYC.js";
6
+ import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BmIHrl_h.js";
7
7
  import { Effect, FileSystem, Option, Result } from "effect";
8
8
  import path from "node:path";
9
9
  import crypto from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.32.5",
3
+ "version": "0.32.6",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",
@@ -69,14 +69,14 @@
69
69
  "@typespec/openapi3": "^1.17.0",
70
70
  "effect": "4.1.4",
71
71
  "oxc-parser": "^0.158.0",
72
- "oxfmt": "^0.77.0"
72
+ "oxfmt": "^0.78.0"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@faker-js/faker": "^10.6.0",
76
76
  "@hono/zod-openapi": "^1.6.3",
77
77
  "@types/node": "^26.6.6",
78
78
  "@typespec/http": "^1.17.0",
79
- "@typespec/rest": "^0.87.0",
79
+ "@typespec/rest": "^0.88.0",
80
80
  "hono": "^4.13.17",
81
81
  "typescript": "^7.0.2",
82
82
  "zod": "^4.6.7"