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