hono-takibi 0.1.3 → 0.1.5

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 (48) hide show
  1. package/README.md +47 -26
  2. package/dist/core/validator/is-format-number.d.ts +8 -0
  3. package/dist/core/validator/is-format-number.js +8 -0
  4. package/dist/core/validator/is-format-string.d.ts +7 -0
  5. package/dist/core/validator/is-format-string.js +7 -0
  6. package/dist/core/validator/is-http-method.js +2 -1
  7. package/dist/core/validator/is-unique-content-schema.d.ts +8 -0
  8. package/dist/core/validator/is-unique-content-schema.js +13 -0
  9. package/dist/generators/openapi/components/generate-components-code.d.ts +0 -28
  10. package/dist/generators/openapi/components/generate-components-code.js +1 -29
  11. package/dist/generators/openapi/paths/generate-create-route.d.ts +1 -0
  12. package/dist/generators/openapi/paths/generate-create-route.js +1 -0
  13. package/dist/generators/openapi/paths/generate-route-code.d.ts +0 -32
  14. package/dist/generators/openapi/paths/generate-route-code.js +2 -34
  15. package/dist/generators/openapi/paths/generate-route-name.d.ts +0 -13
  16. package/dist/generators/openapi/paths/generate-route-name.js +0 -13
  17. package/dist/generators/openapi/paths/generate-route.d.ts +0 -27
  18. package/dist/generators/openapi/paths/generate-route.js +2 -28
  19. package/dist/generators/request/body/generate-insert-request-body.d.ts +0 -23
  20. package/dist/generators/request/body/generate-insert-request-body.js +0 -23
  21. package/dist/generators/request/body/generate-request-body.d.ts +0 -9
  22. package/dist/generators/request/body/generate-request-body.js +3 -11
  23. package/dist/generators/request/params/generate-params-object.d.ts +0 -47
  24. package/dist/generators/request/params/generate-params-object.js +15 -70
  25. package/dist/generators/request/params/generate-request-parameter.d.ts +0 -27
  26. package/dist/generators/request/params/generate-request-parameter.js +0 -27
  27. package/dist/generators/request/params/generate-request-params-array.d.ts +0 -28
  28. package/dist/generators/request/params/generate-request-params-array.js +7 -29
  29. package/dist/generators/request/params/generate-request-params.d.ts +0 -25
  30. package/dist/generators/request/params/generate-request-params.js +0 -25
  31. package/dist/generators/response/schemas/generate-response-schema.d.ts +0 -37
  32. package/dist/generators/response/schemas/generate-response-schema.js +5 -47
  33. package/dist/generators/zod/generate-zod-integer-schema.d.ts +2 -0
  34. package/dist/generators/zod/generate-zod-integer-schema.js +11 -12
  35. package/dist/generators/zod/generate-zod-number-schema.d.ts +2 -0
  36. package/dist/generators/zod/generate-zod-number-schema.js +11 -12
  37. package/dist/generators/zod/generate-zod-schema-definition.d.ts +1 -1
  38. package/dist/generators/zod/generate-zod-schema-definition.js +2 -2
  39. package/dist/generators/zod/generate-zod-schema.d.ts +1 -1
  40. package/dist/generators/zod/generate-zod-schema.js +7 -1
  41. package/dist/generators/zod/generate-zod-string-schema.d.ts +2 -0
  42. package/dist/generators/zod/generate-zod-string-schema.js +12 -13
  43. package/dist/generators/zod/generate-zod-to-openapi.d.ts +1 -1
  44. package/dist/generators/zod/generate-zod-to-openapi.js +4 -1
  45. package/dist/types/index.d.ts +16 -13
  46. package/package.json +2 -1
  47. package/dist/generators/zod/generate-zod-openapi-example.d.ts +0 -2
  48. package/dist/generators/zod/generate-zod-openapi-example.js +0 -6
package/README.md CHANGED
@@ -4,13 +4,17 @@
4
4
 
