hono-takibi 0.8.0-beta → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +113 -404
  2. package/dist/cli/hono-takibi/index.js +8 -14
  3. package/dist/cli/hono-takibi/takibi.d.ts +12 -1
  4. package/dist/cli/hono-takibi/takibi.js +11 -0
  5. package/dist/cli/hono-takibi/template-code.d.ts +9 -0
  6. package/dist/cli/hono-takibi/template-code.js +9 -0
  7. package/dist/cli/parse/parse-cli.d.ts +21 -0
  8. package/dist/cli/{args → parse}/parse-cli.js +9 -3
  9. package/dist/cli/parse/parse-io.d.ts +10 -0
  10. package/dist/cli/{args → parse}/parse-io.js +3 -2
  11. package/dist/cli/utils/index.d.ts +26 -4
  12. package/dist/cli/utils/index.js +37 -4
  13. package/dist/core/utils/exclusive.d.ts +2 -0
  14. package/dist/core/utils/exclusive.js +6 -0
  15. package/dist/core/utils/index.d.ts +3 -0
  16. package/dist/core/utils/index.js +3 -0
  17. package/dist/core/utils/maybe-apply-nullability.d.ts +2 -0
  18. package/dist/core/utils/maybe-apply-nullability.js +4 -0
  19. package/dist/core/utils/pick-types.d.ts +2 -0
  20. package/dist/core/utils/pick-types.js +4 -0
  21. package/dist/core/validator/is-http-method.d.ts +1 -2
  22. package/dist/fsp/index.d.ts +17 -3
  23. package/dist/fsp/index.js +42 -3
  24. package/dist/generator/zod/index.d.ts +4 -3
  25. package/dist/generator/zod/index.js +87 -103
  26. package/dist/generator/zod/z/array.d.ts +1 -1
  27. package/dist/generator/zod/z/array.js +1 -1
  28. package/dist/generator/zod/z/coerce.d.ts +1 -1
  29. package/dist/generator/zod/z/coerce.js +1 -1
  30. package/dist/generator/zod/z/default.d.ts +1 -1
  31. package/dist/generator/zod/z/default.js +1 -1
  32. package/dist/generator/zod/z/enum.d.ts +2 -1
  33. package/dist/generator/zod/z/enum.js +12 -8
  34. package/dist/generator/zod/z/gt.d.ts +1 -1
  35. package/dist/generator/zod/z/gt.js +1 -1
  36. package/dist/generator/zod/z/index.d.ts +0 -1
  37. package/dist/generator/zod/z/index.js +0 -1
  38. package/dist/generator/zod/z/infer.d.ts +1 -1
  39. package/dist/generator/zod/z/infer.js +1 -1
  40. package/dist/generator/zod/z/integer.d.ts +1 -1
  41. package/dist/generator/zod/z/integer.js +22 -8
  42. package/dist/generator/zod/z/intersection.d.ts +1 -1
  43. package/dist/generator/zod/z/intersection.js +1 -1
  44. package/dist/generator/zod/z/length.d.ts +1 -4
  45. package/dist/generator/zod/z/length.js +1 -4
  46. package/dist/generator/zod/z/lt.d.ts +1 -1
  47. package/dist/generator/zod/z/lt.js +1 -1
  48. package/dist/generator/zod/z/max.d.ts +1 -1
  49. package/dist/generator/zod/z/max.js +1 -1
  50. package/dist/generator/zod/z/min.d.ts +1 -1
  51. package/dist/generator/zod/z/min.js +1 -1
  52. package/dist/generator/zod/z/number.d.ts +1 -1
  53. package/dist/generator/zod/z/number.js +8 -2
  54. package/dist/generator/zod/z/object.d.ts +1 -1
  55. package/dist/generator/zod/z/object.js +1 -1
  56. package/dist/generator/zod/z/partial.d.ts +1 -1
  57. package/dist/generator/zod/z/partial.js +1 -1
  58. package/dist/generator/zod/z/record.d.ts +1 -1
  59. package/dist/generator/zod/z/record.js +1 -1
  60. package/dist/generator/zod/z/regex.d.ts +1 -1
  61. package/dist/generator/zod/z/regex.js +1 -1
  62. package/dist/generator/zod/z/schema.d.ts +1 -1
  63. package/dist/generator/zod/z/schema.js +1 -1
  64. package/dist/generator/zod/z/string.d.ts +1 -26
  65. package/dist/generator/zod/z/string.js +4 -32
  66. package/dist/generator/zod/z/stringbool.d.ts +6 -0
  67. package/dist/generator/zod/z/stringbool.js +6 -0
  68. package/dist/generator/zod/z/union.d.ts +1 -3
  69. package/dist/generator/zod/z/union.js +1 -3
  70. package/dist/generator/zod-openapi-hono/app/index.js +1 -1
  71. package/dist/generator/zod-openapi-hono/handler/zod-openapi-hono-handler.d.ts +1 -1
  72. package/dist/generator/zod-openapi-hono/openapi/route/params/query-parameter.d.ts +7 -0
  73. package/dist/generator/zod-openapi-hono/openapi/route/params/query-parameter.js +11 -1
  74. package/dist/generator/zod-openapi-hono/openapi/route/request/body/request-body.js +8 -1
  75. package/dist/generator/zod-openapi-hono/openapi/route/route-name.js +1 -1
  76. package/dist/generator/zod-to-openapi/zod-to-openapi-schema.d.ts +3 -1
  77. package/dist/generator/zod-to-openapi/zod-to-openapi-schema.js +3 -1
  78. package/dist/generator/zod-to-openapi/zod-to-openapi.d.ts +5 -6
  79. package/dist/generator/zod-to-openapi/zod-to-openapi.js +5 -6
  80. package/dist/openapi/index.d.ts +0 -1
  81. package/dist/openapi/parse-openapi.d.ts +3 -3
  82. package/dist/openapi/parse-openapi.js +3 -3
  83. package/dist/openapi/types.d.ts +12 -11
  84. package/dist/result/index.d.ts +31 -5
  85. package/dist/result/index.js +35 -4
  86. package/dist/typespec/index.d.ts +5 -0
  87. package/dist/typespec/index.js +5 -0
  88. package/dist/vite-plugin/index.d.ts +6 -1
  89. package/dist/vite-plugin/index.js +1 -1
  90. package/package.json +1 -1
  91. package/dist/cli/args/parse-cli.d.ts +0 -8
  92. package/dist/cli/args/parse-io.d.ts +0 -9
  93. package/dist/cli/types.d.ts +0 -9
  94. package/dist/cli/types.js +0 -1
  95. package/dist/cli/utils/get-flag-value.d.ts +0 -5
  96. package/dist/cli/utils/get-flag-value.js +0 -10
  97. package/dist/cli/utils/has-flag.d.ts +0 -5
  98. package/dist/cli/utils/has-flag.js +0 -7
  99. package/dist/cli/utils/is-help-requested.d.ts +0 -4
  100. package/dist/cli/utils/is-help-requested.js +0 -6
  101. package/dist/cli/utils/slice-argv.d.ts +0 -4
  102. package/dist/cli/utils/slice-argv.js +0 -6
  103. package/dist/fsp/mkdir.d.ts +0 -2
  104. package/dist/fsp/mkdir.js +0 -11
  105. package/dist/fsp/readdir.d.ts +0 -6
  106. package/dist/fsp/readdir.js +0 -15
  107. package/dist/fsp/write-file.d.ts +0 -7
  108. package/dist/fsp/write-file.js +0 -16
  109. package/dist/generator/zod/z/nullable.d.ts +0 -7
  110. package/dist/generator/zod/z/nullable.js +0 -9
  111. package/dist/result/and-then.d.ts +0 -2
  112. package/dist/result/and-then.js +0 -3
  113. package/dist/result/async-and-then.d.ts +0 -2
  114. package/dist/result/async-and-then.js +0 -6
  115. package/dist/result/err.d.ts +0 -7
  116. package/dist/result/err.js +0 -8
  117. package/dist/result/ok.d.ts +0 -7
  118. package/dist/result/ok.js +0 -8
  119. package/dist/result/types.d.ts +0 -9
  120. package/dist/result/types.js +0 -1
  121. /package/dist/cli/{args → parse}/index.d.ts +0 -0
  122. /package/dist/cli/{args → parse}/index.js +0 -0
