hono-takibi 0.32.1 → 0.32.3

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.1";
8
+ var version = "0.32.3";
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-BohdqQVB.js").then((n) => n.o)
44
+ import("./shared-C7pHMuGq.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-BohdqQVB.js").then((n) => n.o));
82
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-C7pHMuGq.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-BErYCEq-.js").then((n) => n.t),
212
- import("./shared-BohdqQVB.js").then((n) => n.o)
211
+ import("./core-BH4uT5Z5.js").then((n) => n.t),
212
+ import("./shared-C7pHMuGq.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-BaXZEgTP.js";
6
- import { t as zodOpenAPIHono } from "./openapi-B8oA5BKZ.js";
7
- import { t as makeMock } from "./mock-D2cCG7D7.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-BLjJU-RS.js";
6
+ import { t as zodOpenAPIHono } from "./openapi-CJCgn7NT.js";
7
+ import { t as makeMock } from "./mock-CkcuVVvQ.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-BohdqQVB.js";
4
+ import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-C7pHMuGq.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-D2cCG7D7.js";
1
+ export { t as makeMock } from "../../mock-CkcuVVvQ.js";
@@ -1 +1 @@
1
- export { t as zodOpenAPIHono } from "../../../openapi-B8oA5BKZ.js";
1
+ export { t as zodOpenAPIHono } from "../../../openapi-CJCgn7NT.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-BaXZEgTP.js";
3
+ import { n as componentsCode, t as routeCode } from "./routes-BLjJU-RS.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-BaXZEgTP.js";
3
+ import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-BLjJU-RS.js";
4
4
  // src/helper/names.ts
5
5
  /**
6
6
  * Renames the components whose identifiers would collide, and every `$ref` to them.
@@ -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(",")}}`;
@@ -1585,6 +1649,11 @@ function wrap(zod, schema, meta, options) {
1585
1649
  ].flatMap((key) => schema[key] === void 0 ? [] : [`${key}:${JSON.stringify(schema[key])}`]),
1586
1650
  ...schema.const === void 0 || schema.enum !== void 0 ? [] : [`enum:${JSON.stringify([schema.const])}`]
1587
1651
  ] : [];
1652
+ const patternMetaProps = meta?.parameters === void 0 && meta?.headers === void 0 && schema.patternProperties !== void 0 && Object.keys(schema.patternProperties).length > 0 ? [
1653
+ `...{patternProperties:${JSON.stringify(Object.fromEntries(Object.entries(schema.patternProperties).map(([pattern, sub]) => [pattern, pruneSchemaObject(inlineSchemaRefs(sub, options?.schemas), true)])))}}`,
1654
+ ...schema.additionalProperties === false ? ["additionalProperties:false"] : [],
1655
+ ...typeof schema.additionalProperties === "object" ? [`additionalProperties:${schemaLiteral(pruneSchemaObject(inlineSchemaRefs(schema.additionalProperties, options?.schemas), true))}`] : []
1656
+ ] : [];
1588
1657
  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
1658
  if (options?.component === true && parameter !== void 0 && !isDecorated) {
1590
1659
  const inside = absent(build(around(`${zod}.openapi({param:${makeSerializedParam(parameter)}})`)));
@@ -1597,6 +1666,7 @@ function wrap(zod, schema, meta, options) {
1597
1666
  ...fileMetaProps,
1598
1667
  ...timeMetaProps,
1599
1668
  ...bigintMetaProps,
1669
+ ...patternMetaProps,
1600
1670
  openapiSchemaBody && openapiSchemaBody.length > 0 ? openapiSchemaBody : void 0
1601
1671
  ].filter((v) => v !== void 0);
1602
1672
  if (meta?.parameters || meta?.headers) {
@@ -2107,7 +2177,8 @@ function object(schema, options) {
2107
2177
  const elseOverride = elseMessage ? `,message:${JSON.stringify(elseMessage)}` : "";
2108
2178
  const propertiesMessage = schema["x-properties-message"];
2109
2179
  const needsLoose = schema.additionalProperties === void 0 && (schema.patternProperties !== void 0 || schema.propertyNames !== void 0 || schema.unevaluatedProperties !== void 0 || Object.keys(schema.properties ?? {}).length === 0);
2110
- const objectType = schema.additionalProperties === true ? "looseObject" : schema.additionalProperties === false ? "strictObject" : needsLoose ? "looseObject" : "object";
2180
+ const hasPatternProperties = schema.patternProperties !== void 0 && Object.keys(schema.patternProperties).length > 0;
2181
+ const objectType = schema.additionalProperties === true ? "looseObject" : schema.additionalProperties === false ? hasPatternProperties ? "looseObject" : "strictObject" : needsLoose ? "looseObject" : "object";
2111
2182
  const propertiesCode = schema.properties ? Object.entries(schema.properties).map(([key, propSchema]) => {
2112
2183
  const isRequired = Array.isArray(schema.required) && schema.required.includes(key);
2113
2184
  return `${makeSafeKey(key)}:${zodToOpenAPI(propSchema, void 0, {
@@ -2123,7 +2194,8 @@ function object(schema, options) {
2123
2194
  if (!hasStrictAdditional && !propertiesMessage && !errorMessageEffective) return "";
2124
2195
  return `,{error:(issue)=>issue.code==='unrecognized_keys'?${hasStrictAdditional ? JSON.stringify(additionalPropertiesMessage) : "undefined"}:${propertiesMessage ? JSON.stringify(propertiesMessage) : errorMessageEffective ? JSON.stringify(errorMessageEffective) : "undefined"}}`;
2125
2196
  })();
2126
- 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})`;
2197
+ const additionalSchema = typeof schema.additionalProperties === "object" ? zodToOpenAPI(schema.additionalProperties, void 0, options) : void 0;
2198
+ 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})`;
2127
2199
  const minProperties = typeof schema.minProperties === "number" ? `.refine((val)=>Object.keys(val).length>=${schema.minProperties}${minErrorArg})` : "";
2128
2200
  const maxProperties = typeof schema.maxProperties === "number" ? `.refine((val)=>Object.keys(val).length<=${schema.maxProperties}${maxErrorArg})` : "";
2129
2201
  const propertyNamesMessageField = propertyNamesMessage ? `,message:${JSON.stringify(propertyNamesMessage)}` : "";
@@ -2137,6 +2209,16 @@ function object(schema, options) {
2137
2209
  const zodSchema = zodToOpenAPI(propSchema, void 0, options);
2138
2210
  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}})}}}})`;
2139
2211
  }).join("") : "";
2212
+ const isAdditionalKey = (() => {
2213
+ const declaredKeys = Object.keys(schema.properties ?? {});
2214
+ const patterns = Object.keys(schema.patternProperties ?? {});
2215
+ return [...declaredKeys.length > 0 ? [`!${JSON.stringify(declaredKeys)}.includes(k)`] : [], `!${JSON.stringify(patterns)}.some((p)=>new RegExp(p).test(k))`].join("&&");
2216
+ })();
2217
+ const undeclaredKeys = schema.additionalProperties === false && hasPatternProperties ? (() => {
2218
+ const messageField = additionalPropertiesMessage !== void 0 ? `,message:${JSON.stringify(additionalPropertiesMessage)}` : "";
2219
+ 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}})}})`;
2220
+ })() : "";
2221
+ 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]})}}}}})` : "";
2140
2222
  const dependentRequired = schema.dependentRequired ? Object.entries(schema.dependentRequired).map(([key, deps]) => {
2141
2223
  const stmts = deps.map((dependency) => {
2142
2224
  const msg = dependentRequiredMessage ?? errorMessage ?? `requires "${dependency}" when "${key}" present`;
@@ -2147,7 +2229,7 @@ function object(schema, options) {
2147
2229
  }).join("") : "";
2148
2230
  const dependentSchemasMessage = schema["x-dependentSchemas-message"] ?? schema["x-error-message"];
2149
2231
  const dependentSchemasMessageField = dependentSchemasMessage !== void 0 ? `,message:${JSON.stringify(dependentSchemasMessage)}` : "";
2150
- return `${base}${minProperties}${maxProperties}${propertyNames}${patternProperties}${dependentRequired}${schema.dependentSchemas ? Object.entries(schema.dependentSchemas).map(([key, subSchema]) => {
2232
+ return `${base}${undeclaredKeys}${additionalKeys}${minProperties}${maxProperties}${propertyNames}${patternProperties}${dependentRequired}${schema.dependentSchemas ? Object.entries(schema.dependentSchemas).map(([key, subSchema]) => {
2151
2233
  const subZod = zodToOpenAPI(subSchema, void 0, options);
2152
2234
  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}})}}})`;
2153
2235
  }).join("") : ""}${(() => {
@@ -2547,7 +2629,7 @@ function zodToOpenAPI(schema, meta, options) {
2547
2629
  }
2548
2630
  if (schema.properties !== void 0 && schema.type === void 0 && !isUntypedObject(schema)) return done(emitTypelessRefine(schema, (s) => zodToOpenAPI(s, void 0, childOptions)), schema);
2549
2631
  if (schema.properties !== void 0 || isUntypedObject(schema)) {
2550
- const needsDefaultRequired = schema.required === void 0 && Object.keys(schema.properties ?? {}).length > 0 && typeof schema.additionalProperties !== "object" && schema.anyOf === void 0;
2632
+ const needsDefaultRequired = schema.required === void 0 && Object.keys(schema.properties ?? {}).length > 0 && schema.anyOf === void 0;
2551
2633
  return done(object(schema, childOptions), needsDefaultRequired ? {
2552
2634
  ...schema,
2553
2635
  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-BErYCEq-.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-BH4uT5Z5.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-B8oA5BKZ.js";
10
+ import { n as normalizeOpenAPI } from "./openapi-CJCgn7NT.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-BErYCEq-.js";
4
+ import { C as isInsideDirectory, S as appEntryOutput } from "../core-BH4uT5Z5.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-BohdqQVB.js";
6
+ import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-C7pHMuGq.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.1",
3
+ "version": "0.32.3",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",