@g1cloud/api-gen 1.0.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 (86) hide show
  1. package/.claude/settings.local.json +22 -0
  2. package/CLAUDE.md +63 -0
  3. package/README.md +379 -0
  4. package/dist/analyzer/controllerAnalyzer.d.ts +20 -0
  5. package/dist/analyzer/controllerAnalyzer.d.ts.map +1 -0
  6. package/dist/analyzer/controllerAnalyzer.js +101 -0
  7. package/dist/analyzer/controllerAnalyzer.js.map +1 -0
  8. package/dist/analyzer/parameterAnalyzer.d.ts +19 -0
  9. package/dist/analyzer/parameterAnalyzer.d.ts.map +1 -0
  10. package/dist/analyzer/parameterAnalyzer.js +207 -0
  11. package/dist/analyzer/parameterAnalyzer.js.map +1 -0
  12. package/dist/analyzer/responseAnalyzer.d.ts +12 -0
  13. package/dist/analyzer/responseAnalyzer.d.ts.map +1 -0
  14. package/dist/analyzer/responseAnalyzer.js +116 -0
  15. package/dist/analyzer/responseAnalyzer.js.map +1 -0
  16. package/dist/analyzer/schemaGenerator.d.ts +6 -0
  17. package/dist/analyzer/schemaGenerator.d.ts.map +1 -0
  18. package/dist/analyzer/schemaGenerator.js +347 -0
  19. package/dist/analyzer/schemaGenerator.js.map +1 -0
  20. package/dist/analyzer/securityAnalyzer.d.ts +6 -0
  21. package/dist/analyzer/securityAnalyzer.d.ts.map +1 -0
  22. package/dist/analyzer/securityAnalyzer.js +177 -0
  23. package/dist/analyzer/securityAnalyzer.js.map +1 -0
  24. package/dist/generator/openapiGenerator.d.ts +14 -0
  25. package/dist/generator/openapiGenerator.d.ts.map +1 -0
  26. package/dist/generator/openapiGenerator.js +340 -0
  27. package/dist/generator/openapiGenerator.js.map +1 -0
  28. package/dist/index.d.ts +3 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +218 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/lib.d.ts +61 -0
  33. package/dist/lib.d.ts.map +1 -0
  34. package/dist/lib.js +199 -0
  35. package/dist/lib.js.map +1 -0
  36. package/dist/mcp-server.d.ts +9 -0
  37. package/dist/mcp-server.d.ts.map +1 -0
  38. package/dist/mcp-server.js +257 -0
  39. package/dist/mcp-server.js.map +1 -0
  40. package/dist/mcp-server.mjs +45586 -0
  41. package/dist/parser/astAnalyzer.d.ts +87 -0
  42. package/dist/parser/astAnalyzer.d.ts.map +1 -0
  43. package/dist/parser/astAnalyzer.js +321 -0
  44. package/dist/parser/astAnalyzer.js.map +1 -0
  45. package/dist/parser/javaParser.d.ts +10 -0
  46. package/dist/parser/javaParser.d.ts.map +1 -0
  47. package/dist/parser/javaParser.js +805 -0
  48. package/dist/parser/javaParser.js.map +1 -0
  49. package/dist/types/index.d.ts +217 -0
  50. package/dist/types/index.d.ts.map +1 -0
  51. package/dist/types/index.js +3 -0
  52. package/dist/types/index.js.map +1 -0
  53. package/examples/CreateUserRequest.java +80 -0
  54. package/examples/DepartmentDTO.java +45 -0
  55. package/examples/Filter.java +39 -0
  56. package/examples/PaginatedList.java +71 -0
  57. package/examples/ProductController.java +136 -0
  58. package/examples/ProductDTO.java +129 -0
  59. package/examples/RoleDTO.java +47 -0
  60. package/examples/SearchParam.java +55 -0
  61. package/examples/Sort.java +70 -0
  62. package/examples/UpdateUserRequest.java +74 -0
  63. package/examples/UserController.java +98 -0
  64. package/examples/UserDTO.java +119 -0
  65. package/package.json +51 -0
  66. package/prompt/01_Initial.md +358 -0
  67. package/prompt/02_/354/266/224/352/260/200.md +31 -0
  68. package/src/analyzer/controllerAnalyzer.ts +125 -0
  69. package/src/analyzer/parameterAnalyzer.ts +259 -0
  70. package/src/analyzer/responseAnalyzer.ts +142 -0
  71. package/src/analyzer/schemaGenerator.ts +412 -0
  72. package/src/analyzer/securityAnalyzer.ts +200 -0
  73. package/src/generator/openapiGenerator.ts +378 -0
  74. package/src/index.ts +212 -0
  75. package/src/lib.ts +240 -0
  76. package/src/mcp-server.ts +310 -0
  77. package/src/parser/astAnalyzer.ts +373 -0
  78. package/src/parser/javaParser.ts +901 -0
  79. package/src/types/index.ts +238 -0
  80. package/test-boolean.yaml +607 -0
  81. package/test-filter.yaml +576 -0
  82. package/test-inner.ts +59 -0
  83. package/test-output.yaml +650 -0
  84. package/test-paginated.yaml +585 -0
  85. package/tsconfig.json +20 -0
  86. package/tsup.config.ts +30 -0
