hono-takibi 0.32.2 → 0.32.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.
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.2";
8
+ var version = "0.32.4";
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-CxGcNKCd.js").then((n) => n.o)
44
+ import("./shared-BDYWF9wQ.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-CxGcNKCd.js").then((n) => n.o));
82
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-BDYWF9wQ.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-CK8YfM5b.js").then((n) => n.t),
212
- import("./shared-CxGcNKCd.js").then((n) => n.o)
211
+ import("./core-DuBKXeEi.js").then((n) => n.t),
212
+ import("./shared-BDYWF9wQ.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-EQul_g44.js";
6
- import { t as zodOpenAPIHono } from "./openapi-BMI5cgyx.js";
7
- import { t as makeMock } from "./mock-DlS0Lyq6.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-g-suwftT.js";
6
+ import { t as zodOpenAPIHono } from "./openapi-Dy5PycHC.js";
7
+ import { t as makeMock } from "./mock-m2jO1vos.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-CxGcNKCd.js";
4
+ import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BDYWF9wQ.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-DlS0Lyq6.js";
1
+ export { t as makeMock } from "../../mock-m2jO1vos.js";
@@ -1 +1 @@
1
- export { t as zodOpenAPIHono } from "../../../openapi-BMI5cgyx.js";
1
+ export { t as zodOpenAPIHono } from "../../../openapi-Dy5PycHC.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-EQul_g44.js";
3
+ import { n as componentsCode, t as routeCode } from "./routes-g-suwftT.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-EQul_g44.js";
3
+ import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-g-suwftT.js";
4
4
  // src/helper/names.ts
5
5
  /**
6
6
  * Renames the components whose identifiers would collide, and every `$ref` to them.
@@ -319,7 +319,7 @@ function resolveObject(schema, schemas, seen = []) {
319
319
  const target = resolveSchemaRef(schema.$ref, schemas);
320
320
  return target === void 0 ? void 0 : resolveObject(target, schemas, [...seen, schema.$ref]);
321
321
  }
322
- return normalizeTypes(schema.type).includes("object") || schema.properties !== void 0 ? schema : void 0;
322
+ return normalizeTypes(schema.type).includes("object") || schema.type === void 0 && schema.properties !== void 0 || isUntypedObject(schema) ? schema : void 0;
323
323
  }
324
324
  /**
325
325
  * The function that reads one value holding an object, as source. `separator` is what
@@ -1130,10 +1130,14 @@ const SCHEMA_MAP_KEYS = /* @__PURE__ */ new Set(["properties"]);
1130
1130
  * literal (`null`, `true`) is a string; a 3.0-style `examples` map is its values. The output
1131
1131
  * is what `.openapi()` is handed, so nothing in it may fail to type-check.
1132
1132
  */
1133
- function pruneSchemaObject(schema) {
1133
+ function pruneSchemaObject(schema, patterns = false) {
1134
1134
  if (!isRecord(schema)) return schema;
1135
1135
  const pruned = {};
1136
1136
  for (const [key, value] of Object.entries(schema)) {
1137
+ if (patterns && key === "patternProperties" && isRecord(value)) {
1138
+ pruned[key] = Object.fromEntries(Object.entries(value).map(([pattern, sub]) => [pattern, pruneSchemaObject(sub, patterns)]));
1139
+ continue;
1140
+ }
1137
1141
  if (value === void 0 || !isSchemaObjectKey(key)) continue;
1138
1142
  if (!hasSchemaObjectValueType(key, value)) continue;
1139
1143
  if (key === "required" && Array.isArray(value)) {
@@ -1159,15 +1163,15 @@ function pruneSchemaObject(schema) {
1159
1163
  continue;
1160
1164
  }
1161
1165
  if (SCHEMA_VALUED_KEYS.has(key)) {
1162
- pruned[key] = pruneSchemaObject(value);
1166
+ pruned[key] = pruneSchemaObject(value, patterns);
1163
1167
  continue;
1164
1168
  }
1165
1169
  if (SCHEMA_LIST_KEYS.has(key) && Array.isArray(value)) {
1166
- pruned[key] = value.map(pruneSchemaObject);
1170
+ pruned[key] = value.map((sub) => pruneSchemaObject(sub, patterns));
1167
1171
  continue;
1168
1172
  }
1169
1173
  if (SCHEMA_MAP_KEYS.has(key) && isRecord(value)) {
1170
- pruned[key] = Object.fromEntries(Object.entries(value).map(([name, sub]) => [name, pruneSchemaObject(sub)]));
1174
+ pruned[key] = Object.fromEntries(Object.entries(value).map(([name, sub]) => [name, pruneSchemaObject(sub, patterns)]));
1171
1175
  continue;
1172
1176
  }
1173
1177
  pruned[key] = value;
@@ -1175,6 +1179,66 @@ function pruneSchemaObject(schema) {
1175
1179
  return pruned;
1176
1180
  }
1177
1181
  /**
1182
+ * A pruned schema as the object literal `.openapi()` and `param.schema` are handed. It is
1183
+ * the JSON of the schema, except where an object has `patternProperties`: the type of a
1184
+ * Schema Object has no such key, and a literal that names it does not type-check, so the
1185
+ * keyword is brought by a spread, which is not checked for the keys it brings (#452). That
1186
+ * holds one level deep only — a literal nested in the spread is checked again — so every
1187
+ * object that has the keyword is written this way, wherever it stands. What a
1188
+ * `patternProperties` holds has no type to answer to, and is JSON as it is.
1189
+ */
1190
+ function schemaLiteral(schema) {
1191
+ if (!hasPatternProperties(schema)) return JSON.stringify(schema);
1192
+ if (Array.isArray(schema)) return `[${schema.map(schemaLiteral).join(",")}]`;
1193
+ if (!isRecord(schema)) return JSON.stringify(schema);
1194
+ return `{${Object.entries(schema).flatMap(([key, value]) => {
1195
+ if (value === void 0) return [];
1196
+ if (key === "patternProperties") return [`...{patternProperties:${JSON.stringify(value)}}`];
1197
+ if (SCHEMA_VALUED_KEYS.has(key) || SCHEMA_LIST_KEYS.has(key)) return [`${JSON.stringify(key)}:${schemaLiteral(value)}`];
1198
+ if (SCHEMA_MAP_KEYS.has(key) && isRecord(value)) {
1199
+ const members = Object.entries(value).map(([name, sub]) => `${JSON.stringify(name)}:${schemaLiteral(sub)}`);
1200
+ return [`${JSON.stringify(key)}:{${members.join(",")}}`];
1201
+ }
1202
+ return [`${JSON.stringify(key)}:${JSON.stringify(value)}`];
1203
+ }).join(",")}}`;
1204
+ }
1205
+ /** Whether a pruned schema has `patternProperties` where a Schema Object is typed. */
1206
+ function hasPatternProperties(schema) {
1207
+ if (Array.isArray(schema)) return schema.some(hasPatternProperties);
1208
+ if (!isRecord(schema)) return false;
1209
+ return Object.entries(schema).some(([key, value]) => {
1210
+ if (key === "patternProperties") return true;
1211
+ if (SCHEMA_VALUED_KEYS.has(key) || SCHEMA_LIST_KEYS.has(key)) return hasPatternProperties(value);
1212
+ return SCHEMA_MAP_KEYS.has(key) && isRecord(value) ? Object.values(value).some(hasPatternProperties) : false;
1213
+ });
1214
+ }
1215
+ /**
1216
+ * A schema with every reference to a component written out as the component, at every
1217
+ * level. What `patternProperties` holds reaches the document as metadata (#452), where a
1218
+ * reference would name a component the document defines only when a route uses it. A
1219
+ * reference `schemas` has not stays as written; one that leads back to itself is any value.
1220
+ */
1221
+ function inlineSchemaRefs(schema, schemas, reading = /* @__PURE__ */ new Set()) {
1222
+ if (!isRecord(schema)) return schema;
1223
+ const ref = schema.$ref;
1224
+ if (typeof ref === "string") {
1225
+ if (reading.has(ref)) return {};
1226
+ const target = resolveSchemaRef(ref, schemas);
1227
+ if (target === void 0) return schema;
1228
+ const { $ref: _ref, ...beside } = schema;
1229
+ return inlineSchemaRefs({
1230
+ ...target,
1231
+ ...beside
1232
+ }, schemas, /* @__PURE__ */ new Set([...reading, ref]));
1233
+ }
1234
+ return Object.fromEntries(Object.entries(schema).map(([key, value]) => {
1235
+ if (SCHEMA_VALUED_KEYS.has(key)) return [key, inlineSchemaRefs(value, schemas, reading)];
1236
+ if (SCHEMA_LIST_KEYS.has(key) && Array.isArray(value)) return [key, value.map((sub) => inlineSchemaRefs(sub, schemas, reading))];
1237
+ if ((SCHEMA_MAP_KEYS.has(key) || key === "patternProperties") && isRecord(value)) return [key, Object.fromEntries(Object.entries(value).map(([name, sub]) => [name, inlineSchemaRefs(sub, schemas, reading)]))];
1238
+ return [key, value];
1239
+ }));
1240
+ }
1241
+ /**
1178
1242
  * `examples` as the Schema Object has it, a list of values: a list is taken as it is, and a
1179
1243
  * map of Example Objects (the 3.0 shape of a Header or Parameter Object, #398) is reduced to
1180
1244
  * the values its entries carry. A map whose entries carry none (`externalValue`, `$ref`) has
@@ -1347,11 +1411,11 @@ const PARAMETER_KEYS = /* @__PURE__ */ new Set([
1347
1411
  function makeSerializedParam(param) {
1348
1412
  return `{${Object.entries(param).filter(([key, value]) => value !== void 0 && (PARAMETER_KEYS.has(key) || key.startsWith("x-"))).map(([key, value]) => {
1349
1413
  if (key === "examples" && isExamplesInput(value)) return `"examples":${makeExamples(value)}`;
1350
- if (key === "schema") return `"schema":${JSON.stringify(pruneSchemaObject(value))}`;
1414
+ if (key === "schema") return `"schema":${schemaLiteral(pruneSchemaObject(value, true))}`;
1351
1415
  if (key === "content" && isRecord(value)) return `"content":{${Object.entries(value).map(([mediaType, mediaObj]) => {
1352
1416
  if (!isRecord(mediaObj)) return `${JSON.stringify(mediaType)}:${JSON.stringify(mediaObj)}`;
1353
1417
  const { examples: mediaExamples, ...mediaRest } = mediaObj;
1354
- const restEntries = Object.entries(mediaRest).filter(([, v]) => v !== void 0).map(([k, v]) => `${JSON.stringify(k)}:${JSON.stringify(k === "schema" ? pruneSchemaObject(v) : v)}`);
1418
+ const restEntries = Object.entries(mediaRest).filter(([, v]) => v !== void 0).map(([k, v]) => `${JSON.stringify(k)}:${k === "schema" ? schemaLiteral(pruneSchemaObject(v, true)) : JSON.stringify(v)}`);
1355
1419
  const examplesEntry = isExamplesInput(mediaExamples) ? `"examples":${makeExamples(mediaExamples)}` : void 0;
1356
1420
  const mediaEntries = examplesEntry ? [...restEntries, examplesEntry] : restEntries;
1357
1421
  return `${JSON.stringify(mediaType)}:{${mediaEntries.join(",")}}`;
@@ -1505,6 +1569,7 @@ function wrap(zod, schema, meta, options) {
1505
1569
  return `${v}`;
1506
1570
  }
1507
1571
  if (schema.type === "date" && typeof v === "string") return `new Date(${JSON.stringify(v)})`;
1572
+ if ((v === "true" || v === "false") && ((schema.enum?.includes(v) ?? false) || schema.const === v)) return JSON.stringify(v);
1508
1573
  if (typeList.includes("boolean") && (v === "true" || v === "false")) return v;
1509
1574
  return JSON.stringify(v);
1510
1575
  };
@@ -1585,6 +1650,11 @@ function wrap(zod, schema, meta, options) {
1585
1650
  ].flatMap((key) => schema[key] === void 0 ? [] : [`${key}:${JSON.stringify(schema[key])}`]),
1586
1651
  ...schema.const === void 0 || schema.enum !== void 0 ? [] : [`enum:${JSON.stringify([schema.const])}`]
1587
1652
  ] : [];
1653
+ const patternMetaProps = meta?.parameters === void 0 && meta?.headers === void 0 && schema.patternProperties !== void 0 && Object.keys(schema.patternProperties).length > 0 ? [
1654
+ `...{patternProperties:${JSON.stringify(Object.fromEntries(Object.entries(schema.patternProperties).map(([pattern, sub]) => [pattern, pruneSchemaObject(inlineSchemaRefs(sub, options?.schemas), true)])))}}`,
1655
+ ...schema.additionalProperties === false ? ["additionalProperties:false"] : [],
1656
+ ...typeof schema.additionalProperties === "object" ? [`additionalProperties:${schemaLiteral(pruneSchemaObject(inlineSchemaRefs(schema.additionalProperties, options?.schemas), true))}`] : []
1657
+ ] : [];
1588
1658
  const isDecorated = isNullable || schema.default !== void 0 || schema["x-prefault"] !== void 0 || schema["x-catch"] !== void 0 || schema["x-readonly"] === true || schema["x-refine"] !== void 0 || schema["x-superRefine"] !== void 0 || schema["x-brand"] !== void 0 || schema["x-preprocess"] !== void 0 || schema["x-transform"] !== void 0 || schema["x-pipe"] !== void 0 || schema["x-codec"] !== void 0;
1589
1659
  if (options?.component === true && parameter !== void 0 && !isDecorated) {
1590
1660
  const inside = absent(build(around(`${zod}.openapi({param:${makeSerializedParam(parameter)}})`)));
@@ -1597,6 +1667,7 @@ function wrap(zod, schema, meta, options) {
1597
1667
  ...fileMetaProps,
1598
1668
  ...timeMetaProps,
1599
1669
  ...bigintMetaProps,
1670
+ ...patternMetaProps,
1600
1671
  openapiSchemaBody && openapiSchemaBody.length > 0 ? openapiSchemaBody : void 0
1601
1672
  ].filter((v) => v !== void 0);
1602
1673
  if (meta?.parameters || meta?.headers) {
@@ -2124,7 +2195,8 @@ function object(schema, options) {
2124
2195
  if (!hasStrictAdditional && !propertiesMessage && !errorMessageEffective) return "";
2125
2196
  return `,{error:(issue)=>issue.code==='unrecognized_keys'?${hasStrictAdditional ? JSON.stringify(additionalPropertiesMessage) : "undefined"}:${propertiesMessage ? JSON.stringify(propertiesMessage) : errorMessageEffective ? JSON.stringify(errorMessageEffective) : "undefined"}}`;
2126
2197
  })();
2127
- const base = typeof schema.additionalProperties === "object" ? Object.keys(schema.properties ?? {}).length > 0 ? `z.object({${propertiesCode}}${objectParams}).catchall(${zodToOpenAPI(schema.additionalProperties, void 0, options)})` : `z.record(z.string(),${zodToOpenAPI(schema.additionalProperties, void 0, options)})` : `z.${objectType}({${propertiesCode}}${objectParams})`;
2198
+ const additionalSchema = typeof schema.additionalProperties === "object" ? zodToOpenAPI(schema.additionalProperties, void 0, options) : void 0;
2199
+ const base = additionalSchema === void 0 ? `z.${objectType}({${propertiesCode}}${objectParams})` : hasPatternProperties ? `z.looseObject({${propertiesCode}}${objectParams})` : Object.keys(schema.properties ?? {}).length > 0 ? `z.object({${propertiesCode}}${objectParams}).catchall(${additionalSchema})` : `z.record(z.string(),${additionalSchema})`;
2128
2200
  const minProperties = typeof schema.minProperties === "number" ? `.refine((val)=>Object.keys(val).length>=${schema.minProperties}${minErrorArg})` : "";
2129
2201
  const maxProperties = typeof schema.maxProperties === "number" ? `.refine((val)=>Object.keys(val).length<=${schema.maxProperties}${maxErrorArg})` : "";
2130
2202
  const propertyNamesMessageField = propertyNamesMessage ? `,message:${JSON.stringify(propertyNamesMessage)}` : "";
@@ -2138,12 +2210,16 @@ function object(schema, options) {
2138
2210
  const zodSchema = zodToOpenAPI(propSchema, void 0, options);
2139
2211
  return `.superRefine((o,ctx)=>{const regex=new RegExp(${JSON.stringify(pattern)});const Schema=${zodSchema};for(const [k,val] of Object.entries(o)){if(!regex.test(k)){continue}const result=Schema.safeParse(val);if(!result.success){for(const issue of result.error.issues){ctx.addIssue({...issue,path:[k,...issue.path]${patternPropertiesMessageOverride}})}}}})`;
2140
2212
  }).join("") : "";
2141
- const undeclaredKeys = schema.additionalProperties === false && hasPatternProperties ? (() => {
2213
+ const isAdditionalKey = (() => {
2142
2214
  const declaredKeys = Object.keys(schema.properties ?? {});
2143
2215
  const patterns = Object.keys(schema.patternProperties ?? {});
2216
+ return [...declaredKeys.length > 0 ? [`!${JSON.stringify(declaredKeys)}.includes(k)`] : [], `!${JSON.stringify(patterns)}.some((p)=>new RegExp(p).test(k))`].join("&&");
2217
+ })();
2218
+ const undeclaredKeys = schema.additionalProperties === false && hasPatternProperties ? (() => {
2144
2219
  const messageField = additionalPropertiesMessage !== void 0 ? `,message:${JSON.stringify(additionalPropertiesMessage)}` : "";
2145
- return `.superRefine((o,ctx)=>{const keys=Object.keys(o).filter((k)=>${[...declaredKeys.length > 0 ? [`!${JSON.stringify(declaredKeys)}.includes(k)`] : [], `!${JSON.stringify(patterns)}.some((p)=>new RegExp(p).test(k))`].join("&&")});if(keys.length>0){ctx.addIssue({code:"unrecognized_keys",keys,input:o${messageField}})}})`;
2220
+ return `.superRefine((o,ctx)=>{const keys=Object.keys(o).filter((k)=>${isAdditionalKey});if(keys.length>0){ctx.addIssue({code:"unrecognized_keys",keys,input:o${messageField}})}})`;
2146
2221
  })() : "";
2222
+ const additionalKeys = additionalSchema !== void 0 && hasPatternProperties ? `.superRefine((o,ctx)=>{const Schema=${additionalSchema};for(const [k,val] of Object.entries(o)){if(${isAdditionalKey}){const result=Schema.safeParse(val);if(!result.success){for(const issue of result.error.issues){ctx.addIssue({...issue,path:[k,...issue.path]})}}}}})` : "";
2147
2223
  const dependentRequired = schema.dependentRequired ? Object.entries(schema.dependentRequired).map(([key, deps]) => {
2148
2224
  const stmts = deps.map((dependency) => {
2149
2225
  const msg = dependentRequiredMessage ?? errorMessage ?? `requires "${dependency}" when "${key}" present`;
@@ -2154,7 +2230,7 @@ function object(schema, options) {
2154
2230
  }).join("") : "";
2155
2231
  const dependentSchemasMessage = schema["x-dependentSchemas-message"] ?? schema["x-error-message"];
2156
2232
  const dependentSchemasMessageField = dependentSchemasMessage !== void 0 ? `,message:${JSON.stringify(dependentSchemasMessage)}` : "";
2157
- return `${base}${undeclaredKeys}${minProperties}${maxProperties}${propertyNames}${patternProperties}${dependentRequired}${schema.dependentSchemas ? Object.entries(schema.dependentSchemas).map(([key, subSchema]) => {
2233
+ return `${base}${undeclaredKeys}${additionalKeys}${minProperties}${maxProperties}${propertyNames}${patternProperties}${dependentRequired}${schema.dependentSchemas ? Object.entries(schema.dependentSchemas).map(([key, subSchema]) => {
2158
2234
  const subZod = zodToOpenAPI(subSchema, void 0, options);
2159
2235
  return `.superRefine((o,ctx)=>{if(!Object.hasOwn(o,${JSON.stringify(key)})){return}const Schema=${subZod};const result=Schema.safeParse(o);if(!result.success){for(const issue of result.error.issues){ctx.addIssue({...issue,path:issue.path${dependentSchemasMessageField}})}}})`;
2160
2236
  }).join("") : ""}${(() => {
@@ -2553,8 +2629,8 @@ function zodToOpenAPI(schema, meta, options) {
2553
2629
  return done(isJson && isBigintFormat && schema.enum.some((member) => typeof member === "number") ? `z.preprocess(${JSON_BIGINT},${members})` : members, schema);
2554
2630
  }
2555
2631
  if (schema.properties !== void 0 && schema.type === void 0 && !isUntypedObject(schema)) return done(emitTypelessRefine(schema, (s) => zodToOpenAPI(s, void 0, childOptions)), schema);
2556
- if (schema.properties !== void 0 || isUntypedObject(schema)) {
2557
- const needsDefaultRequired = schema.required === void 0 && Object.keys(schema.properties ?? {}).length > 0 && typeof schema.additionalProperties !== "object" && schema.anyOf === void 0;
2632
+ if (schema.properties !== void 0 && normalizeTypes(schema.type).includes("object") || isUntypedObject(schema)) {
2633
+ const needsDefaultRequired = schema.required === void 0 && Object.keys(schema.properties ?? {}).length > 0 && schema.anyOf === void 0;
2558
2634
  return done(object(schema, childOptions), needsDefaultRequired ? {
2559
2635
  ...schema,
2560
2636
  required: []
@@ -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-CK8YfM5b.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-DuBKXeEi.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-BMI5cgyx.js";
10
+ import { n as normalizeOpenAPI } from "./openapi-Dy5PycHC.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-CK8YfM5b.js";
4
+ import { C as isInsideDirectory, S as appEntryOutput } from "../core-DuBKXeEi.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-CxGcNKCd.js";
6
+ import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BDYWF9wQ.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.2",
3
+ "version": "0.32.4",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",