hono-takibi 0.9.992 → 0.9.994

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/README.md CHANGED
@@ -134,6 +134,38 @@ z.string({ error: 'Name is required' }).min(1, { error: 'Name cannot be empty' }
134
134
  | `x-propertyNames-message` | `propertyNames` |
135
135
  | `x-dependentRequired-message` | `dependentRequired` |
136
136
 
137
+ ## Branded Types
138
+
139
+ Use the `x-brand` vendor extension to generate [Zod branded types](https://zod.dev/api?id=branded-types), creating nominal types that are structurally identical but semantically distinct:
140
+
141
+ ```yaml
142
+ components:
143
+ schemas:
144
+ Cat:
145
+ type: object
146
+ properties:
147
+ name:
148
+ type: string
149
+ required:
150
+ - name
151
+ x-brand: Cat
152
+ Dog:
153
+ type: object
154
+ properties:
155
+ name:
156
+ type: string
157
+ required:
158
+ - name
159
+ x-brand: Dog
160
+ ```
161
+
162
+ ```ts
163
+ // Generated output
164
+ const CatSchema = z.object({ name: z.string() }).brand<'Cat'>().openapi('Cat')
165
+
166
+ const DogSchema = z.object({ name: z.string() }).brand<'Dog'>().openapi('Dog')
167
+ ```
168
+
137
169
  ## Vite Plugin
138
170
 
139
171
  Watches your OpenAPI spec and `hono-takibi.config.ts` for changes, then auto-regenerates code on save.
@@ -632,4 +632,4 @@ declare function defineConfig(config: ConfigInput): Readonly<{
632
632
  };
633
633
  }>;
634
634
  //#endregion
635
- export { defineConfig, parseConfig, readConfig };
635
+ export { Config, defineConfig, parseConfig, readConfig };
@@ -175,6 +175,7 @@ const ConfigSchema = z.object({
175
175
  ...config["zod-openapi"],
176
176
  ...config["zod-openapi"].routes && { routes: normalize(config["zod-openapi"].routes) },
177
177
  ...config["zod-openapi"].components && { components: {
178
+ ...config["zod-openapi"].components,
178
179
  ...config["zod-openapi"].components.schemas && { schemas: normalize(config["zod-openapi"].components.schemas) },
179
180
  ...config["zod-openapi"].components.parameters && { parameters: normalize(config["zod-openapi"].components.parameters) },
180
181
  ...config["zod-openapi"].components.headers && { headers: normalize(config["zod-openapi"].components.headers) },
@@ -210,6 +211,13 @@ function parseConfig(config) {
210
211
  };
211
212
  }
212
213
  /**
214
+ * Dynamic import wrapper that avoids Vite's static analysis.
215
+ * Vite warns about dynamic imports it cannot analyze at build time.
216
+ * Using an indirect call prevents the warning since Vite only analyzes
217
+ * direct `import()` expressions.
218
+ */
219
+ const dynamicImport = (specifier) => new Function("specifier", "return import(specifier)")(specifier);
220
+ /**
213
221
  * Reads and validates the hono-takibi configuration from hono-takibi.config.ts.
214
222
  */
215
223
  async function readConfig() {
@@ -220,7 +228,8 @@ async function readConfig() {
220
228
  };
221
229
  try {
222
230
  register();
223
- const mod = await import(pathToFileURL(abs).href);
231
+ const url = pathToFileURL(abs).href;
232
+ const mod = await dynamicImport(url);
224
233
  if (!("default" in mod) || mod.default === void 0) return {
225
234
  ok: false,
226
235
  error: "Config must export default object"
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/generator/docs/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/core/rpc/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/core/svelte-query/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/core/swr/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/core/tanstack-query/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/core/type/index.d.ts
4
4
  /**
@@ -176,7 +176,11 @@ function makeSchemaTypeString(schema, components, visited) {
176
176
  if (schema.anyOf && schema.anyOf.length > 0) return schema.anyOf.map((s) => makeSchemaTypeString(s, components, visited)).join("|");
177
177
  if (schema.allOf && schema.allOf.length > 0) return makeAllOfTypeString(schema.allOf, components, visited);
178
178
  if (schema.enum && schema.enum.length > 0) return schema.enum.map((v) => typeof v === "string" ? `'${v.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'` : String(v)).join("|");
179
- if (schema.const !== void 0) return typeof schema.const === "string" ? `'${String(schema.const).replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'` : typeof schema.const === "object" ? JSON.stringify(schema.const) : String(schema.const);
179
+ if (schema.const !== void 0) {
180
+ if (typeof schema.const === "string") return `'${schema.const.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
181
+ if (typeof schema.const === "number" || typeof schema.const === "boolean") return String(schema.const);
182
+ return JSON.stringify(schema.const);
183
+ }
180
184
  const types = makeNormalizedTypes(schema);
181
185
  const isNullable = schema.nullable === true || types.includes("null");
182
186
  const baseType = makeBaseTypeString(schema, types.filter((t) => t !== "null"), components, visited);
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/core/vue-query/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../../index-C0mJiFsw.js";
1
+ import { t as OpenAPI } from "../../../index-CMf0VrGm.js";
2
2
 
3
3
  //#region src/generator/zod-openapi-hono/openapi/index.d.ts
4
4
  /**
@@ -1,2 +1,2 @@
1
- import { t as zodOpenAPIHono } from "../../../openapi-ySW4cz2Q.js";
1
+ import { t as zodOpenAPIHono } from "../../../openapi-BZ9b1y3X.js";
2
2
  export { zodOpenAPIHono };
@@ -356,6 +356,7 @@ type Schema = {
356
356
  readonly 'x-enum-error-messages'?: {
357
357
  readonly [k: string]: string;
358
358
  };
359
+ readonly 'x-brand'?: string;
359
360
  };
360
361
  type Parameter = {
361
362
  readonly $ref?: Ref;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { readConfig } from "./config/index.js";
3
3
  import { r as setFormatOptions } from "./core-BlUaJE2n.js";
4
- import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "./openapi-BNsdBSpS.js";
4
+ import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "./openapi-BBy6frF3.js";
5
5
  import { t as docs } from "./docs-Da_MOdAe.js";
6
6
  import { rpc } from "./core/rpc/index.js";
7
7
  import { svelteQuery } from "./core/svelte-query/index.js";
@@ -1,6 +1,6 @@
1
1
  import { i as isMediaWithSchema, n as isHttpMethod, p as isRefObject, s as isOperation, t as isContentBody, v as isSecurityArray, y as isSecurityScheme } from "./guard-BabA4f3q.js";
2
2
  import { d as toIdentifierPascalCase, f as uncapitalize, i as makeBarrel, l as renderNamedImport, n as ensureSuffix, p as zodToOpenAPISchema, s as methodPath } from "./utils-B9bUHU9P.js";
3
- import { _ as zodToOpenAPI, a as schemasCode, c as pathItemsCode, d as makeSplitSchemaFile, f as makeConst, g as ast, h as analyzeCircularSchemas, i as componentsCode, l as parametersCode, m as makeImports, n as webhookCode, o as responsesCode, p as makeExportConst, r as routeCode, s as requestBodiesCode, t as zodOpenAPIHono, u as headersCode, v as makeCallback, y as makeRef } from "./openapi-ySW4cz2Q.js";
3
+ import { _ as zodToOpenAPI, a as schemasCode, c as pathItemsCode, d as makeSplitSchemaFile, f as makeConst, g as ast, h as analyzeCircularSchemas, i as componentsCode, l as parametersCode, m as makeImports, n as webhookCode, o as responsesCode, p as makeExportConst, r as routeCode, s as requestBodiesCode, t as zodOpenAPIHono, u as headersCode, v as makeCallback, y as makeRef } from "./openapi-BZ9b1y3X.js";
4
4
  import { n as fmt, t as core } from "./core-BlUaJE2n.js";
5
5
  import { a as writeFile, i as unlink, n as readFile, r as readdir, t as mkdir } from "./fsp-Bv1yR6UV.js";
6
6
  import path from "node:path";
@@ -115,30 +115,30 @@ function makeExamples(examples) {
115
115
  }).join(",")}}`;
116
116
  }
117
117
  /** Generates code for an operation's responses object. */
118
- function makeOperationResponses(responses) {
118
+ function makeOperationResponses(responses, readonly) {
119
119
  const isResponse = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
120
120
  return `{${Object.entries(responses).map(([statusCode, res]) => {
121
121
  if (!isResponse(res)) return void 0;
122
- return `${/^\d+$/.test(statusCode) ? statusCode : `'${statusCode}'`}:${makeResponses(res)}`;
122
+ return `${/^\d+$/.test(statusCode) ? statusCode : `'${statusCode}'`}:${makeResponses(res, readonly)}`;
123
123
  }).filter((v) => v !== void 0).join(",")}}`;
124
124
  }
125
125
  /** Generates a Zod object schema for response headers. */
126
- function makeHeaderResponses(headers) {
127
- return `z.object({${Object.entries(headers).map(([k, header]) => `${JSON.stringify(k)}:${makeHeadersAndReferences(header)}`).join(",")}})`;
126
+ function makeHeaderResponses(headers, readonly) {
127
+ return `z.object({${Object.entries(headers).map(([k, header]) => `${JSON.stringify(k)}:${makeHeadersAndReferences(header, readonly)}`).join(",")}})`;
128
128
  }
129
129
  /** Generates code for a single response object (handles `$ref` and inline). */
130
- function makeResponses(responses) {
130
+ function makeResponses(responses, readonly) {
131
131
  if (responses.$ref) return makeRef(responses.$ref);
132
132
  return `{${[
133
133
  responses.summary ? `summary:${JSON.stringify(responses.summary)}` : void 0,
134
134
  `description:${JSON.stringify(responses.description || "")}`,
135
- responses.headers ? `headers:${makeHeaderResponses(responses.headers)}` : void 0,
136
- responses.content ? `content:{${makeContent(responses.content).join(",")}}` : void 0,
135
+ responses.headers ? `headers:${makeHeaderResponses(responses.headers, readonly)}` : void 0,
136
+ responses.content ? `content:{${makeContent(responses.content, readonly).join(",")}}` : void 0,
137
137
  responses.links ? `links:{${Object.entries(responses.links).map(([key, link]) => "$ref" in link && link.$ref ? `${JSON.stringify(key)}:${makeRef(link.$ref)}` : `${JSON.stringify(key)}:${makeLinkOrReference(link)}`).join(",")}}` : void 0
138
138
  ].filter((v) => v !== void 0).join(",")}}`;
139
139
  }
140
140
  /** Generates code for a header or header reference. */
141
- function makeHeadersAndReferences(headers) {
141
+ function makeHeadersAndReferences(headers, readonly) {
142
142
  if ("$ref" in headers && headers.$ref) return makeRef(headers.$ref);
143
143
  return `{${[
144
144
  headers.description ? `description:${JSON.stringify(headers.description)}` : void 0,
@@ -148,8 +148,8 @@ function makeHeadersAndReferences(headers) {
148
148
  "examples" in headers && headers.examples ? `examples:${makeExamples(headers.examples)}` : void 0,
149
149
  "style" in headers && headers.style ? `style:${JSON.stringify(headers.style)}` : void 0,
150
150
  "explode" in headers && headers.explode ? `explode:${JSON.stringify(headers.explode)}` : void 0,
151
- "schema" in headers && headers.schema ? `schema:${zodToOpenAPI(headers.schema, { headers })}` : void 0,
152
- "content" in headers && headers.content ? `content:${makeContent(headers.content).join(",")}` : void 0
151
+ "schema" in headers && headers.schema ? `schema:${zodToOpenAPI(headers.schema, { headers }, readonly)}` : void 0,
152
+ "content" in headers && headers.content ? `content:${makeContent(headers.content, readonly).join(",")}` : void 0
153
153
  ].filter((v) => v !== void 0).join(",")}}`;
154
154
  }
155
155
  /** Generates code for a link or link reference. */
@@ -173,7 +173,7 @@ function makeCallback(callback) {
173
173
  return `${JSON.stringify(callbackKey)}:${pathItemCode}`;
174
174
  }).filter((v) => v !== void 0).join(",");
175
175
  }
176
- function makeCallbacks(callbacks) {
176
+ function makeCallbacks(callbacks, readonly) {
177
177
  const methods = [
178
178
  "get",
179
179
  "put",
@@ -187,7 +187,7 @@ function makeCallbacks(callbacks) {
187
187
  const makeMethodsCode = (record) => methods.map((method) => {
188
188
  const operation = record[method];
189
189
  if (!isOperation(operation)) return void 0;
190
- return `${method}:${makeOperation(operation)}`;
190
+ return `${method}:${makeOperation(operation, readonly)}`;
191
191
  }).filter((v) => v !== void 0).join(",");
192
192
  return Object.entries(callbacks).map(([callbackKey, pathItem]) => {
193
193
  if (isRefObject(pathItem)) return `${JSON.stringify(callbackKey)}:${makeRef(pathItem.$ref)}`;
@@ -204,11 +204,11 @@ function makeCallbacks(callbacks) {
204
204
  }).filter((v) => v !== void 0).join(",");
205
205
  }
206
206
  /** Generates code for an OpenAPI content object. */
207
- function makeContent(content) {
207
+ function makeContent(content, readonly) {
208
208
  const isMedia = (v) => isRecord(v) && "schema" in v;
209
209
  return Object.entries(content).map(([contentType, mediaOrRef]) => {
210
210
  if (isRefObject(mediaOrRef)) return `'${contentType}':${makeRef(mediaOrRef.$ref)}`;
211
- if (isMedia(mediaOrRef)) return `'${contentType}':${makeMedia(mediaOrRef)}`;
211
+ if (isMedia(mediaOrRef)) return `'${contentType}':${makeMedia(mediaOrRef, readonly)}`;
212
212
  }).filter((v) => v !== void 0);
213
213
  }
214
214
  /**
@@ -234,11 +234,11 @@ function makeContent(content) {
234
234
  * // → '{content:{"application/json":{schema:...}},required:true}'
235
235
  * ```
236
236
  */
237
- function makeRequestBody(body) {
237
+ function makeRequestBody(body, readonly) {
238
238
  if ("$ref" in body && body.$ref) return makeRef(body.$ref);
239
239
  return `{${[
240
240
  body.description ? `description:${JSON.stringify(body.description)}` : void 0,
241
- "content" in body && body.content ? `content:{${makeContent(body.content).join(",")}}` : void 0,
241
+ "content" in body && body.content ? `content:{${makeContent(body.content, readonly).join(",")}}` : void 0,
242
242
  "required" in body && body.required ? `required:${JSON.stringify(body.required)}` : void 0
243
243
  ].filter((v) => v !== void 0).join(",")}}`;
244
244
  }
@@ -260,16 +260,16 @@ function makeRequestBody(body) {
260
260
  * // → '{schema:z.object({name:z.string()}),example:{"name":"John"}}'
261
261
  * ```
262
262
  */
263
- function makeMedia(media) {
264
- const encodingCode = media.encoding ? Object.entries(media.encoding).map(([name, encoding]) => `${JSON.stringify(name)}:{${makeEncoding(encoding)}}`).join(",") : void 0;
263
+ function makeMedia(media, readonly) {
264
+ const encodingCode = media.encoding ? Object.entries(media.encoding).map(([name, encoding]) => `${JSON.stringify(name)}:{${makeEncoding(encoding, readonly)}}`).join(",") : void 0;
265
265
  return `{${[
266
- media.schema ? `schema:${zodToOpenAPI(media.schema)}` : void 0,
267
- media.itemSchema ? `itemSchema:${zodToOpenAPI(media.itemSchema)}` : void 0,
266
+ media.schema ? `schema:${zodToOpenAPI(media.schema, void 0, readonly)}` : void 0,
267
+ media.itemSchema ? `itemSchema:${zodToOpenAPI(media.itemSchema, void 0, readonly)}` : void 0,
268
268
  media.example !== void 0 ? `example:${JSON.stringify(media.example)}` : void 0,
269
269
  media.examples ? `examples:${makeExamples(media.examples)}` : void 0,
270
270
  encodingCode ? `encoding:{${encodingCode}}` : void 0,
271
- media.prefixEncoding ? `prefixEncoding:{${makeEncoding(media.prefixEncoding)}}` : void 0,
272
- media.itemEncoding ? `itemEncoding:{${makeEncoding(media.itemEncoding)}}` : void 0
271
+ media.prefixEncoding ? `prefixEncoding:{${makeEncoding(media.prefixEncoding, readonly)}}` : void 0,
272
+ media.itemEncoding ? `itemEncoding:{${makeEncoding(media.itemEncoding, readonly)}}` : void 0
273
273
  ].filter((v) => v !== void 0).join(",")}}`;
274
274
  }
275
275
  /**
@@ -290,15 +290,15 @@ function makeMedia(media) {
290
290
  * // → 'contentType:"image/png",headers:{"X-Custom":{schema:z.string()}}'
291
291
  * ```
292
292
  */
293
- function makeEncoding(encoding) {
294
- const nestedEncoding = encoding.encoding ? Object.entries(encoding.encoding).map(([name, encoding]) => `${JSON.stringify(name)}:{${makeEncoding(encoding)}}`).join(",") : void 0;
295
- const headersCode = encoding.headers ? Object.entries(encoding.headers).map(([name, header]) => `${JSON.stringify(name)}:${makeHeadersAndReferences(header)}`).join(",") : void 0;
293
+ function makeEncoding(encoding, readonly) {
294
+ const nestedEncoding = encoding.encoding ? Object.entries(encoding.encoding).map(([name, encoding]) => `${JSON.stringify(name)}:{${makeEncoding(encoding, readonly)}}`).join(",") : void 0;
295
+ const headersCode = encoding.headers ? Object.entries(encoding.headers).map(([name, header]) => `${JSON.stringify(name)}:${makeHeadersAndReferences(header, readonly)}`).join(",") : void 0;
296
296
  return [
297
297
  encoding.contentType ? `contentType:${JSON.stringify(encoding.contentType)}` : void 0,
298
298
  headersCode ? `headers:{${headersCode}}` : void 0,
299
299
  nestedEncoding ? `encoding:{${nestedEncoding}}` : void 0,
300
- encoding.prefixEncoding ? `prefixEncoding:{${makeEncoding(encoding.prefixEncoding)}}` : void 0,
301
- encoding.itemEncoding ? `itemEncoding:{${makeEncoding(encoding.itemEncoding)}}` : void 0
300
+ encoding.prefixEncoding ? `prefixEncoding:{${makeEncoding(encoding.prefixEncoding, readonly)}}` : void 0,
301
+ encoding.itemEncoding ? `itemEncoding:{${makeEncoding(encoding.itemEncoding, readonly)}}` : void 0
302
302
  ].filter((v) => v !== void 0).join(",");
303
303
  }
304
304
  /**
@@ -307,8 +307,8 @@ function makeEncoding(encoding) {
307
307
  * @param requestBody OpenAPI request body (can be Reference or inline RequestBody)
308
308
  * @returns Request string like `request:{query:...,body:...},` or empty string
309
309
  */
310
- function makeRequest(parameters, requestBody) {
311
- const result = [parameters && parameters.length > 0 ? makeRequestParams(parameters) : void 0, requestBody && "$ref" in requestBody && requestBody.$ref || requestBody && "content" in requestBody && requestBody.content ? `body:${makeRequestBody(requestBody)}` : void 0].filter((v) => v !== void 0).join(",");
310
+ function makeRequest(parameters, requestBody, readonly) {
311
+ const result = [parameters && parameters.length > 0 ? makeRequestParams(parameters, readonly) : void 0, requestBody && "$ref" in requestBody && requestBody.$ref || requestBody && "content" in requestBody && requestBody.content ? `body:${makeRequestBody(requestBody, readonly)}` : void 0].filter((v) => v !== void 0).join(",");
312
312
  return result.length > 0 ? `{${result}}` : void 0;
313
313
  }
314
314
  /**
@@ -331,7 +331,7 @@ function getSchemaFromContent$1(content) {
331
331
  * - Supports parameters with content instead of schema (OpenAPI 3.x).
332
332
  * - Applies coercion for query parameters with number/boolean/date types.
333
333
  */
334
- function makeParameters(parameters) {
334
+ function makeParameters(parameters, readonly) {
335
335
  return parameters.reduce((acc, param) => {
336
336
  if (!acc[param.in]) acc[param.in] = {};
337
337
  if (param.$ref) {
@@ -343,7 +343,7 @@ function makeParameters(parameters) {
343
343
  acc[param.in][makeSafeKey(param.name)] = "z.any()";
344
344
  return acc;
345
345
  }
346
- const baseSchema = zodToOpenAPI(schema, { parameters: param });
346
+ const baseSchema = zodToOpenAPI(schema, { parameters: param }, readonly);
347
347
  const z = param.in === "query" && (schema.type === "number" || schema.type === "integer") ? applyNumberCoerce(baseSchema, schema.type, schema.format) : param.in === "query" && schema.type === "boolean" ? baseSchema.replace("boolean", "stringbool").replace(/\.default\("true"\)/g, ".default(true)").replace(/\.default\("false"\)/g, ".default(false)") : param.in === "query" && schema.type === "date" ? `z.coerce.${baseSchema.replace("z.", "")}` : param.in === "query" && (schema.type === "object" || schema.type === "array") ? baseSchema.replace(/z\.(int\d*)\(\)((?:\.(?:min|max|gt|lt|positive|negative|nonnegative|nonpositive|multipleOf)\([^)]*\))*)/g, (_, type, constraints) => `z.coerce.number().pipe(z.${type}()${constraints})`).replace(/z\.bigint\(\)/g, "z.coerce.bigint()").replace(/z\.number\(\)/g, "z.coerce.number()").replace(/z\.boolean\(\)/g, "z.stringbool()").replace(/z\.date\(\)/g, "z.coerce.date()") : baseSchema;
348
348
  acc[param.in][makeSafeKey(param.name)] = z;
349
349
  return acc;
@@ -355,8 +355,8 @@ function makeParameters(parameters) {
355
355
  * @param parameters - Array of OpenAPI parameter objects.
356
356
  * @returns Comma-separated parameter code string or undefined if empty.
357
357
  */
358
- function makeRequestParams(parameters) {
359
- const paramsArray = requestParamsArray(makeParameters(parameters));
358
+ function makeRequestParams(parameters, readonly) {
359
+ const paramsArray = requestParamsArray(makeParameters(parameters, readonly));
360
360
  return paramsArray.length > 0 ? paramsArray.join(",") : void 0;
361
361
  }
362
362
  /**
@@ -388,24 +388,24 @@ function makePathParameters(parameters) {
388
388
  return serializeValue(param);
389
389
  }).join(",")}]`;
390
390
  }
391
- function makeOperationParameters(parameters) {
391
+ function makeOperationParameters(parameters, readonly) {
392
392
  return `[${parameters.map((param) => {
393
393
  if (isRefObject(param)) return makeRef(param.$ref);
394
- if (isParameter(param) && param.schema) return zodToOpenAPI(param.schema, { parameters: param });
394
+ if (isParameter(param) && param.schema) return zodToOpenAPI(param.schema, { parameters: param }, readonly);
395
395
  return JSON.stringify(param);
396
396
  }).join(",")}]`;
397
397
  }
398
- function makeOperation(operation) {
398
+ function makeOperation(operation, readonly) {
399
399
  return `{${[
400
400
  operation.tags ? `tags:${JSON.stringify(operation.tags)}` : void 0,
401
401
  operation.summary ? `summary:${JSON.stringify(operation.summary)}` : void 0,
402
402
  operation.description ? `description:${JSON.stringify(operation.description)}` : void 0,
403
403
  operation.externalDocs ? `externalDocs:${JSON.stringify(operation.externalDocs)}` : void 0,
404
404
  operation.operationId ? `operationId:${JSON.stringify(operation.operationId)}` : void 0,
405
- operation.parameters ? `parameters:${makeOperationParameters(operation.parameters)}` : void 0,
406
- operation.requestBody ? `requestBody:${makeRequestBody(operation.requestBody)}` : void 0,
407
- operation.responses ? `responses:${makeOperationResponses(operation.responses)}` : void 0,
408
- operation.callbacks ? `callbacks:{${makeCallbacks(operation.callbacks)}}` : void 0,
405
+ operation.parameters ? `parameters:${makeOperationParameters(operation.parameters, readonly)}` : void 0,
406
+ operation.requestBody ? `requestBody:${makeRequestBody(operation.requestBody, readonly)}` : void 0,
407
+ operation.responses ? `responses:${makeOperationResponses(operation.responses, readonly)}` : void 0,
408
+ operation.callbacks ? `callbacks:{${makeCallbacks(operation.callbacks, readonly)}}` : void 0,
409
409
  operation.deprecated ? `deprecated:${JSON.stringify(operation.deprecated)}` : void 0,
410
410
  operation.security ? `security:${JSON.stringify(operation.security)}` : void 0,
411
411
  operation.servers ? `servers:${JSON.stringify(operation.servers)}` : void 0
@@ -494,7 +494,8 @@ function wrap(zod, schema, meta) {
494
494
  return JSON.stringify(v);
495
495
  };
496
496
  const n = schema.nullable === true || (Array.isArray(schema.type) ? schema.type.includes("null") : schema.type === "null") ? `${zod}.nullable()` : zod;
497
- const z = schema.default !== void 0 ? `${n}.default(${formatLiteral(schema.default)})` : n;
497
+ const d = schema.default !== void 0 ? `${n}.default(${formatLiteral(schema.default)})` : n;
498
+ const z = schema["x-brand"] ? `${d}.brand<"${schema["x-brand"]}">()` : d;
498
499
  const zodExpressedProps = new Set([
499
500
  "type",
500
501
  "format",
@@ -538,7 +539,8 @@ function wrap(zod, schema, meta) {
538
539
  "x-anyOf-message",
539
540
  "x-oneOf-message",
540
541
  "x-not-message",
541
- "x-enum-error-messages"
542
+ "x-enum-error-messages",
543
+ "x-brand"
542
544
  ]);
543
545
  const args = filterUnsupportedProps(Object.fromEntries(Object.entries(schema).filter(([k, v]) => !(zodExpressedProps.has(k) || k === "required" && typeof v === "boolean"))));
544
546
  const headerMetaProps = meta?.headers ? [
@@ -921,7 +923,7 @@ function string(schema) {
921
923
  const errorMessage = schema["x-error-message"];
922
924
  const base = (() => {
923
925
  if (!format) return errorMessage ? `z.string(${error(errorMessage)})` : "z.string()";
924
- if (errorMessage && !TRANSFORM_FORMATS.has(schema.format)) return `z.${format.replace(/\(\)$/, `(${error(errorMessage)})`)}`;
926
+ if (errorMessage && schema.format && !TRANSFORM_FORMATS.has(schema.format)) return `z.${format.replace(/\(\)$/, `(${error(errorMessage)})`)}`;
925
927
  return `z.${format}`;
926
928
  })();
927
929
  const patternMessage = schema["x-pattern-message"];
@@ -1806,7 +1808,11 @@ function makeTypeString(schema, selfTypeName, cyclicGroup, readonly) {
1806
1808
  if (schema.anyOf && schema.anyOf.length > 0) return makeUnionTypeString(schema.anyOf, selfTypeName, cyclicGroup, "|", readonly);
1807
1809
  if (schema.allOf && schema.allOf.length > 0) return makeUnionTypeString(schema.allOf, selfTypeName, cyclicGroup, "&", readonly);
1808
1810
  if (schema.enum && schema.enum.length > 0) return schema.enum.map((v) => typeof v === "string" ? `'${v}'` : String(v)).join("|");
1809
- if (schema.const !== void 0) return typeof schema.const === "string" ? `'${schema.const}'` : typeof schema.const === "object" ? JSON.stringify(schema.const) : String(schema.const);
1811
+ if (schema.const !== void 0) {
1812
+ if (typeof schema.const === "string") return `'${schema.const}'`;
1813
+ if (typeof schema.const === "number" || typeof schema.const === "boolean") return String(schema.const);
1814
+ return JSON.stringify(schema.const);
1815
+ }
1810
1816
  const types = normalizeType(schema);
1811
1817
  const isNullable = schema.nullable === true || types.includes("null");
1812
1818
  const baseType = makeBaseTypeString(schema, types.filter((t) => t !== "null"), selfTypeName, cyclicGroup, readonly);
@@ -2312,9 +2318,9 @@ function createRoute(path, method, operation, readonly) {
2312
2318
  operation.description ? `description:${JSON.stringify(operation.description)}` : void 0,
2313
2319
  operation.externalDocs ? `externalDocs:${JSON.stringify(operation.externalDocs)}` : void 0,
2314
2320
  operation.operationId ? `operationId:'${operation.operationId}'` : void 0,
2315
- makeRequest(operation.parameters, operation.requestBody) ? `request:${makeRequest(operation.parameters, operation.requestBody)}` : void 0,
2316
- operation.responses ? `responses:${makeOperationResponses(operation.responses)}` : void 0,
2317
- operation.callbacks ? `callbacks:{${makeCallbacks(operation.callbacks)}}` : void 0,
2321
+ makeRequest(operation.parameters, operation.requestBody, readonly) ? `request:${makeRequest(operation.parameters, operation.requestBody, readonly)}` : void 0,
2322
+ operation.responses ? `responses:${makeOperationResponses(operation.responses, readonly)}` : void 0,
2323
+ operation.callbacks ? `callbacks:{${makeCallbacks(operation.callbacks, readonly)}}` : void 0,
2318
2324
  operation.deprecated ? `deprecated:${JSON.stringify(operation.deprecated)}` : void 0,
2319
2325
  operation.security ? `security:${JSON.stringify(operation.security)}` : void 0,
2320
2326
  operation.servers ? `servers:${JSON.stringify(operation.servers)}` : void 0
@@ -2438,9 +2444,9 @@ function createWebhook(name, method, operation, readonly) {
2438
2444
  operation.description ? `description:${JSON.stringify(operation.description)}` : void 0,
2439
2445
  operation.externalDocs ? `externalDocs:${JSON.stringify(operation.externalDocs)}` : void 0,
2440
2446
  operation.operationId ? `operationId:'${operation.operationId}'` : void 0,
2441
- makeRequest(operation.parameters, operation.requestBody) ? `request:${makeRequest(operation.parameters, operation.requestBody)}` : void 0,
2442
- operation.responses ? `responses:${makeOperationResponses(operation.responses)}` : void 0,
2443
- operation.callbacks ? makeCallbacks(operation.callbacks) : void 0,
2447
+ makeRequest(operation.parameters, operation.requestBody, readonly) ? `request:${makeRequest(operation.parameters, operation.requestBody, readonly)}` : void 0,
2448
+ operation.responses ? `responses:${makeOperationResponses(operation.responses, readonly)}` : void 0,
2449
+ operation.callbacks ? makeCallbacks(operation.callbacks, readonly) : void 0,
2444
2450
  operation.deprecated ? `deprecated:${JSON.stringify(operation.deprecated)}` : void 0,
2445
2451
  operation.security ? `security:${JSON.stringify(operation.security)}` : void 0,
2446
2452
  operation.servers ? `servers:${JSON.stringify(operation.servers)}` : void 0
@@ -1,7 +1,7 @@
1
1
  import { parseConfig } from "../config/index.js";
2
2
  import { f as isRecord } from "../guard-BabA4f3q.js";
3
3
  import { r as setFormatOptions } from "../core-BlUaJE2n.js";
4
- import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "../openapi-BNsdBSpS.js";
4
+ import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "../openapi-BBy6frF3.js";
5
5
  import { t as docs } from "../docs-Da_MOdAe.js";
6
6
  import { rpc } from "../core/rpc/index.js";
7
7
  import { svelteQuery } from "../core/svelte-query/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.9.992",
3
+ "version": "0.9.994",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",
@@ -72,18 +72,18 @@
72
72
  "@apidevtools/swagger-parser": "^12.1.0",
73
73
  "@typespec/compiler": "^1.10.0",
74
74
  "@typespec/openapi3": "^1.10.0",
75
- "oxfmt": "^0.39.0",
75
+ "oxfmt": "^0.42.0",
76
76
  "ts-morph": "^27.0.2",
77
77
  "tsx": "^4.21.0",
78
- "typescript": "^5.9.3",
78
+ "typescript": "^6.0.2",
79
79
  "zod": "^4.3.6"
80
80
  },
81
81
  "devDependencies": {
82
- "@types/node": "^25.4.0",
82
+ "@types/node": "^25.5.0",
83
83
  "@typespec/http": "^1.10.0",
84
84
  "@typespec/rest": "^0.80.0",
85
85
  "@typespec/versioning": "^0.80.0",
86
- "tsdown": "0.21.2"
86
+ "tsdown": "0.21.5"
87
87
  },
88
88
  "scripts": {
89
89
  "dev": "vite --host",