@@ -0,0 +1,650 @@
1
+ openapi: 3.0.0
2
+ info:
3
+ title: API Documentation
4
+ version: 1.0.0
5
+ tags:
6
+ - name: ProductController
7
+ description: "Product management REST controller\r\nDemonstrates additional features like @Secured and complex queries"
8
+ - name: UserController
9
+ description: User management REST controller
10
+ paths:
11
+ /api/products:
12
+ get:
13
+ summary: Search Products
14
+ operationId: product_searchProducts
15
+ responses:
16
+ '200':
17
+ description: Successful response
18
+ headers:
19
+ X-Total-Count:
20
+ schema:
21
+ type: integer
22
+ description: Total number of items
23
+ X-Offset:
24
+ schema:
25
+ type: integer
26
+ description: Current offset
27
+ X-Limit:
28
+ schema:
29
+ type: integer
30
+ description: Current limit
31
+ content:
32
+ application/json:
33
+ schema:
34
+ type: array
35
+ items:
36
+ $ref: '#/components/schemas/ProductDTO'
37
+ tags:
38
+ - ProductController
39
+ description: Search products with pagination
40
+ parameters:
41
+ - name: offset
42
+ in: query
43
+ schema:
44
+ type: integer
45
+ description: Pagination offset
46
+ - name: limit
47
+ in: query
48
+ schema:
49
+ type: integer
50
+ description: Pagination limit
51
+ - name: filter
52
+ in: query
53
+ schema:
54
+ $ref: '#/components/schemas/Filter'
55
+ description: Filter conditions
56
+ - name: sort
57
+ in: query
58
+ schema:
59
+ $ref: '#/components/schemas/Sort'
60
+ description: Sort conditions
61
+ post:
62
+ summary: Create Product
63
+ operationId: product_createProduct
64
+ responses:
65
+ '200':
66
+ description: Successful response
67
+ content:
68
+ application/json:
69
+ schema:
70
+ $ref: '#/components/schemas/ProductDTO'
71
+ tags:
72
+ - ProductController
73
+ description: "Create new product\r\nUsing @Secured annotation\n\n**Required Roles:** ROLE_ADMIN"
74
+ requestBody:
75
+ required: true
76
+ content:
77
+ application/json:
78
+ schema:
79
+ $ref: '#/components/schemas/ProductDTO'
80
+ security:
81
+ - bearerAuth: []
82
+ x-required-roles:
83
+ - ROLE_ADMIN
84
+ /api/products/{id}:
85
+ get:
86
+ summary: Get Product By Id
87
+ operationId: product_getProductById
88
+ responses:
89
+ '200':
90
+ description: Successful response
91
+ content:
92
+ application/json:
93
+ schema:
94
+ $ref: '#/components/schemas/ProductDTO'
95
+ tags:
96
+ - ProductController
97
+ description: Get product by ID
98
+ parameters:
99
+ - name: id
100
+ in: path
101
+ schema:
102
+ type: integer
103
+ format: int64
104
+ required: true
105
+ put:
106
+ summary: Update Product
107
+ operationId: product_updateProduct
108
+ responses:
109
+ '200':
110
+ description: Successful response
111
+ content:
112
+ application/json:
113
+ schema:
114
+ $ref: '#/components/schemas/ProductDTO'
115
+ tags:
116
+ - ProductController
117
+ description: "Update product\r\nComplex security: admin can update any product, vendor can only update own products\n\n**Required Roles:** ROLE_ADMIN, ROLE_VENDOR\n\n**Security Expression:** `hasRole('ADMIN') or (hasRole('VENDOR') and @productService.isOwner(#id, authentication.principal.id))`"
118
+ parameters:
119
+ - name: id
120
+ in: path
121
+ schema:
122
+ type: integer
123
+ format: int64
124
+ required: true
125
+ requestBody:
126
+ required: true
127
+ content:
128
+ application/json:
129
+ schema:
130
+ $ref: '#/components/schemas/ProductDTO'
131
+ security:
132
+ - bearerAuth: []
133
+ x-required-roles:
134
+ - ROLE_ADMIN
135
+ - ROLE_VENDOR
136
+ x-security-expression: hasRole('ADMIN') or (hasRole('VENDOR') and @productService.isOwner(#id, authentication.principal.id))
137
+ delete:
138
+ summary: Delete Product
139
+ operationId: product_deleteProduct
140
+ responses:
141
+ '200':
142
+ description: Successful response
143
+ tags:
144
+ - ProductController
145
+ description: Delete product
146
+ parameters:
147
+ - name: id
148
+ in: path
149
+ schema:
150
+ type: integer
151
+ format: int64
152
+ required: true
153
+ /api/products/category/{categoryId}:
154
+ get:
155
+ summary: Get Products By Category
156
+ operationId: product_getProductsByCategory
157
+ responses:
158
+ '200':
159
+ description: Successful response
160
+ content:
161
+ application/json:
162
+ schema:
163
+ type: array
164
+ items:
165
+ $ref: '#/components/schemas/ProductDTO'
166
+ tags:
167
+ - ProductController
168
+ description: |-
169
+ Get products by category with price range filter
170
+
171
+ **Security Expression:** `isAuthenticated()`
172
+ parameters:
173
+ - name: categoryId
174
+ in: path
175
+ schema:
176
+ type: integer
177
+ format: int64
178
+ required: true
179
+ - name: minPrice
180
+ in: query
181
+ schema:
182
+ type: number
183
+ - name: maxPrice
184
+ in: query
185
+ schema:
186
+ type: number
187
+ - name: limit
188
+ in: query
189
+ schema:
190
+ type: integer
191
+ format: int32
192
+ x-security-expression: isAuthenticated()
193
+ /api/products/search:
194
+ get:
195
+ summary: Search Products By Name
196
+ operationId: product_searchProductsByName
197
+ responses:
198
+ '200':
199
+ description: Successful response
200
+ content:
201
+ application/json:
202
+ schema:
203
+ type: array
204
+ items:
205
+ $ref: '#/components/schemas/ProductDTO'
206
+ tags:
207
+ - ProductController
208
+ description: Search products by name (partial match)
209
+ parameters:
210
+ - name: query
211
+ in: query
212
+ schema:
213
+ type: string
214
+ required: true
215
+ - name: sortBy
216
+ in: query
217
+ schema:
218
+ type: string
219
+ - name: sortDirection
220
+ in: query
221
+ schema:
222
+ type: string
223
+ /api/products/bulk-price-update:
224
+ post:
225
+ summary: Bulk Update Prices
226
+ operationId: product_bulkUpdatePrices
227
+ responses:
228
+ '200':
229
+ description: Successful response
230
+ content:
231
+ application/json:
232
+ schema:
233
+ type: array
234
+ items:
235
+ $ref: '#/components/schemas/ProductDTO'
236
+ tags:
237
+ - ProductController
238
+ description: "Bulk update product prices\r\nVery complex security expression with multiple conditions\n\n**Required Roles:** ROLE_ADMIN\n\n**Security Expression:** `hasRole('ADMIN') and hasAuthority('BULK_OPERATIONS') and #request.size() <= 100`"
239
+ requestBody:
240
+ required: true
241
+ content:
242
+ application/json:
243
+ schema:
244
+ type: array
245
+ items:
246
+ $ref: '#/components/schemas/PriceUpdateRequest'
247
+ security:
248
+ - bearerAuth: []
249
+ x-required-roles:
250
+ - ROLE_ADMIN
251
+ x-security-expression: 'hasRole(''ADMIN'') and hasAuthority(''BULK_OPERATIONS'') and #request.size() <= 100'
252
+ /api/users:
253
+ get:
254
+ summary: Search Users
255
+ operationId: user_searchUsers
256
+ responses:
257
+ '200':
258
+ description: Successful response
259
+ headers:
260
+ X-Total-Count:
261
+ schema:
262
+ type: integer
263
+ description: Total number of items
264
+ X-Offset:
265
+ schema:
266
+ type: integer
267
+ description: Current offset
268
+ X-Limit:
269
+ schema:
270
+ type: integer
271
+ description: Current limit
272
+ content:
273
+ application/json:
274
+ schema:
275
+ type: array
276
+ items:
277
+ $ref: '#/components/schemas/UserDTO'
278
+ tags:
279
+ - UserController
280
+ description: "Search users with pagination\r\nUses SearchParam for pagination and filtering\n\n**Required Roles:** ROLE_USER"
281
+ parameters:
282
+ - name: offset
283
+ in: query
284
+ schema:
285
+ type: integer
286
+ description: Pagination offset
287
+ - name: limit
288
+ in: query
289
+ schema:
290
+ type: integer
291
+ description: Pagination limit
292
+ - name: filter
293
+ in: query
294
+ schema:
295
+ $ref: '#/components/schemas/Filter'
296
+ description: Filter conditions
297
+ - name: sort
298
+ in: query
299
+ schema:
300
+ $ref: '#/components/schemas/Sort'
301
+ description: Sort conditions
302
+ security:
303
+ - bearerAuth: []
304
+ x-required-roles:
305
+ - ROLE_USER
306
+ post:
307
+ summary: Create User
308
+ operationId: user_createUser
309
+ responses:
310
+ '200':
311
+ description: Successful response
312
+ content:
313
+ application/json:
314
+ schema:
315
+ $ref: '#/components/schemas/UserDTO'
316
+ tags:
317
+ - UserController
318
+ description: |-
319
+ Create new user
320
+
321
+ **Required Roles:** ROLE_ADMIN
322
+ requestBody:
323
+ required: true
324
+ content:
325
+ application/json:
326
+ schema:
327
+ $ref: '#/components/schemas/CreateUserRequest'
328
+ security:
329
+ - bearerAuth: []
330
+ x-required-roles:
331
+ - ROLE_ADMIN
332
+ /api/users/{id}:
333
+ get:
334
+ summary: Get User By Id
335
+ operationId: user_getUserById
336
+ responses:
337
+ '200':
338
+ description: Successful response
339
+ content:
340
+ application/json:
341
+ schema:
342
+ $ref: '#/components/schemas/UserDTO'
343
+ tags:
344
+ - UserController
345
+ description: |-
346
+ Get user by ID
347
+
348
+ **Required Roles:** ROLE_USER, ROLE_ADMIN
349
+ parameters:
350
+ - name: id
351
+ in: path
352
+ schema:
353
+ type: integer
354
+ format: int64
355
+ required: true
356
+ security:
357
+ - bearerAuth: []
358
+ x-required-roles:
359
+ - ROLE_USER
360
+ - ROLE_ADMIN
361
+ put:
362
+ summary: Update User
363
+ operationId: user_updateUser
364
+ responses:
365
+ '200':
366
+ description: Successful response
367
+ content:
368
+ application/json:
369
+ schema:
370
+ $ref: '#/components/schemas/UserDTO'
371
+ tags:
372
+ - UserController
373
+ description: "Update existing user\r\nComplex security: admin can update anyone, users can only update themselves\n\n**Required Roles:** ROLE_ADMIN, ROLE_USER\n\n**Security Expression:** `hasRole('ADMIN') or (#id == authentication.principal.id and hasRole('USER'))`"
374
+ parameters:
375
+ - name: id
376
+ in: path
377
+ schema:
378
+ type: integer
379
+ format: int64
380
+ required: true
381
+ requestBody:
382
+ required: true
383
+ content:
384
+ application/json:
385
+ schema:
386
+ $ref: '#/components/schemas/UpdateUserRequest'
387
+ security:
388
+ - bearerAuth: []
389
+ x-required-roles:
390
+ - ROLE_ADMIN
391
+ - ROLE_USER
392
+ x-security-expression: hasRole('ADMIN') or (#id == authentication.principal.id and hasRole('USER'))
393
+ delete:
394
+ summary: Delete User
395
+ operationId: user_deleteUser
396
+ responses:
397
+ '200':
398
+ description: Successful response
399
+ tags:
400
+ - UserController
401
+ description: |-
402
+ Delete user
403
+
404
+ **Required Roles:** ROLE_ADMIN
405
+ parameters:
406
+ - name: id
407
+ in: path
408
+ schema:
409
+ type: integer
410
+ format: int64
411
+ required: true
412
+ security:
413
+ - bearerAuth: []
414
+ x-required-roles:
415
+ - ROLE_ADMIN
416
+ /api/users/department/{departmentId}:
417
+ get:
418
+ summary: Get Users By Department
419
+ operationId: user_getUsersByDepartment
420
+ responses:
421
+ '200':
422
+ description: Successful response
423
+ content:
424
+ application/json:
425
+ schema:
426
+ type: array
427
+ items:
428
+ $ref: '#/components/schemas/UserDTO'
429
+ tags:
430
+ - UserController
431
+ description: Get users by department with optional status filter
432
+ parameters:
433
+ - name: departmentId
434
+ in: path
435
+ schema:
436
+ type: integer
437
+ format: int64
438
+ required: true
439
+ - name: status
440
+ in: query
441
+ schema:
442
+ type: string
443
+ - name: X-Tenant-ID
444
+ in: header
445
+ schema:
446
+ type: string
447
+ security:
448
+ - bearerAuth: []
449
+ /api/users/bulk:
450
+ post:
451
+ summary: Bulk Import Users
452
+ operationId: user_bulkImportUsers
453
+ responses:
454
+ '200':
455
+ description: Successful response
456
+ content:
457
+ application/json:
458
+ schema:
459
+ type: array
460
+ items:
461
+ $ref: '#/components/schemas/UserDTO'
462
+ tags:
463
+ - UserController
464
+ description: |-
465
+ Bulk import users
466
+
467
+ **Required Roles:** ROLE_ADMIN
468
+ requestBody:
469
+ required: true
470
+ content:
471
+ application/json:
472
+ schema:
473
+ type: array
474
+ items:
475
+ $ref: '#/components/schemas/CreateUserRequest'
476
+ security:
477
+ - bearerAuth: []
478
+ x-required-roles:
479
+ - ROLE_ADMIN
480
+ components:
481
+ schemas:
482
+ Filter:
483
+ type: object
484
+ description: Filter conditions
485
+ Sort:
486
+ type: object
487
+ description: Sort conditions
488
+ SearchParam:
489
+ type: object
490
+ description: Search parameters for pagination and filtering
491
+ properties:
492
+ offset:
493
+ type: integer
494
+ description: Pagination offset
495
+ limit:
496
+ type: integer
497
+ description: Pagination limit
498
+ filter:
499
+ $ref: '#/components/schemas/Filter'
500
+ sort:
501
+ $ref: '#/components/schemas/Sort'
502
+ UpdateUserRequest:
503
+ type: object
504
+ properties:
505
+ firstName:
506
+ type: string
507
+ lastName:
508
+ type: string
509
+ email:
510
+ type: string
511
+ pattern: ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
512
+ phoneNumber:
513
+ type: string
514
+ pattern: ^\\+?[1-9]\\d{1,14}$
515
+ departmentId:
516
+ type: integer
517
+ format: int64
518
+ status:
519
+ type: string
520
+ CreateUserRequest:
521
+ type: object
522
+ properties:
523
+ firstName:
524
+ type: string
525
+ lastName:
526
+ type: string
527
+ email:
528
+ type: string
529
+ pattern: ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
530
+ password:
531
+ type: string
532
+ phoneNumber:
533
+ type: string
534
+ pattern: ^\\+?[1-9]\\d{1,14}$
535
+ departmentId:
536
+ type: integer
537
+ format: int64
538
+ required:
539
+ - firstName
540
+ - lastName
541
+ - email
542
+ - password
543
+ - departmentId
544
+ UserDTO:
545
+ type: object
546
+ properties:
547
+ id:
548
+ type: integer
549
+ format: int64
550
+ firstName:
551
+ type: string
552
+ lastName:
553
+ type: string
554
+ email:
555
+ type: string
556
+ pattern: ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
557
+ phoneNumber:
558
+ type: string
559
+ pattern: ^\\+?[1-9]\\d{1,14}$
560
+ status:
561
+ type: string
562
+ createdAt:
563
+ type: string
564
+ format: date-time
565
+ updatedAt:
566
+ type: string
567
+ format: date-time
568
+ department:
569
+ $ref: '#/components/schemas/DepartmentDTO'
570
+ roles:
571
+ type: array
572
+ items:
573
+ $ref: '#/components/schemas/RoleDTO'
574
+ required:
575
+ - firstName
576
+ - lastName
577
+ - email
578
+ RoleDTO:
579
+ type: object
580
+ properties:
581
+ id:
582
+ type: integer
583
+ format: int64
584
+ name:
585
+ type: string
586
+ description:
587
+ type: string
588
+ permissions:
589
+ type: array
590
+ items:
591
+ type: string
592
+ DepartmentDTO:
593
+ type: object
594
+ properties:
595
+ id:
596
+ type: integer
597
+ format: int64
598
+ name:
599
+ type: string
600
+ description:
601
+ type: string
602
+ code:
603
+ type: string
604
+ PriceUpdateRequest:
605
+ type: object
606
+ properties:
607
+ productId:
608
+ type: integer
609
+ format: int64
610
+ newPrice:
611
+ type: number
612
+ ProductDTO:
613
+ type: object
614
+ properties:
615
+ id:
616
+ type: integer
617
+ format: int64
618
+ name:
619
+ type: string
620
+ description:
621
+ type: string
622
+ price:
623
+ type: number
624
+ stockQuantity:
625
+ type: integer
626
+ format: int32
627
+ sku:
628
+ type: string
629
+ category:
630
+ type: string
631
+ tags:
632
+ type: array
633
+ items:
634
+ type: string
635
+ active:
636
+ type: boolean
637
+ createdAt:
638
+ type: string
639
+ format: date-time
640
+ updatedAt:
641
+ type: string
642
+ format: date-time
643
+ required:
644
+ - name
645
+ - price
646
+ securitySchemes:
647
+ bearerAuth:
648
+ type: http
649
+ scheme: bearer
650
+ bearerFormat: JWT