5
5
  ![img](https://raw.githubusercontent.com/nakita628/hono-takibi/refs/heads/main/assets/img/hono-takibi.png)
6
6
 
7
+ ```bash
8
+ npm add -D hono-takibi
9
+ ```
10
+
7
11
  ## Migrate Legacy APIs to Hono
8
12
 
9
13
  **Hono Takibi** is an OpenAPI-to-Hono code generator, specifically developed to assist in migrating APIs from various programming languages to Hono. This tool automates the creation of type-safe Hono routes from your existing OpenAPI specifications, making it easier to transition from legacy systems (Ruby, Perl, PHP, etc.) to a modern Hono architecture.
10
14
 
11
15
  ## What Problem Does It Solve?
12
16
 
13
- Moving to [Zod OpenAPI Hono](https://hono.dev/examples/zod-openapi) requires:
17
+ Moving to [@hono/zod-openapi](https://hono.dev/examples/zod-openapi) requires:
14
18
 
15
19
  * Manual conversion of OpenAPI paths to Hono routes
16
20
  * Translation of OpenAPI schemas to Zod schemas
@@ -23,20 +27,10 @@ If you have OpenAPI specifications, Hono Takibi automates the conversion process
23
27
  - Generating type-safe route definitions
24
28
  - Creating proper variable names and exports
25
29
 
26
- ```bash
27
- npm add -D hono-takibi
28
- ```
29
-
30
- # Usage
31
-
32
- ```bash
33
- npx hono-takibi path/to/input.yaml -o path/to/output.ts
34
- ```
35
-
36
- # Example
30
+ ## Usage
37
31
 
38
32
  ```bash
39
- npx hono-takibi example/hono-rest-example.yaml -o routes/index.ts
33
+ npx hono-takibi path/to/openapi.yaml -o path/to/output_hono.ts
40
34
  ```
41
35
 
42
36
  input:
@@ -165,19 +159,21 @@ paths:
165
159
  parameters:
166
160
  - in: query
167
161
  name: page
168
- required: false
162
+ required: true
169
163
  schema:
170
164
  type: integer
171
165
  minimum: 0
172
166
  default: 1
167
+ example: 1
173
168
  description: The page number to retrieve. Must be a positive integer. Defaults to 1.
174
169
  - in: query
175
170
  name: rows
176
- required: false
171
+ required: true
177
172
  schema:
178
173
  type: integer
179
174
  minimum: 0
180
175
  default: 10
176
+ example: 10
181
177
  description: The number of posts per page. Must be a positive integer. Defaults to 10.
182
178
  responses:
183
179
  '200':
@@ -272,6 +268,7 @@ paths:
272
268
  schema:
273
269
  type: string
274
270
  format: uuid
271
+ example: 123e4567-e89b-12d3-a456-426614174000
275
272
  description: Unique identifier of the post.
276
273
  responses:
277
274
  '204':
@@ -299,14 +296,16 @@ output:
299
296
  ```ts
300
297
  import { createRoute, z } from '@hono/zod-openapi'
301
298
 
302
- const errorSchema = z.object({ message: z.string() })
299
+ const errorSchema = z.object({ message: z.string() }).openapi('Error')
303
300
 
304
- const postSchema = z.object({
305
- id: z.string().uuid(),
306
- post: z.string().min(1).max(140),
307
- createdAt: z.string().datetime(),
308
- updatedAt: z.string().datetime(),
309
- })
301
+ const postSchema = z
302
+ .object({
303
+ id: z.string().uuid(),
304
+ post: z.string().min(1).max(140),
305
+ createdAt: z.string().datetime(),
306
+ updatedAt: z.string().datetime(),
307
+ })
308
+ .openapi('Post')
310
309
 
311
310
  export const schemas = {
312
311
  errorSchema,
@@ -317,11 +316,16 @@ export const getRoute = createRoute({
317
316
  tags: ['Hono'],
318
317
  method: 'get',
319
318
  path: '/',
319
+ summary: 'Welcome message',
320
320
  description: 'Retrieve a simple welcome message from the Hono API.',
321
321
  responses: {
322
322
  200: {
323
323
  description: 'Successful response with a welcome message.',
324
- content: { 'application/json': { schema: z.object({ message: z.string() }) } },
324
+ content: {
325
+ 'application/json': {
326
+ schema: z.object({ message: z.string().openapi({ example: 'Hono🔥' }) }),
327
+ },
328
+ },
325
329
  },
326
330
  },
327
331
  })
@@ -330,6 +334,7 @@ export const postPostsRoute = createRoute({
330
334
  tags: ['Post'],
331
335
  method: 'post',
332
336
  path: '/posts',
337
+ summary: 'Create a new post',
333
338
  description: 'Submit a new post with a maximum length of 140 characters.',
334
339
  request: {
335
340
  body: {
@@ -357,12 +362,13 @@ export const getPostsRoute = createRoute({
357
362
  tags: ['Post'],
358
363
  method: 'get',
359
364
  path: '/posts',
365
+ summary: 'Retrieve a list of posts',
360
366
  description:
361
367
  'Retrieve a paginated list of posts. Specify the page number and the number of posts per page.',
362
368
  request: {
363
369
  query: z.object({
364
- page: z.string().pipe(z.coerce.number().int().min(0)).optional(),
365
- rows: z.string().pipe(z.coerce.number().int().min(0)).optional(),
370
+ page: z.string().pipe(z.coerce.number().int().min(0).default(1).openapi({ example: 1 })),
371
+ rows: z.string().pipe(z.coerce.number().int().min(0).default(10).openapi({ example: 10 })),
366
372
  }),
367
373
  },
368
374
  responses: {
@@ -385,6 +391,7 @@ export const putPostsIdRoute = createRoute({
385
391
  tags: ['Post'],
386
392
  method: 'put',
387
393
  path: '/posts/{id}',
394
+ summary: 'Update an existing post',
388
395
  description: 'Update the content of an existing post identified by its unique ID.',
389
396
  request: {
390
397
  body: {
@@ -410,8 +417,19 @@ export const deletePostsIdRoute = createRoute({
410
417
  tags: ['Post'],
411
418
  method: 'delete',
412
419
  path: '/posts/{id}',
420
+ summary: 'Delete a post',
413
421
  description: 'Delete an existing post identified by its unique ID.',
414
- request: { params: z.object({ id: z.string().uuid() }) },
422
+ request: {
423
+ params: z.object({
424
+ id: z
425
+ .string()
426
+ .uuid()
427
+ .openapi({
428
+ param: { name: 'id', in: 'path' },
429
+ example: '123e4567-e89b-12d3-a456-426614174000',
430
+ }),
431
+ }),
432
+ },
415
433
  responses: {
416
434
  204: { description: 'Post successfully deleted.' },
417
435
  400: {
@@ -426,6 +444,9 @@ export const deletePostsIdRoute = createRoute({
426
444
  })
427
445
  ```
428
446
 
447
+
448
+ 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:
449
+
429
450
  ### ⚠️ WARNING: Potential Breaking Changes Without Notice
430
451
 
431
452
  **This package is in active development and may introduce breaking changes without prior notice.**
@@ -1,2 +1,10 @@
1
1
  import type { Format, FormatNumber } from '../../types';
2
+ /**
3
+ * Checks if the format is a number type
4
+ *
5
+ * @function isFormatNumber
6
+ *
7
+ * @param format - OpenAPI format type
8
+ * @returns true if the format is a number type, false otherwise
9
+ */
2
10
  export declare function isFormatNumber(format: Format): format is FormatNumber;
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isFormatNumber = isFormatNumber;
4
+ /**
5
+ * Checks if the format is a number type
6
+ *
7
+ * @function isFormatNumber
8
+ *
9
+ * @param format - OpenAPI format type
10
+ * @returns true if the format is a number type, false otherwise
11
+ */
4
12
  function isFormatNumber(format) {
5
13
  return ['int32', 'int64', 'float', 'double'].includes(format);
6
14
  }
@@ -1,2 +1,9 @@
1
1
  import type { Format, FormatString } from '../../types';
2
+ /**
3
+ * Checks if the format is a string type
4
+ *
5
+ * @function isFormatString
6
+ * @param format - OpenAPI format type
7
+ * @returns true if the format is a string type, false otherwise
8
+ */
2
9
  export declare function isFormatString(format: Format): format is FormatString;
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isFormatString = isFormatString;
4
+ /**
5
+ * Checks if the format is a string type
6
+ *
7
+ * @function isFormatString
8
+ * @param format - OpenAPI format type
9
+ * @returns true if the format is a string type, false otherwise
10
+ */
4
11
  function isFormatString(format) {
5
12
  return [
6
13
  'email',
@@ -15,5 +15,6 @@ function isHttpMethod(method) {
15
15
  method === 'delete' ||
16
16
  method === 'patch' ||
17
17
  method === 'options' ||
18
- method === 'head');
18
+ method === 'head' ||
19
+ method === 'trace');
19
20
  }
@@ -0,0 +1,8 @@
1
+ import type { Content } from '../../types';
2
+ /**
3
+ * Get unique content schema
4
+ * @param contentTypes - Content types
5
+ * @param content - Content
6
+ * @returns Unique content schema
7
+ */
8
+ export declare function isUniqueContentSchema(contentTypes: string[], content: Content): boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isUniqueContentSchema = isUniqueContentSchema;
4
+ /**
5
+ * Get unique content schema
6
+ * @param contentTypes - Content types
7
+ * @param content - Content
8
+ * @returns Unique content schema
9
+ */
10
+ function isUniqueContentSchema(contentTypes, content) {
11
+ const schema = new Set(contentTypes.map((type) => JSON.stringify(content?.[type].schema)));
12
+ return schema.size === 1;
13
+ }
@@ -7,34 +7,6 @@ import type { Components } from '../../../types';
7
7
  * @param components - OpenAPI components object containing schema definitions
8
8
  * @returns Generated TypeScript code string containing Zod schema definitions and exports, or empty string if no schemas
9
9
  *
10
- * @example
11
- * // With schemas
12
- * const components = {
13
- * schemas: {
14
- * User: {
15
- * type: 'object',
16
- * properties: {
17
- * profile: { $ref: '#/components/schemas/Profile' }
18
- * }
19
- * },
20
- * Profile: {
21
- * type: 'object',
22
- * properties: {
23
- * name: { type: 'string' }
24
- * }
25
- * }
26
- * }
27
- * }
28
- * generateComponentsCode(components)
29
- * // Returns:
30
- * // export const profileSchema = z.object({ name: z.string() })
31
- * // export const userSchema = z.object({ profile: profileSchema })
32
- * // export const schemas = { profileSchema, userSchema }
33
- *
34
- * // Without schemas
35
- * generateComponentsCode({})
36
- * // Returns: ''
37
- *
38
10
  * @note The function:
39
11
  * 1. Extracts schemas from components
40
12
  * 2. Resolves dependencies between schemas to determine correct generation order
@@ -14,34 +14,6 @@ const generate_schemas_export_1 = require("../paths/generate-schemas-export");
14
14
  * @param components - OpenAPI components object containing schema definitions
15
15
  * @returns Generated TypeScript code string containing Zod schema definitions and exports, or empty string if no schemas
16
16
  *
17
- * @example
18
- * // With schemas
19
- * const components = {
20
- * schemas: {
21
- * User: {
22
- * type: 'object',
23
- * properties: {
24
- * profile: { $ref: '#/components/schemas/Profile' }
25
- * }
26
- * },
27
- * Profile: {
28
- * type: 'object',
29
- * properties: {
30
- * name: { type: 'string' }
31
- * }
32
- * }
33
- * }
34
- * }
35
- * generateComponentsCode(components)
36
- * // Returns:
37
- * // export const profileSchema = z.object({ name: z.string() })
38
- * // export const userSchema = z.object({ profile: profileSchema })
39
- * // export const schemas = { profileSchema, userSchema }
40
- *
41
- * // Without schemas
42
- * generateComponentsCode({})
43
- * // Returns: ''
44
- *
45
17
  * @note The function:
46
18
  * 1. Extracts schemas from components
47
19
  * 2. Resolves dependencies between schemas to determine correct generation order
@@ -69,7 +41,7 @@ function generateComponentsCode(components) {
69
41
  // 4.3 generate zod schema
70
42
  const zodSchema = (0, generate_zod_schema_1.generateZodSchema)(schema);
71
43
  // 4.4 generate zod schema definition
72
- return (0, generate_zod_schema_definition_1.generateZodSchemaDefinition)(camelCaseSchemaName, zodSchema);
44
+ return (0, generate_zod_schema_definition_1.generateZodSchemaDefinition)(camelCaseSchemaName, zodSchema, schemaName);
73
45
  })
74
46
  .join('\n\n');
75
47
  // 5. generate export statement
@@ -3,6 +3,7 @@ type GenerateCreateRouteParams = {
3
3
  tagsCode: string;
4
4
  methodCode: string;
5
5
  pathCode: string;
6
+ summaryCode?: string;
6
7
  descriptionCode?: string;
7
8
  securityCode?: string;
8
9
  requestParams: string;
@@ -52,6 +52,7 @@ function generateCreateRoute(args) {
52
52
  args.tagsCode,
53
53
  args.methodCode,
54
54
  args.pathCode,
55
+ args.summaryCode,
55
56
  args.descriptionCode,
56
57
  args.securityCode,
57
58
  args.requestParams,
@@ -6,38 +6,6 @@ import type { OpenAPIPaths } from '../../../types';
6
6
  * @param openAPIPaths - OpenAPI paths object containing route definitions
7
7
  * @returns Generated TypeScript code string for all valid routes
8
8
  *
9
- * @example
10
- * const paths = {
11
- * '/users': {
12
- * get: {
13
- * operationId: 'getUsers',
14
- * responses: {
15
- * '200': {
16
- * description: 'List of users',
17
- * content: {
18
- * 'application/json': {
19
- * schema: { $ref: '#/components/schemas/UserList' }
20
- * }
21
- * }
22
- * }
23
- * }
24
- * },
25
- * post: {
26
- * operationId: 'createUser',
27
- * requestBody: {
28
- * content: {
29
- * 'application/json': {
30
- * schema: { $ref: '#/components/schemas/CreateUserInput' }
31
- * }
32
- * }
33
- * }
34
- * }
35
- * }
36
- * }
37
- *
38
- * const code = generateRouteCode(paths)
39
- * // Returns TypeScript code for both GET and POST /users routes
40
- *
41
9
  * @note
42
10
  * - Processes each path and HTTP method combination
43
11
  * - Validates HTTP methods and operation objects
@@ -11,38 +11,6 @@ const is_operation_1 = require("../../../core/validator/is-operation");
11
11
  * @param openAPIPaths - OpenAPI paths object containing route definitions
12
12
  * @returns Generated TypeScript code string for all valid routes
13
13
  *
14
- * @example
15
- * const paths = {
16
- * '/users': {
17
- * get: {
18
- * operationId: 'getUsers',
19
- * responses: {
20
- * '200': {
21
- * description: 'List of users',
22
- * content: {
23
- * 'application/json': {
24
- * schema: { $ref: '#/components/schemas/UserList' }
25
- * }
26
- * }
27
- * }
28
- * }
29
- * },
30
- * post: {
31
- * operationId: 'createUser',
32
- * requestBody: {
33
- * content: {
34
- * 'application/json': {
35
- * schema: { $ref: '#/components/schemas/CreateUserInput' }
36
- * }
37
- * }
38
- * }
39
- * }
40
- * }
41
- * }
42
- *
43
- * const code = generateRouteCode(paths)
44
- * // Returns TypeScript code for both GET and POST /users routes
45
- *
46
14
  * @note
47
15
  * - Processes each path and HTTP method combination
48
16
  * - Validates HTTP methods and operation objects
@@ -67,9 +35,9 @@ function generateRouteCode(openAPIPaths) {
67
35
  // 3.1. skip parameters key and undefined operations
68
36
  if (method === 'parameters' || !pathItemValue)
69
37
  continue;
70
- // 3.2. check if the method is an actual HTTP method
38
+ // 3.2. check if the method is an HTTP method
71
39
  if (!(0, is_http_method_1.isHttpMethod)(method))
72
- continue;
40
+ throw new Error('Invalid HTTP method');
73
41
  // 3.3 exclude the possibility of string or Parameter[]
74
42
  if (typeof pathItemValue === 'string' || Array.isArray(pathItemValue))
75
43
  continue;
@@ -5,19 +5,6 @@
5
5
  * @param path - URL path pattern (e.g., '/users/{id}/posts')
6
6
  * @returns Formatted route name string
7
7
  *
8
- * @example
9
- * // Basic path
10
- * generateRouteName('get', '/users')
11
- * // Returns: 'getUsersRoute'
12
- *
13
- * // Path with parameters
14
- * generateRouteName('post', '/users/{id}/posts')
15
- * // Returns: 'postUsersIdPostsRoute'
16
- *
17
- * // Path with hyphens
18
- * generateRouteName('put', '/user-profiles/{id}')
19
- * // Returns: 'putUserProfilesIdRoute'
20
- *
21
8
  * @remarks
22
9
  * Transformation process:
23
10
  * 1. Replace special characters (/{}-) with spaces
@@ -9,19 +9,6 @@ const capitalize_1 = require("../../../core/text/capitalize");
9
9
  * @param path - URL path pattern (e.g., '/users/{id}/posts')
10
10
  * @returns Formatted route name string
11
11
  *
12
- * @example
13
- * // Basic path
14
- * generateRouteName('get', '/users')
15
- * // Returns: 'getUsersRoute'
16
- *
17
- * // Path with parameters
18
- * generateRouteName('post', '/users/{id}/posts')
19
- * // Returns: 'postUsersIdPostsRoute'
20
- *
21
- * // Path with hyphens
22
- * generateRouteName('put', '/user-profiles/{id}')
23
- * // Returns: 'putUserProfilesIdRoute'
24
- *
25
12
  * @remarks
26
13
  * Transformation process:
27
14
  * 1. Replace special characters (/{}-) with spaces
@@ -8,33 +8,6 @@ import type { Operation } from '../../../types';
8
8
  * @param operation - The OpenAPI Operation object containing route details
9
9
  * @returns Generated TypeScript code string for the route
10
10
  *
11
- * @example
12
- * const operation = {
13
- * tags: ['users'],
14
- * description: 'Create a new user',
15
- * security: [{ bearerAuth: [] }],
16
- * requestBody: {
17
- * content: {
18
- * 'application/json': {
19
- * schema: { $ref: '#/components/schemas/CreateUserInput' }
20
- * }
21
- * }
22
- * },
23
- * responses: {
24
- * '201': {
25
- * description: 'User created successfully',
26
- * content: {
27
- * 'application/json': {
28
- * schema: { $ref: '#/components/schemas/User' }
29
- * }
30
- * }
31
- * }
32
- * }
33
- * }
34
- *
35
- * const route = generateRoute('/users', 'post', operation)
36
- * // Returns: TypeScript code for a type-safe POST /users route
37
- *
38
11
  * @note
39
12
  * - Generates a complete route definition including:
40
13
  * - Route name based on method and path
@@ -15,33 +15,6 @@ const escape_quote_1 = require("../../../core/text/escape-quote");
15
15
  * @param operation - The OpenAPI Operation object containing route details
16
16
  * @returns Generated TypeScript code string for the route
17
17
  *
18
- * @example
19
- * const operation = {
20
- * tags: ['users'],
21
- * description: 'Create a new user',
22
- * security: [{ bearerAuth: [] }],
23
- * requestBody: {
24
- * content: {
25
- * 'application/json': {
26
- * schema: { $ref: '#/components/schemas/CreateUserInput' }
27
- * }
28
- * }
29
- * },
30
- * responses: {
31
- * '201': {
32
- * description: 'User created successfully',
33
- * content: {
34
- * 'application/json': {
35
- * schema: { $ref: '#/components/schemas/User' }
36
- * }
37
- * }
38
- * }
39
- * }
40
- * }
41
- *
42
- * const route = generateRoute('/users', 'post', operation)
43
- * // Returns: TypeScript code for a type-safe POST /users route
44
- *
45
18
  * @note
46
19
  * - Generates a complete route definition including:
47
20
  * - Route name based on method and path
@@ -56,7 +29,7 @@ const escape_quote_1 = require("../../../core/text/escape-quote");
56
29
  * - Integrates with Hono's createRoute function
57
30
  */
58
31
  function generateRoute(path, method, operation) {
59
- const { tags, description, security, parameters, requestBody, responses } = operation;
32
+ const { tags, summary, description, security, parameters, requestBody, responses } = operation;
60
33
  const routeName = (0, generate_route_name_1.generateRouteName)(method, path);
61
34
  const tagList = tags ? JSON.stringify(tags) : '[]';
62
35
  const requestParams = (0, generate_request_parameter_1.generateRequestParameter)(parameters, requestBody);
@@ -65,6 +38,7 @@ function generateRoute(path, method, operation) {
65
38
  tagsCode: `tags:${tagList},`,
66
39
  methodCode: `method:'${method}',`,
67
40
  pathCode: `path:'${path}',`,
41
+ summaryCode: summary ? `summary:'${(0, escape_quote_1.escapeQuote)(summary)}',` : '',
68
42
  descriptionCode: description ? `description:'${(0, escape_quote_1.escapeQuote)(description)}',` : '',
69
43
  securityCode: security ? `security:${JSON.stringify(security)},` : '',
70
44
  requestParams: requestParams ? `${requestParams}` : '',
@@ -5,28 +5,5 @@
5
5
  * @param requestParams - Existing request parameters string
6
6
  * @param requestBodyCode - Request body validation code to insert
7
7
  * @returns Combined request validation string
8
- *
9
- * @example
10
- * // Adding body validation to query parameters
11
- * const params = 'request:{query:z.object({id:z.string()})}'
12
- * const body = 'body:{content:{"application/json":{schema:z.object({name:z.string()})}}}'
13
- *
14
- * generateInsertRequestBody(params, body)
15
- * // Returns:
16
- * // 'request:{
17
- * // body:{
18
- * // content:{
19
- * // "application/json":{
20
- * // schema:z.object({name:z.string()})
21
- * // }
22
- * // }
23
- * // },
24
- * // query:z.object({id:z.string()})
25
- * // }'
26
- *
27
- * @example
28
- * // Adding body to empty request
29
- * generateInsertRequestBody('request:{}', 'body:{...}')
30
- * // Returns: 'request:{body:{...}}'
31
8
  */
32
9
  export declare function generateInsertRequestBody(requestParams: string, requestBodyCode: string): string;
@@ -8,29 +8,6 @@ exports.generateInsertRequestBody = generateInsertRequestBody;
8
8
  * @param requestParams - Existing request parameters string
9
9
  * @param requestBodyCode - Request body validation code to insert
10
10
  * @returns Combined request validation string
11
- *
12
- * @example
13
- * // Adding body validation to query parameters
14
- * const params = 'request:{query:z.object({id:z.string()})}'
15
- * const body = 'body:{content:{"application/json":{schema:z.object({name:z.string()})}}}'
16
- *
17
- * generateInsertRequestBody(params, body)
18
- * // Returns:
19
- * // 'request:{
20
- * // body:{
21
- * // content:{
22
- * // "application/json":{
23
- * // schema:z.object({name:z.string()})
24
- * // }
25
- * // }
26
- * // },
27
- * // query:z.object({id:z.string()})
28
- * // }'
29
- *
30
- * @example
31
- * // Adding body to empty request
32
- * generateInsertRequestBody('request:{}', 'body:{...}')
33
- * // Returns: 'request:{body:{...}}'
34
11
  */
35
12
  function generateInsertRequestBody(requestParams, requestBodyCode) {
36
13
  return requestParams.replace('request:{', `request:{${requestBodyCode}`);
@@ -6,14 +6,5 @@ import type { Content } from '../../../types';
6
6
  * @param required - Whether the request body is required
7
7
  * @param zodSchema - Zod schema string for request body validation
8
8
  * @returns Generated request body configuration string
9
- *
10
- * @example
11
- * // Required request body
12
- * generateRequestBody(true, 'z.object({ name: z.string() })')
13
- * // Returns: 'body:{required:true,content:{'application/json':{schema:z.object({ name: z.string() }),},},},'
14
- *
15
- * // Optional request body
16
- * generateRequestBody(false, 'z.object({ age: z.number() })')
17
- * // Returns: 'body:{required:false,content:{'application/json':{schema:z.object({ age: z.number() }),},},},'
18
9
  */
19
10
  export declare function generateRequestBody(required: boolean, content: Content, zodSchema: string): string;