package/README.md CHANGED
@@ -30,69 +30,49 @@ If you have OpenAPI specifications, Hono Takibi automates the conversion process
30
30
  ## Usage
31
31
 
32
32
  ```bash
33
- npx hono-takibi path/to/openapi.yaml -o path/to/output_hono.ts
33
+ npx hono-takibi path/to/input.{yaml,json,tsp} -o path/to/output.ts
34
34
  ```
35
35
 
36
- ## Demo
36
+ ## CLI
37
37
 
38
- ![](https://raw.githubusercontent.com/nakita628/hono-takibi/refs/heads/main/assets/demo/hono-takibi.gif)
38
+ ### Options
39
+
40
+ basic
41
+
42
+ ```bash
43
+ Options:
44
+ --export-type export TypeScript type aliases
45
+ --export-schema export Zod schema objects
46
+ --template generate app file and handler stubs
47
+ --test generate empty *.test.ts files
48
+ --base-path <path> api prefix (default: /)
49
+ ```
50
+
51
+ template
52
+
53
+ > **⚠️** When using the `--template` option, you must specify a valid directory path. Ensure the directory exists before executing the
54
+
55
+ ### Example
56
+
57
+ ```bash
58
+ npx hono-takibi path/to/input.{yaml,json,tsp} -o path/to/output.ts --export-type --export-schema --template --base-path '/api/v1'
59
+ ```
39
60
 
40
61
  input:
41
62
 
42
63
  ```yaml
43
64
  openapi: 3.1.0
44
65
  info:
45
- title: Hono API
46
- version: v1
47
- tags:
48
- - name: Hono
49
- description: Endpoints related to general Hono operations
50
- - name: Post
51
- description: Endpoints for creating, retrieving, updating, and deleting posts
52
- components:
53
- schemas:
54
- Error:
55
- type: object
56
- properties:
57
- message:
58
- type: string
59
- required:
60
- - message
61
- Post:
62
- type: object
63
- properties:
64
- id:
65
- type: string
66
- format: uuid
67
- description: Unique identifier of the post
68
- post:
69
- type: string
70
- minLength: 1
71
- maxLength: 140
72
- description: Content of the post
73
- createdAt:
74
- type: string
75
- format: date-time
76
- description: Timestamp when the post was created
77
- updatedAt:
78
- type: string
79
- format: date-time
80
- description: Timestamp when the post was last updated
81
- required:
82
- - id
83
- - post
84
- - createdAt
85
- - updatedAt
66
+ title: Hono Takibi API
67
+ version: "1.0.0"
86
68
  paths:
87
69
  /:
88
70
  get:
89
- tags:
90
- - Hono
91
- summary: Welcome message
92
- description: Retrieve a simple welcome message from the Hono API.
71
+ summary: Welcome
72
+ description: Returns a welcome message from Hono Takibi.
93
73
  responses:
94
- '200':
95
- description: Successful response with a welcome message.
74
+ "200":
75
+ description: OK
96
76
  content:
97
77
  application/json:
98
78
  schema:
@@ -100,163 +80,9 @@ paths:
100
80
  properties:
101
81
  message:
102
82
  type: string
103
- example: Hono🔥
83
+ example: Hono Takibi🔥
104
84
  required:
105
85
  - message
106
- /posts:
107
- post:
108
- tags:
109
- - Post
110
- summary: Create a new post
111
- description: Submit a new post with a maximum length of 140 characters.
112
- requestBody:
113
- required: true
114
- content:
115
- application/json:
116
- schema:
117
- type: object
118
- properties:
119
- post:
120
- type: string
121
- minLength: 1
122
- maxLength: 140
123
- description: Content of the post
124
- required:
125
- - post
126
- responses:
127
- '201':
128
- description: Post successfully created.
129
- content:
130
- application/json:
131
- schema:
132
- type: object
133
- properties:
134
- message:
135
- type: string
136
- example: Post created successfully.
137
- required:
138
- - message
139
- '400':
140
- description: Invalid request due to bad input.
141
- content:
142
- application/json:
143
- schema:
144
- $ref: '#/components/schemas/Error'
145
- '500':
146
- description: Internal server error.
147
- content:
148
- application/json:
149
- schema:
150
- $ref: '#/components/schemas/Error'
151
- get:
152
- tags:
153
- - Post
154
- summary: Retrieve a list of posts
155
- description: Retrieve a paginated list of posts. Specify the page number and the number of posts per page.
156
- parameters:
157
- - name: page
158
- in: query
159
- required: true
160
- schema:
161
- type: integer
162
- - name: rows
163
- in: query
164
- required: true
165
- schema:
166
- type: integer
167
- responses:
168
- '200':
169
- description: Successfully retrieved a list of posts.
170
- content:
171
- application/json:
172
- schema:
173
- type: array
174
- items:
175
- $ref: '#/components/schemas/Post'
176
- '400':
177
- description: Invalid request due to bad input.
178
- content:
179
- application/json:
180
- schema:
181
- $ref: '#/components/schemas/Error'
182
- '500':
183
- description: Internal server error.
184
- content:
185
- application/json:
186
- schema:
187
- $ref: '#/components/schemas/Error'
188
- /posts/{id}:
189
- put:
190
- tags:
191
- - Post
192
- summary: Update an existing post
193
- description: Update the content of an existing post identified by its unique ID.
194
- parameters:
195
- - name: id
196
- in: path
197
- required: true
198
- schema:
199
- type: string
200
- format: uuid
201
- description: Unique identifier of the post.
202
- requestBody:
203
- required: true
204
- content:
205
- application/json:
206
- schema:
207
- type: object
208
- properties:
209
- post:
210
- type: string
211
- minLength: 1
212
- maxLength: 140
213
- description: Updated content for the post
214
- required:
215
- - post
216
- responses:
217
- '204':
218
- description: Post successfully updated.
219
- '400':
220
- description: Invalid input.
221
- content:
222
- application/json:
223
- schema:
224
- $ref: '#/components/schemas/Error'
225
- '500':
226
- description: Internal server error.
227
- content:
228
- application/json:
229
- schema:
230
- $ref: '#/components/schemas/Error'
231
- delete:
232
- tags:
233
- - Post
234
- summary: Delete a post
235
- description: Delete an existing post identified by its unique ID.
236
- parameters:
237
- - name: id
238
- in: path
239
- required: true
240
- schema:
241
- type: string
242
- format: uuid
243
- description: Unique identifier of the post.
244
- example: 123e4567-e89b-12d3-a456-426614174000
245
- responses:
246
- '204':
247
- description: Post successfully deleted.
248
- '400':
249
- description: Invalid input.
250
- content:
251
- application/json:
252
- schema:
253
- $ref: '#/components/schemas/Error'
254
- '500':
255
- description: Internal server error.
256
- content:
257
- application/json:
258
- schema:
259
- $ref: '#/components/schemas/Error'
260
86
  ```
261
87
 
262
88
  output:
@@ -264,213 +90,117 @@ output:
264
90
  ```ts
265
91
  import { createRoute, z } from '@hono/zod-openapi'
266
92
 
267
- const ErrorSchema = z.object({ message: z.string() }).openapi('Error')
268
-
269
- const PostSchema = z
270
- .object({
271
- id: z.uuid().openapi({ description: 'Unique identifier of the post' }),
272
- post: z.string().min(1).max(140).openapi({ description: 'Content of the post' }),
273
- createdAt: z.iso.date().openapi({ description: 'Timestamp when the post was created' }),
274
- updatedAt: z.date().openapi({ description: 'Timestamp when the post was last updated' }),
275
- })
276
- .openapi('Post')
277
-
278
93
  export const getRoute = createRoute({
279
- tags: ['Hono'],
280
94
  method: 'get',
281
95
  path: '/',
282
- summary: 'Welcome message',
283
- description: 'Retrieve a simple welcome message from the Hono API.',
96
+ summary: 'Welcome',
97
+ description: 'Returns a welcome message from Hono Takibi.',
284
98
  responses: {
285
99
  200: {
286
- description: 'Successful response with a welcome message.',
100
+ description: 'OK',
287
101
  content: {
288
102
  'application/json': {
289
- schema: z.object({ message: z.string().openapi({ example: 'Hono🔥' }) }),
103
+ schema: z.object({ message: z.string().openapi({ example: 'Hono Takibi🔥' }) }),
290
104
  },
291
105
  },
292
106
  },
293
107
  },
294
108
  })
109
+ ```
295
110
 
296
- export const postPostsRoute = createRoute({
297
- tags: ['Post'],
298
- method: 'post',
299
- path: '/posts',
300
- summary: 'Create a new post',
301
- description: 'Submit a new post with a maximum length of 140 characters.',
302
- request: {
303
- body: {
304
- required: true,
305
- content: {
306
- 'application/json': {
307
- schema: z.object({
308
- post: z.string().min(1).max(140).openapi({ description: 'Content of the post' }),
309
- }),
310
- },
311
- },
312
- },
313
- },
314
- responses: {
315
- 201: {
316
- description: 'Post successfully created.',
317
- content: {
318
- 'application/json': {
319
- schema: z.object({
320
- message: z.string().openapi({ example: 'Post created successfully.' }),
321
- }),
322
- },
323
- },
324
- },
325
- 400: {
326
- description: 'Invalid request due to bad input.',
327
- content: { 'application/json': { schema: ErrorSchema } },
328
- },
329
- 500: {
330
- description: 'Internal server error.',
331
- content: { 'application/json': { schema: ErrorSchema } },
332
- },
333
- },
334
- })
111
+ ### Demo
335
112
 
336
- export const getPostsRoute = createRoute({
337
- tags: ['Post'],
338
- method: 'get',
339
- path: '/posts',
340
- summary: 'Retrieve a list of posts',
341
- description:
342
- 'Retrieve a paginated list of posts. Specify the page number and the number of posts per page.',
343
- request: {
344
- query: z.object({
345
- page: z.coerce
346
- .number()
347
- .int()
348
- .min(0)
349
- .openapi({ param: { in: 'query', name: 'page', required: false } }),
350
-
351
- rows: z.coerce
352
- .number()
353
- .int()
354
- .min(0)
355
- .openapi({ param: { in: 'query', name: 'rows', required: false } }),
356
- }),
357
- },
358
- responses: {
359
- 200: {
360
- description: 'Successfully retrieved a list of posts.',
361
- content: { 'application/json': { schema: z.array(PostSchema) } },
362
- },
363
- 400: {
364
- description: 'Invalid request due to bad input.',
365
- content: { 'application/json': { schema: ErrorSchema } },
366
- },
367
- 500: {
368
- description: 'Internal server error.',
369
- content: { 'application/json': { schema: ErrorSchema } },
370
- },
371
- },
372
- })
113
+ ![](https://raw.githubusercontent.com/nakita628/hono-takibi/refs/heads/main/assets/demo/hono-takibi.gif)
373
114
 
374
- export const putPostsIdRoute = createRoute({
375
- tags: ['Post'],
376
- method: 'put',
377
- path: '/posts/{id}',
378
- summary: 'Update an existing post',
379
- description: 'Update the content of an existing post identified by its unique ID.',
380
- request: {
381
- body: {
382
- required: true,
383
- content: {
384
- 'application/json': {
385
- schema: z.object({
386
- post: z
387
- .string()
388
- .min(1)
389
- .max(140)
390
- .openapi({ description: 'Updated content for the post' }),
391
- }),
392
- },
393
- },
394
- },
395
- params: z.object({
396
- id: z.uuid().openapi({
397
- param: { in: 'path', name: 'id', required: true },
398
- description: 'Unique identifier of the post.',
399
- }),
400
- }),
401
- },
402
- responses: {
403
- 204: { description: 'Post successfully updated.' },
404
- 400: {
405
- description: 'Invalid input.',
406
- content: { 'application/json': { schema: ErrorSchema } },
407
- },
408
- 500: {
409
- description: 'Internal server error.',
410
- content: { 'application/json': { schema: ErrorSchema } },
411
- },
412
- },
413
- })
115
+ ## HonoTakibiVite
116
+
117
+ ### Automatic Code Regeneration & HMR
118
+
119
+ With **HonoTakibiVite**, saving your OpenAPI spec while the Vite dev server is running instantly regenerates the code.
120
+
121
+ ### OpenAPI Schema Requirements
122
+
123
+ - Your OpenAPI definition must include **only the `#/components/schemas/` section**.
124
+ - It must be fully compliant with **OpenAPI 3.0 or later (e.g., 3.0 or 3.1)**.
125
+ - Do **not** include `paths`, `tags`, or any other OpenAPI sections.
126
+
127
+ ### Supported Input Formats
128
+
129
+ You may specify the input file in one of the following formats:
130
+
131
+ - `.yaml` OpenAPI YAML (schemas only)
132
+ - `.json` — OpenAPI JSON (schemas only)
133
+ - `.tsp` — TypeSpec source file
414
134
 
415
- export const deletePostsIdRoute = createRoute({
416
- tags: ['Post'],
417
- method: 'delete',
418
- path: '/posts/{id}',
419
- summary: 'Delete a post',
420
- description: 'Delete an existing post identified by its unique ID.',
421
- request: {
422
- params: z.object({
423
- id: z.uuid().openapi({
424
- param: { in: 'path', name: 'id', required: true },
425
- example: '123e4567-e89b-12d3-a456-426614174000',
426
- description: 'Unique identifier of the post.',
427
- }),
135
+ ### TypeSpec Setup (if using `.tsp`)
136
+
137
+ If you use a `.tsp` TypeSpec file, you must set up the TypeSpec environment and install required libraries:
138
+
139
+ - @typespec/http
140
+ - @typespec/rest
141
+ - ...other
142
+
143
+ ### Example
144
+
145
+ `vite.config.ts`
146
+
147
+ ```ts
148
+ import { defineConfig } from 'vite'
149
+ import HonoTakibiVite from './src/vite-plugin'
150
+
151
+ export default defineConfig({
152
+ plugins: [
153
+ HonoTakibiVite({
154
+ input: 'main.tsp',
155
+ output: 'index.ts',
156
+ exportType: true,
157
+ exportSchema: true,
428
158
  }),
429
- },
430
- responses: {
431
- 204: { description: 'Post successfully deleted.' },
432
- 400: {
433
- description: 'Invalid input.',
434
- content: { 'application/json': { schema: ErrorSchema } },
435
- },
436
- 500: {
437
- description: 'Internal server error.',
438
- content: { 'application/json': { schema: ErrorSchema } },
439
- },
440
- },
159
+ ],
441
160
  })
442
161
  ```
443
162
 
444
- ## CLI
163
+ ### Demo
445
164
 
446
- ### Options
165
+ ![](https://raw.githubusercontent.com/nakita628/hono-takibi/refs/heads/main/assets/vite/hono-takibi-vite.gif)
447
166
 
448
- basic
449
167
 
450
- ```bash
451
- Options:
452
- --export-schema exports all schema definitions
453
- --export-type exports all type definitions
454
- ```
168
+ ## With AI Prompt
455
169
 
456
- template
170
+ ### Sample Prompt — Schemas-Only Extractor (OpenAPI 3+)
457
171
 
458
- > **⚠️** When using the `--template` option, you must specify a valid directory path. Ensure the directory exists before executing the
172
+ A copy‑and‑paste prompt for **any LLM** that extracts **only** the contents of `#/components/schemas/` from an OpenAPI document.
459
173
 
460
- ```bash
461
- Options:
462
- --template generation of application and handler files
463
- --test automatic generation of test files
464
- --base-path base URL path for your API endpoints
465
- ```
174
+ ## Prompt Example
466
175
 
467
- ### Example
176
+ ```md
177
+ You are a **Schemas‑Only Extractor** for OpenAPI 3+.
468
178
 
469
- ```bash
470
- npx hono-takibi openapi.yaml -o src/routes.ts --template -test --base-path 'api'
471
- ```
179
+ ## 1. Version
180
+ - Accept files that start with `openapi: "3.0.0"` or newer.
181
+ - Otherwise reply with: `Unsupported OpenAPI version (must be 3.0+).`
182
+
183
+ ## 2. Scope
184
+ - Look **only** inside `#/components/schemas/`. Ignore everything else.
185
+ - `$ref` must also point inside that section.
472
186
 
473
- This project is in **early development** and being maintained by a developer with about 2 years of experience. While I'm doing my best to create a useful tool:
187
+ ## 3. Schemas section present?
188
+ - If `components.schemas` is missing, reply with: `Missing '#/components/schemas/' section. Cannot proceed.`
189
+
190
+ ## 4. File type
191
+ - Accept **.yaml**, **.json**, or **.tsp** files.
192
+ - Otherwise reply with: `Unsupported input file extension.`
193
+
194
+ ## Format tips
195
+ - `format: uuid` usually means **UUID v4**.
196
+ - Other accepted identifiers include `uuidv6`, `uuidv7`, `ulid`, `cuid`, etc.
197
+ - With **hono‑takibi**, you can generate **Zod schemas** directly from a custom OpenAPI file.
198
+
199
+ ## What the LLM should do
200
+ 1. Validate the file with the four rules above.
201
+ 2. If it passes, output **only** the YAML/JSON fragment under `#/components/schemas/` (preserve indentation).
202
+ 3. Otherwise, output the exact error message above—nothing more.
203
+ ```
474
204
 
475
205
  ### ⚠️ WARNING: Potential Breaking Changes Without Notice
476
206
 
@@ -496,27 +226,6 @@ We welcome feedback and contributions to improve the tool!
496
226
  - Limited support for certain response types
497
227
  - Some OpenAPI validations may not be perfectly converted to Zod validations
498
228
 
499
- ### 🙏 Seeking Advice
500
-
501
- As a relatively new developer, I would greatly appreciate feedback on:
502
-
503
- - Code architecture and best practices
504
- - Error handling approaches
505
- - Testing strategies
506
- - Performance improvements
507
- - Security considerations
508
- - Naming convention flexibility
509
- - OpenAPI to Zod conversion strategies
510
-
511
- I welcome any feedback, suggestions, or contributions that could help make this tool more robust and reliable. Feel free to:
512
- - Open issues for bugs or suggestions
513
- - Submit PRs with improvements
514
- - Share your experience using the tool
515
- - Provide guidance on better coding practices
516
- - Report any conversion inconsistencies you find
517
-
518
- Let's make this tool better together! 🔥
519
-
520
229
  ## License
521
230
 
522
231
  Distributed under the MIT License. See [LICENSE](https://github.com/nakita-Ypm/hono-takibi?tab=MIT-1-ov-file) for more information.
@@ -1,23 +1,17 @@
1
1
  import { ok, asyncAndThen } from '../../result/index.js';
2
2
  import { takibi } from './takibi.js';
3
- import { parseCli } from '../args/parse-cli.js';
3
+ import { parseCli } from '../parse/parse-cli.js';
4
4
  import { isHelpRequested, sliceArgv } from '../utils/index.js';
5
5
  const HELP_TEXT = `
6
- Usage:
7
- hono-takibi <input.{yaml,json,tsp}> -o <routes.ts> [options]
6
+ Usage: hono-takibi <input.{yaml,json,tsp}> -o <routes.ts> [options]
8
7
 
9
8
  Options:
10
- --export-type Export TypeScript type aliases
11
- --export-schema Export Zod schema objects
12
- --template Generate app file and handler stubs
13
- --test Generate empty *.test.ts files
14
- --base-path <path> API prefix (default: /)
15
- -h, --help Show this help and exit
16
-
17
- Examples:
18
- hono-takibi api.yaml -o routes.ts
19
- hono-takibi api.yaml -o routes.ts --export-schema --export-type --base-path /api/v1
20
- `.trimStart();
9
+ --export-type export TypeScript type aliases
10
+ --export-schema export Zod schema objects
11
+ --template generate app file and handler stubs
12
+ --test generate empty *.test.ts files
13
+ --base-path <path> api prefix (default: /)
14
+ -h, --help display help for command`.trimStart();
21
15
  export async function honoTakibi() {
22
16
  const args = sliceArgv(process.argv);
23
17
  return isHelpRequested(sliceArgv(process.argv))
@@ -1,4 +1,15 @@
1
- import type { Result } from '../../result/types.js';
1
+ import type { Result } from '../../result/index.js';
2
+ /**
3
+ * @param { `${string}.yaml` | `${string}.json` | `${string}.tsp` } input - The input OpenAPI file.
4
+ * @param { `${string}.ts` } output - The output TypeScript file.
5
+ * @param { boolean } exportSchema - Whether to export the schema.
6
+ * @param { boolean } exportType - Whether to export the type.
7
+ * @param { boolean } template - Whether to generate a template.
8
+ * @param { boolean } test - Whether to generate test files.
9
+ * @param { string } [basePath] - The base path for the template.
10
+ * @returns { Promise<Result<{ message: string }, string>> }
11
+ * @description Generates TypeScript code from an OpenAPI specification and optionally creates template files.
12
+ */
2
13
  export declare function takibi(input: `${string}.yaml` | `${string}.json` | `${string}.tsp`, output: `${string}.ts`, exportSchema: boolean, exportType: boolean, template: boolean, test: boolean, basePath?: string): Promise<Result<{
3
14
  message: string;
4
15
  }, string>>;
@@ -5,6 +5,17 @@ import { parseOpenAPI } from '../../openapi/parse-openapi.js';
5
5
  import { zodOpenAPIHono } from '../../generator/zod-openapi-hono/openapi/zod-openapi-hono.js';
6
6
  import { templateCode } from './template-code.js';
7
7
  import { mkdir, writeFile } from '../../fsp/index.js';
8
+ /**
9
+ * @param { `${string}.yaml` | `${string}.json` | `${string}.tsp` } input - The input OpenAPI file.
10
+ * @param { `${string}.ts` } output - The output TypeScript file.
11
+ * @param { boolean } exportSchema - Whether to export the schema.
12
+ * @param { boolean } exportType - Whether to export the type.
13
+ * @param { boolean } template - Whether to generate a template.
14
+ * @param { boolean } test - Whether to generate test files.
15
+ * @param { string } [basePath] - The base path for the template.
16
+ * @returns { Promise<Result<{ message: string }, string>> }
17
+ * @description Generates TypeScript code from an OpenAPI specification and optionally creates template files.
18
+ */
8
19
  export async function takibi(input, output, exportSchema, exportType, template, test, basePath) {
9
20
  return await asyncAndThen(await parseOpenAPI(input), async (openAPI) => asyncAndThen(await fmt(zodOpenAPIHono(openAPI, exportSchema, exportType)), async (code) => asyncAndThen(await mkdir(path.dirname(output)), async () => asyncAndThen(await writeFile(output, code), async () => asyncAndThen(await templateCode(openAPI, output, template, test, basePath), async () => ok({
10
21
  message: template
@@ -1,3 +1,12 @@
1
1
  import type { OpenAPI } from '../../openapi/index.js';
2
2
  import type { Result } from '../../result/index.js';
3
+ /**
4
+ * @param { OpenAPI } openAPI - OpenAPI specification
5
+ * @param { `${string}.ts` } output - Output file path
6
+ * @param { boolean } template - Whether to generate a template
7
+ * @param { boolean } test - Whether to generate test files
8
+ * @param { string } basePath - Optional base path for the application
9
+ * @returns { Promise<Result<void, string>> }
10
+ * @description Generates a Hono Takibi application template code based on the OpenAPI specification.
11
+ */
3
12
  export declare function templateCode(openAPI: OpenAPI, output: `${string}.ts`, template: boolean, test: boolean, basePath?: string): Promise<Result<void, string>>;
@@ -4,6 +4,15 @@ import { readdir, writeFile } from '../../fsp/index.js';
4
4
  import { fmt } from '../../format/index.js';
5
5
  import { app } from '../../generator/zod-openapi-hono/app/index.js';
6
6
  import { zodOpenapiHonoHandler } from '../../generator/zod-openapi-hono/handler/zod-openapi-hono-handler.js';
7
+ /**
8
+ * @param { OpenAPI } openAPI - OpenAPI specification
9
+ * @param { `${string}.ts` } output - Output file path
10
+ * @param { boolean } template - Whether to generate a template
11
+ * @param { boolean } test - Whether to generate test files
12
+ * @param { string } basePath - Optional base path for the application
13
+ * @returns { Promise<Result<void, string>> }
14
+ * @description Generates a Hono Takibi application template code based on the OpenAPI specification.
15
+ */
7
16
  export async function templateCode(openAPI, output, template, test, basePath) {
8
17
  if (!(template && output.includes('/')))
9
18
  return ok(undefined);