@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.
- package/.claude/settings.local.json +22 -0
- package/CLAUDE.md +63 -0
- package/README.md +379 -0
- package/dist/analyzer/controllerAnalyzer.d.ts +20 -0
- package/dist/analyzer/controllerAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/controllerAnalyzer.js +101 -0
- package/dist/analyzer/controllerAnalyzer.js.map +1 -0
- package/dist/analyzer/parameterAnalyzer.d.ts +19 -0
- package/dist/analyzer/parameterAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/parameterAnalyzer.js +207 -0
- package/dist/analyzer/parameterAnalyzer.js.map +1 -0
- package/dist/analyzer/responseAnalyzer.d.ts +12 -0
- package/dist/analyzer/responseAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/responseAnalyzer.js +116 -0
- package/dist/analyzer/responseAnalyzer.js.map +1 -0
- package/dist/analyzer/schemaGenerator.d.ts +6 -0
- package/dist/analyzer/schemaGenerator.d.ts.map +1 -0
- package/dist/analyzer/schemaGenerator.js +347 -0
- package/dist/analyzer/schemaGenerator.js.map +1 -0
- package/dist/analyzer/securityAnalyzer.d.ts +6 -0
- package/dist/analyzer/securityAnalyzer.d.ts.map +1 -0
- package/dist/analyzer/securityAnalyzer.js +177 -0
- package/dist/analyzer/securityAnalyzer.js.map +1 -0
- package/dist/generator/openapiGenerator.d.ts +14 -0
- package/dist/generator/openapiGenerator.d.ts.map +1 -0
- package/dist/generator/openapiGenerator.js +340 -0
- package/dist/generator/openapiGenerator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +218 -0
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +61 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +199 -0
- package/dist/lib.js.map +1 -0
- package/dist/mcp-server.d.ts +9 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +257 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/mcp-server.mjs +45586 -0
- package/dist/parser/astAnalyzer.d.ts +87 -0
- package/dist/parser/astAnalyzer.d.ts.map +1 -0
- package/dist/parser/astAnalyzer.js +321 -0
- package/dist/parser/astAnalyzer.js.map +1 -0
- package/dist/parser/javaParser.d.ts +10 -0
- package/dist/parser/javaParser.d.ts.map +1 -0
- package/dist/parser/javaParser.js +805 -0
- package/dist/parser/javaParser.js.map +1 -0
- package/dist/types/index.d.ts +217 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/examples/CreateUserRequest.java +80 -0
- package/examples/DepartmentDTO.java +45 -0
- package/examples/Filter.java +39 -0
- package/examples/PaginatedList.java +71 -0
- package/examples/ProductController.java +136 -0
- package/examples/ProductDTO.java +129 -0
- package/examples/RoleDTO.java +47 -0
- package/examples/SearchParam.java +55 -0
- package/examples/Sort.java +70 -0
- package/examples/UpdateUserRequest.java +74 -0
- package/examples/UserController.java +98 -0
- package/examples/UserDTO.java +119 -0
- package/package.json +51 -0
- package/prompt/01_Initial.md +358 -0
- package/prompt/02_/354/266/224/352/260/200.md +31 -0
- package/src/analyzer/controllerAnalyzer.ts +125 -0
- package/src/analyzer/parameterAnalyzer.ts +259 -0
- package/src/analyzer/responseAnalyzer.ts +142 -0
- package/src/analyzer/schemaGenerator.ts +412 -0
- package/src/analyzer/securityAnalyzer.ts +200 -0
- package/src/generator/openapiGenerator.ts +378 -0
- package/src/index.ts +212 -0
- package/src/lib.ts +240 -0
- package/src/mcp-server.ts +310 -0
- package/src/parser/astAnalyzer.ts +373 -0
- package/src/parser/javaParser.ts +901 -0
- package/src/types/index.ts +238 -0
- package/test-boolean.yaml +607 -0
- package/test-filter.yaml +576 -0
- package/test-inner.ts +59 -0
- package/test-output.yaml +650 -0
- package/test-paginated.yaml +585 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +30 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.generateOpenAPISpec = generateOpenAPISpec;
|
|
37
|
+
exports.generateOpenAPISpecForController = generateOpenAPISpecForController;
|
|
38
|
+
exports.writeOpenAPISpec = writeOpenAPISpec;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const yaml = __importStar(require("js-yaml"));
|
|
41
|
+
const schemaGenerator_1 = require("../analyzer/schemaGenerator");
|
|
42
|
+
/**
|
|
43
|
+
* Generate OpenAPI YAML from analyzed controllers
|
|
44
|
+
*/
|
|
45
|
+
function generateOpenAPISpec(controllers, context, options) {
|
|
46
|
+
// Generate schemas for all referenced types
|
|
47
|
+
const schemas = (0, schemaGenerator_1.generateSchemas)(context);
|
|
48
|
+
// Build tags from controllers
|
|
49
|
+
const tags = controllers.map(controller => ({
|
|
50
|
+
name: controller.className,
|
|
51
|
+
description: controller.javaClass.javadoc || `Endpoints for ${controller.className}`,
|
|
52
|
+
}));
|
|
53
|
+
// Build paths
|
|
54
|
+
const paths = {};
|
|
55
|
+
for (const controller of controllers) {
|
|
56
|
+
for (const endpoint of controller.endpoints) {
|
|
57
|
+
const path = endpoint.path;
|
|
58
|
+
if (!paths[path]) {
|
|
59
|
+
paths[path] = {};
|
|
60
|
+
}
|
|
61
|
+
paths[path][endpoint.method] = buildOperation(endpoint, controller.className);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Convert schema Map to object
|
|
65
|
+
const schemaObject = {};
|
|
66
|
+
for (const [name, schema] of schemas) {
|
|
67
|
+
schemaObject[name] = schema;
|
|
68
|
+
}
|
|
69
|
+
// Build the spec
|
|
70
|
+
const spec = {
|
|
71
|
+
openapi: '3.0.0',
|
|
72
|
+
info: {
|
|
73
|
+
title: options.title,
|
|
74
|
+
version: options.version,
|
|
75
|
+
},
|
|
76
|
+
tags,
|
|
77
|
+
paths,
|
|
78
|
+
components: {
|
|
79
|
+
schemas: schemaObject,
|
|
80
|
+
securitySchemes: {
|
|
81
|
+
bearerAuth: {
|
|
82
|
+
type: 'http',
|
|
83
|
+
scheme: 'bearer',
|
|
84
|
+
bearerFormat: 'JWT',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
// Add servers if base path is specified
|
|
90
|
+
if (options.basePath) {
|
|
91
|
+
spec.servers = [{ url: `http://localhost:8080${options.basePath}` }];
|
|
92
|
+
}
|
|
93
|
+
return spec;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build operation object for an endpoint
|
|
97
|
+
*/
|
|
98
|
+
function buildOperation(endpoint, controllerName) {
|
|
99
|
+
const operation = {
|
|
100
|
+
summary: endpoint.summary,
|
|
101
|
+
operationId: endpoint.operationId,
|
|
102
|
+
responses: {},
|
|
103
|
+
};
|
|
104
|
+
// Add tag for controller grouping
|
|
105
|
+
if (controllerName) {
|
|
106
|
+
operation.tags = [controllerName];
|
|
107
|
+
}
|
|
108
|
+
// Build description with javadoc, @return, and security info
|
|
109
|
+
const descriptionParts = [];
|
|
110
|
+
if (endpoint.description) {
|
|
111
|
+
descriptionParts.push(endpoint.description);
|
|
112
|
+
}
|
|
113
|
+
// Add @return description from javadoc
|
|
114
|
+
if (endpoint.returnDescription) {
|
|
115
|
+
descriptionParts.push(`\n\n**Returns:** ${endpoint.returnDescription}`);
|
|
116
|
+
}
|
|
117
|
+
// Add security info to description
|
|
118
|
+
if (endpoint.security.roles.length > 0) {
|
|
119
|
+
descriptionParts.push(`\n\n**Required Roles:** ${endpoint.security.roles.join(', ')}`);
|
|
120
|
+
}
|
|
121
|
+
if (endpoint.security.securityExpression) {
|
|
122
|
+
descriptionParts.push(`\n\n**Security Expression:** \`${endpoint.security.securityExpression}\``);
|
|
123
|
+
}
|
|
124
|
+
if (descriptionParts.length > 0) {
|
|
125
|
+
operation.description = descriptionParts.join('');
|
|
126
|
+
}
|
|
127
|
+
// Add parameters
|
|
128
|
+
if (endpoint.parameters.length > 0) {
|
|
129
|
+
operation.parameters = endpoint.parameters.map(buildParameter);
|
|
130
|
+
}
|
|
131
|
+
// Add request body
|
|
132
|
+
if (endpoint.requestBody) {
|
|
133
|
+
operation.requestBody = buildRequestBody(endpoint.requestBody);
|
|
134
|
+
}
|
|
135
|
+
// Add responses
|
|
136
|
+
for (const response of endpoint.responses) {
|
|
137
|
+
operation.responses[response.statusCode] = buildResponse(response);
|
|
138
|
+
}
|
|
139
|
+
// Add security
|
|
140
|
+
if (endpoint.security.roles.length > 0 || endpoint.security.authorities.length > 0) {
|
|
141
|
+
operation.security = [{ bearerAuth: [] }];
|
|
142
|
+
}
|
|
143
|
+
// Add x-required-roles
|
|
144
|
+
if (endpoint.security.roles.length > 0) {
|
|
145
|
+
operation['x-required-roles'] = endpoint.security.roles;
|
|
146
|
+
}
|
|
147
|
+
// Add x-security-expression for complex expressions
|
|
148
|
+
if (endpoint.security.hasComplexExpression && endpoint.security.securityExpression) {
|
|
149
|
+
operation['x-security-expression'] = endpoint.security.securityExpression;
|
|
150
|
+
}
|
|
151
|
+
return operation;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Build parameter object
|
|
155
|
+
*/
|
|
156
|
+
function buildParameter(param) {
|
|
157
|
+
const parameter = {
|
|
158
|
+
name: param.name,
|
|
159
|
+
in: param.in,
|
|
160
|
+
schema: param.schema || { type: param.type },
|
|
161
|
+
};
|
|
162
|
+
if (param.required) {
|
|
163
|
+
parameter.required = true;
|
|
164
|
+
}
|
|
165
|
+
if (param.description) {
|
|
166
|
+
parameter.description = param.description;
|
|
167
|
+
}
|
|
168
|
+
return parameter;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Build request body object
|
|
172
|
+
*/
|
|
173
|
+
function buildRequestBody(requestBody) {
|
|
174
|
+
const body = {
|
|
175
|
+
required: requestBody.required,
|
|
176
|
+
content: {
|
|
177
|
+
[requestBody.contentType]: {
|
|
178
|
+
schema: requestBody.schema,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
// Add description from @param javadoc if available
|
|
183
|
+
if (requestBody.description) {
|
|
184
|
+
body.description = requestBody.description;
|
|
185
|
+
}
|
|
186
|
+
return body;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Build response object
|
|
190
|
+
*/
|
|
191
|
+
function buildResponse(response) {
|
|
192
|
+
const responseObj = {
|
|
193
|
+
description: response.description,
|
|
194
|
+
};
|
|
195
|
+
// Add headers
|
|
196
|
+
if (response.headers) {
|
|
197
|
+
responseObj.headers = {};
|
|
198
|
+
for (const [name, header] of Object.entries(response.headers)) {
|
|
199
|
+
responseObj.headers[name] = {
|
|
200
|
+
schema: header.schema,
|
|
201
|
+
description: header.description,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// Add content
|
|
206
|
+
if (response.contentType && response.schema) {
|
|
207
|
+
responseObj.content = {
|
|
208
|
+
[response.contentType]: {
|
|
209
|
+
schema: response.schema,
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return responseObj;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Recursively extract all $ref types from a schema
|
|
217
|
+
*/
|
|
218
|
+
function extractRefsFromSchema(schema, refs) {
|
|
219
|
+
if (!schema || typeof schema !== 'object') {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
// Direct $ref
|
|
223
|
+
if (schema.$ref && typeof schema.$ref === 'string') {
|
|
224
|
+
const typeName = schema.$ref.replace('#/components/schemas/', '');
|
|
225
|
+
refs.add(typeName);
|
|
226
|
+
}
|
|
227
|
+
// Array items
|
|
228
|
+
if (schema.items) {
|
|
229
|
+
extractRefsFromSchema(schema.items, refs);
|
|
230
|
+
}
|
|
231
|
+
// Object properties
|
|
232
|
+
if (schema.properties) {
|
|
233
|
+
for (const prop of Object.values(schema.properties)) {
|
|
234
|
+
extractRefsFromSchema(prop, refs);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
// additionalProperties
|
|
238
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
239
|
+
extractRefsFromSchema(schema.additionalProperties, refs);
|
|
240
|
+
}
|
|
241
|
+
// allOf, anyOf, oneOf
|
|
242
|
+
for (const key of ['allOf', 'anyOf', 'oneOf']) {
|
|
243
|
+
if (Array.isArray(schema[key])) {
|
|
244
|
+
for (const subSchema of schema[key]) {
|
|
245
|
+
extractRefsFromSchema(subSchema, refs);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Generate OpenAPI spec for a single controller
|
|
252
|
+
*/
|
|
253
|
+
function generateOpenAPISpecForController(controller, context, options) {
|
|
254
|
+
// Create a temporary context with only this controller to generate relevant schemas
|
|
255
|
+
const singleControllerContext = {
|
|
256
|
+
javaClasses: context.javaClasses,
|
|
257
|
+
controllers: [controller],
|
|
258
|
+
dtoSchemas: new Map(),
|
|
259
|
+
referencedTypes: new Set(),
|
|
260
|
+
};
|
|
261
|
+
// Collect referenced types from this controller's endpoints
|
|
262
|
+
for (const endpoint of controller.endpoints) {
|
|
263
|
+
// Extract refs from request body schema (including nested refs like array items)
|
|
264
|
+
if (endpoint.requestBody?.schema) {
|
|
265
|
+
extractRefsFromSchema(endpoint.requestBody.schema, singleControllerContext.referencedTypes);
|
|
266
|
+
}
|
|
267
|
+
// Extract refs from response schemas
|
|
268
|
+
for (const response of endpoint.responses) {
|
|
269
|
+
if (response.schema) {
|
|
270
|
+
extractRefsFromSchema(response.schema, singleControllerContext.referencedTypes);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Extract refs from parameter schemas
|
|
274
|
+
for (const param of endpoint.parameters) {
|
|
275
|
+
if (param.schema) {
|
|
276
|
+
extractRefsFromSchema(param.schema, singleControllerContext.referencedTypes);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Generate schemas for referenced types
|
|
281
|
+
const schemas = (0, schemaGenerator_1.generateSchemas)(singleControllerContext);
|
|
282
|
+
// Build paths for this controller only
|
|
283
|
+
const paths = {};
|
|
284
|
+
for (const endpoint of controller.endpoints) {
|
|
285
|
+
const path = endpoint.path;
|
|
286
|
+
if (!paths[path]) {
|
|
287
|
+
paths[path] = {};
|
|
288
|
+
}
|
|
289
|
+
paths[path][endpoint.method] = buildOperation(endpoint, controller.className);
|
|
290
|
+
}
|
|
291
|
+
// Build tag for this controller
|
|
292
|
+
const tags = [{
|
|
293
|
+
name: controller.className,
|
|
294
|
+
description: controller.javaClass.javadoc || `Endpoints for ${controller.className}`,
|
|
295
|
+
}];
|
|
296
|
+
// Convert schema Map to object
|
|
297
|
+
const schemaObject = {};
|
|
298
|
+
for (const [name, schema] of schemas) {
|
|
299
|
+
schemaObject[name] = schema;
|
|
300
|
+
}
|
|
301
|
+
// Build the spec with controller name as title
|
|
302
|
+
const spec = {
|
|
303
|
+
openapi: '3.0.0',
|
|
304
|
+
info: {
|
|
305
|
+
title: controller.className,
|
|
306
|
+
version: options.version,
|
|
307
|
+
},
|
|
308
|
+
tags,
|
|
309
|
+
paths,
|
|
310
|
+
components: {
|
|
311
|
+
schemas: schemaObject,
|
|
312
|
+
securitySchemes: {
|
|
313
|
+
bearerAuth: {
|
|
314
|
+
type: 'http',
|
|
315
|
+
scheme: 'bearer',
|
|
316
|
+
bearerFormat: 'JWT',
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
// Add servers if base path is specified
|
|
322
|
+
if (options.basePath) {
|
|
323
|
+
spec.servers = [{ url: `http://localhost:8080${options.basePath}` }];
|
|
324
|
+
}
|
|
325
|
+
return spec;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Write OpenAPI spec to YAML file
|
|
329
|
+
*/
|
|
330
|
+
function writeOpenAPISpec(spec, outputPath) {
|
|
331
|
+
const yamlContent = yaml.dump(spec, {
|
|
332
|
+
indent: 2,
|
|
333
|
+
lineWidth: -1,
|
|
334
|
+
noRefs: true,
|
|
335
|
+
sortKeys: false,
|
|
336
|
+
});
|
|
337
|
+
fs.writeFileSync(outputPath, yamlContent, 'utf-8');
|
|
338
|
+
console.log(` Written: ${outputPath}`);
|
|
339
|
+
}
|
|
340
|
+
//# sourceMappingURL=openapiGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapiGenerator.js","sourceRoot":"","sources":["../../src/generator/openapiGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,kDA8DC;AAgMD,4EAuFC;AAKD,4CAUC;AAzXD,uCAAyB;AACzB,8CAAgC;AAehC,iEAA8D;AAE9D;;GAEG;AACH,SAAgB,mBAAmB,CACjC,WAA6B,EAC7B,OAA0B,EAC1B,OAAmB;IAEnB,4CAA4C;IAC5C,MAAM,OAAO,GAAG,IAAA,iCAAe,EAAC,OAAO,CAAC,CAAC;IAEzC,8BAA8B;IAC9B,MAAM,IAAI,GAAc,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,EAAE,UAAU,CAAC,SAAS;QAC1B,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,OAAO,IAAI,iBAAiB,UAAU,CAAC,SAAS,EAAE;KACrF,CAAC,CAAC,CAAC;IAEJ,cAAc;IACd,MAAM,KAAK,GAA6B,EAAE,CAAC;IAE3C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;YAE3B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjB,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACnB,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;QAChF,CAAC;IACH,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CAAC,CAAC;IAEH,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;IACnD,OAAO,CAAC,GAAG,CAAC,cAAc,UAAU,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const javaParser_1 = require("./parser/javaParser");
|
|
41
|
+
const controllerAnalyzer_1 = require("./analyzer/controllerAnalyzer");
|
|
42
|
+
const openapiGenerator_1 = require("./generator/openapiGenerator");
|
|
43
|
+
const program = new commander_1.Command();
|
|
44
|
+
// Helper to collect multiple values for an option
|
|
45
|
+
function collect(value, previous) {
|
|
46
|
+
return previous.concat([value]);
|
|
47
|
+
}
|
|
48
|
+
program
|
|
49
|
+
.name('spring-to-openapi')
|
|
50
|
+
.description('Generate OpenAPI v3 YAML from Spring Boot Java source code')
|
|
51
|
+
.version('1.0.0')
|
|
52
|
+
.requiredOption('-s, --source <path...>', 'Java source code directory path(s) (can be specified multiple times)', collect, [])
|
|
53
|
+
.option('-a, --api-source <path>', 'Directory to search for RestControllers (defaults to first --source)')
|
|
54
|
+
.option('-o, --output <path>', 'Output YAML file path (generates single combined file)')
|
|
55
|
+
.option('-d, --out-dir <path>', 'Output directory path (generates separate YAML per controller)')
|
|
56
|
+
.option('-t, --title <title>', 'API title', 'API Documentation')
|
|
57
|
+
.option('--api-version <version>', 'API version', '1.0.0')
|
|
58
|
+
.option('-b, --base-path <path>', 'API base path')
|
|
59
|
+
.action(async (options) => {
|
|
60
|
+
try {
|
|
61
|
+
await run(options);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
console.error('Error:', error instanceof Error ? error.message : error);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
async function run(options) {
|
|
69
|
+
const startTime = Date.now();
|
|
70
|
+
// Validate output options
|
|
71
|
+
if (!options.output && !options.outDir) {
|
|
72
|
+
options.output = 'openapi.yaml'; // default to single file
|
|
73
|
+
}
|
|
74
|
+
if (options.output && options.outDir) {
|
|
75
|
+
console.error('Error: Cannot use both --output and --out-dir. Choose one output mode.');
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
// Normalize source to array
|
|
79
|
+
const sources = Array.isArray(options.source) ? options.source : [options.source];
|
|
80
|
+
if (sources.length === 0) {
|
|
81
|
+
console.error('Error: At least one --source path is required.');
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
// Normalize options
|
|
85
|
+
const cliOptions = {
|
|
86
|
+
source: sources,
|
|
87
|
+
apiSource: options.apiSource, // Optional: specific directory for RestController search
|
|
88
|
+
output: options.output,
|
|
89
|
+
outDir: options.outDir,
|
|
90
|
+
title: options.title,
|
|
91
|
+
version: options.apiVersion,
|
|
92
|
+
basePath: options.basePath,
|
|
93
|
+
};
|
|
94
|
+
const isDirectoryMode = !!cliOptions.outDir;
|
|
95
|
+
console.log('='.repeat(60));
|
|
96
|
+
console.log('Spring Boot to OpenAPI Generator');
|
|
97
|
+
console.log('='.repeat(60));
|
|
98
|
+
if (cliOptions.source.length === 1) {
|
|
99
|
+
console.log(`\nSource directory: ${cliOptions.source[0]}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.log(`\nSource directories:`);
|
|
103
|
+
for (const src of cliOptions.source) {
|
|
104
|
+
console.log(` - ${src}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (cliOptions.apiSource) {
|
|
108
|
+
console.log(`API source directory: ${cliOptions.apiSource} (RestController search)`);
|
|
109
|
+
}
|
|
110
|
+
if (isDirectoryMode) {
|
|
111
|
+
console.log(`Output directory: ${cliOptions.outDir} (per-controller mode)`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.log(`Output file: ${cliOptions.output}`);
|
|
115
|
+
}
|
|
116
|
+
console.log(`API title: ${cliOptions.title}`);
|
|
117
|
+
console.log(`API version: ${cliOptions.version}`);
|
|
118
|
+
if (cliOptions.basePath) {
|
|
119
|
+
console.log(`Base path: ${cliOptions.basePath}`);
|
|
120
|
+
}
|
|
121
|
+
console.log();
|
|
122
|
+
// Resolve paths
|
|
123
|
+
const sourcePaths = cliOptions.source.map(s => path.resolve(s));
|
|
124
|
+
const apiSourcePath = cliOptions.apiSource ? path.resolve(cliOptions.apiSource) : undefined;
|
|
125
|
+
// Step 1: Parse Java files from all source directories
|
|
126
|
+
console.log('Step 1: Parsing Java source files...');
|
|
127
|
+
const javaClasses = new Map();
|
|
128
|
+
for (const sourcePath of sourcePaths) {
|
|
129
|
+
const classes = await (0, javaParser_1.parseJavaSource)(sourcePath);
|
|
130
|
+
console.log(` Found ${classes.size} class(es) in ${sourcePath}`);
|
|
131
|
+
// Merge classes (later sources override earlier ones for same class name)
|
|
132
|
+
for (const [name, cls] of classes) {
|
|
133
|
+
javaClasses.set(name, cls);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
console.log(` Total: ${javaClasses.size} Java class(es)`);
|
|
137
|
+
if (javaClasses.size === 0) {
|
|
138
|
+
console.warn('Warning: No Java files found in the specified directory.');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Step 2: Initialize processing context
|
|
142
|
+
const context = {
|
|
143
|
+
javaClasses,
|
|
144
|
+
controllers: [],
|
|
145
|
+
dtoSchemas: new Map(),
|
|
146
|
+
referencedTypes: new Set(),
|
|
147
|
+
apiSourcePath, // Pass apiSourcePath to filter RestControllers
|
|
148
|
+
};
|
|
149
|
+
// Step 3: Analyze controllers
|
|
150
|
+
console.log('\nStep 2: Analyzing REST controllers...');
|
|
151
|
+
const controllers = (0, controllerAnalyzer_1.analyzeControllers)(context);
|
|
152
|
+
context.controllers = controllers;
|
|
153
|
+
const totalEndpoints = controllers.reduce((sum, c) => sum + c.endpoints.length, 0);
|
|
154
|
+
console.log(`\n Found ${controllers.length} controller(s) with ${totalEndpoints} endpoint(s)`);
|
|
155
|
+
if (controllers.length === 0) {
|
|
156
|
+
console.warn('Warning: No REST controllers found in the source files.');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// Step 4: Generate and write OpenAPI spec(s)
|
|
160
|
+
console.log('\nStep 3: Generating OpenAPI specification...');
|
|
161
|
+
if (isDirectoryMode) {
|
|
162
|
+
// Directory mode: generate separate YAML file per controller
|
|
163
|
+
const outDirPath = path.resolve(cliOptions.outDir);
|
|
164
|
+
// Create output directory if it doesn't exist
|
|
165
|
+
if (!fs.existsSync(outDirPath)) {
|
|
166
|
+
fs.mkdirSync(outDirPath, { recursive: true });
|
|
167
|
+
}
|
|
168
|
+
console.log('\nStep 4: Writing YAML files (per controller)...');
|
|
169
|
+
let totalSchemas = 0;
|
|
170
|
+
for (const controller of controllers) {
|
|
171
|
+
const spec = (0, openapiGenerator_1.generateOpenAPISpecForController)(controller, context, cliOptions);
|
|
172
|
+
const fileName = `${controller.className}.yaml`;
|
|
173
|
+
const outputPath = path.join(outDirPath, fileName);
|
|
174
|
+
(0, openapiGenerator_1.writeOpenAPISpec)(spec, outputPath);
|
|
175
|
+
totalSchemas += Object.keys(spec.components.schemas).length;
|
|
176
|
+
}
|
|
177
|
+
const endTime = Date.now();
|
|
178
|
+
console.log(`\nCompleted in ${endTime - startTime}ms`);
|
|
179
|
+
console.log('='.repeat(60));
|
|
180
|
+
// Print summary
|
|
181
|
+
console.log('\nSummary:');
|
|
182
|
+
console.log(` Controllers: ${controllers.length}`);
|
|
183
|
+
console.log(` Endpoints: ${totalEndpoints}`);
|
|
184
|
+
console.log(` Files generated: ${controllers.length}`);
|
|
185
|
+
// Print generated files
|
|
186
|
+
console.log('\nGenerated files:');
|
|
187
|
+
for (const controller of controllers) {
|
|
188
|
+
const endpointCount = controller.endpoints.length;
|
|
189
|
+
console.log(` ${controller.className}.yaml (${endpointCount} endpoint${endpointCount !== 1 ? 's' : ''})`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
// Single file mode: generate combined YAML
|
|
194
|
+
const spec = (0, openapiGenerator_1.generateOpenAPISpec)(controllers, context, cliOptions);
|
|
195
|
+
const outputPath = path.resolve(cliOptions.output);
|
|
196
|
+
console.log('\nStep 4: Writing YAML output...');
|
|
197
|
+
(0, openapiGenerator_1.writeOpenAPISpec)(spec, outputPath);
|
|
198
|
+
const endTime = Date.now();
|
|
199
|
+
console.log(`\nCompleted in ${endTime - startTime}ms`);
|
|
200
|
+
console.log('='.repeat(60));
|
|
201
|
+
// Print summary
|
|
202
|
+
console.log('\nSummary:');
|
|
203
|
+
console.log(` Controllers: ${controllers.length}`);
|
|
204
|
+
console.log(` Endpoints: ${totalEndpoints}`);
|
|
205
|
+
console.log(` Schemas: ${Object.keys(spec.components.schemas).length}`);
|
|
206
|
+
// Print endpoints by path
|
|
207
|
+
console.log('\nEndpoints:');
|
|
208
|
+
const paths = Object.keys(spec.paths).sort();
|
|
209
|
+
for (const p of paths) {
|
|
210
|
+
const methods = Object.keys(spec.paths[p]).sort();
|
|
211
|
+
for (const method of methods) {
|
|
212
|
+
console.log(` ${method.toUpperCase().padEnd(7)} ${p}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
program.parse();
|
|
218
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAAoC;AACpC,uCAAyB;AACzB,2CAA6B;AAE7B,oDAAsD;AACtD,sEAAmE;AACnE,mEAAuH;AAEvH,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,kDAAkD;AAClD,SA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AAC,kBAAkB,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,gBAAgB,cAAc,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAEzE,0BAA0B;QAC1B,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC7B,OAAO,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library entry point for programmatic API generation
|
|
3
|
+
* This module exports the core functionality for use by MCP server and other integrations
|
|
4
|
+
*/
|
|
5
|
+
import { OpenAPISpec } from './types';
|
|
6
|
+
export interface GenerateOptions {
|
|
7
|
+
/** Java source directories to parse */
|
|
8
|
+
source: string[];
|
|
9
|
+
/** Optional: specific directory to search for RestControllers */
|
|
10
|
+
apiSource?: string;
|
|
11
|
+
/** API title */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** API version */
|
|
14
|
+
version?: string;
|
|
15
|
+
/** API base path */
|
|
16
|
+
basePath?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GenerateResult {
|
|
19
|
+
/** Generated OpenAPI spec object */
|
|
20
|
+
spec: OpenAPISpec;
|
|
21
|
+
/** YAML string of the spec */
|
|
22
|
+
yaml: string;
|
|
23
|
+
/** Summary information */
|
|
24
|
+
summary: {
|
|
25
|
+
controllerCount: number;
|
|
26
|
+
endpointCount: number;
|
|
27
|
+
schemaCount: number;
|
|
28
|
+
controllers: Array<{
|
|
29
|
+
name: string;
|
|
30
|
+
endpointCount: number;
|
|
31
|
+
}>;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export interface GeneratePerControllerResult {
|
|
35
|
+
/** Map of controller name to generated spec */
|
|
36
|
+
specs: Map<string, {
|
|
37
|
+
spec: OpenAPISpec;
|
|
38
|
+
yaml: string;
|
|
39
|
+
}>;
|
|
40
|
+
/** Summary information */
|
|
41
|
+
summary: {
|
|
42
|
+
controllerCount: number;
|
|
43
|
+
totalEndpointCount: number;
|
|
44
|
+
controllers: Array<{
|
|
45
|
+
name: string;
|
|
46
|
+
endpointCount: number;
|
|
47
|
+
schemaCount: number;
|
|
48
|
+
}>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generate OpenAPI specification from Spring Boot Java source code
|
|
53
|
+
* Returns a single combined spec for all controllers
|
|
54
|
+
*/
|
|
55
|
+
export declare function generateOpenAPI(options: GenerateOptions): Promise<GenerateResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Generate separate OpenAPI specifications per controller
|
|
58
|
+
*/
|
|
59
|
+
export declare function generateOpenAPIPerController(options: GenerateOptions): Promise<GeneratePerControllerResult>;
|
|
60
|
+
export type { CLIOptions, ProcessingContext, OpenAPISpec, ControllerInfo } from './types';
|
|
61
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],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