@vinkius-core/mcp-fusion-openapi-gen 1.0.1 → 1.1.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/README.md +38 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/parser/OpenApiParser.d.ts +5 -2
- package/dist/parser/OpenApiParser.d.ts.map +1 -1
- package/dist/parser/OpenApiParser.js +13 -5
- package/dist/parser/OpenApiParser.js.map +1 -1
- package/dist/parser/Swagger2Converter.d.ts +30 -0
- package/dist/parser/Swagger2Converter.d.ts.map +1 -0
- package/dist/parser/Swagger2Converter.js +197 -0
- package/dist/parser/Swagger2Converter.js.map +1 -0
- package/package.json +69 -69
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<h1 align="center">@vinkius-core/mcp-fusion-openapi-gen</h1>
|
|
3
3
|
<p align="center">
|
|
4
|
-
<strong>OpenAPI 3.x → MCP Fusion Server Generator</strong> — Parse any spec, generate a complete MCP server
|
|
4
|
+
<strong>OpenAPI 3.x / Swagger 2.0 → MCP Fusion Server Generator</strong> — Parse any spec, generate a complete MCP server
|
|
5
5
|
</p>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
> Parse any OpenAPI 3.x spec and generate a **complete, ready-to-run MCP Server** powered by MCP Fusion — with Presenters, Tools, ToolRegistry, and server bootstrap. All features configurable via YAML.
|
|
16
|
+
> Parse any **OpenAPI 3.x** or **Swagger 2.0** spec and generate a **complete, ready-to-run MCP Server** powered by MCP Fusion — with Presenters, Tools, ToolRegistry, and server bootstrap. All features configurable via YAML.
|
|
17
17
|
|
|
18
18
|
## What It Generates
|
|
19
19
|
|
|
@@ -97,10 +97,45 @@ for (const file of files) {
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
## Swagger 2.0 Support
|
|
101
|
+
|
|
102
|
+
Swagger 2.0 specs are **automatically detected and converted** to OpenAPI 3.0 internally. No extra configuration needed — just point to your spec:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Works with Swagger 2.0 specs out of the box
|
|
106
|
+
npx openapi-gen --input ./petstore-v2.json --output ./generated
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The converter handles:
|
|
110
|
+
|
|
111
|
+
| Swagger 2.0 | → OpenAPI 3.0 |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `host` + `basePath` + `schemes` | `servers` array |
|
|
114
|
+
| `definitions` | `components.schemas` |
|
|
115
|
+
| `parameters[in: body]` | `requestBody` |
|
|
116
|
+
| `parameters[in: formData]` | `requestBody` (multipart) |
|
|
117
|
+
| `#/definitions/Pet` | `#/components/schemas/Pet` |
|
|
118
|
+
| `produces` / `consumes` | Per-operation `content` types |
|
|
119
|
+
|
|
120
|
+
Runtime mode (`loadOpenAPI()`) also accepts Swagger 2.0:
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { loadOpenAPI } from '@vinkius-core/mcp-fusion-openapi-gen';
|
|
124
|
+
|
|
125
|
+
// Swagger 2.0 JSON — auto-converted internally
|
|
126
|
+
const tools = loadOpenAPI(swagger2Json, { baseUrl: 'https://petstore.swagger.io/v2' });
|
|
127
|
+
registry.registerAll(...tools);
|
|
128
|
+
```
|
|
129
|
+
|
|
100
130
|
## Pipeline
|
|
101
131
|
|
|
102
132
|
```
|
|
103
|
-
OpenAPI 3.x Spec (YAML/JSON)
|
|
133
|
+
OpenAPI 3.x / Swagger 2.0 Spec (YAML/JSON)
|
|
134
|
+
│
|
|
135
|
+
▼
|
|
136
|
+
┌──────────────────┐
|
|
137
|
+
│ Swagger2Converter │ → Auto-detect & convert 2.0 → 3.0 (if needed)
|
|
138
|
+
└──────────────────┘
|
|
104
139
|
│
|
|
105
140
|
▼
|
|
106
141
|
┌─────────────┐
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type { CliOverrides } from './config/ConfigLoader.js';
|
|
|
21
21
|
export { parseOpenAPI } from './parser/OpenApiParser.js';
|
|
22
22
|
export type { ApiSpec, ApiGroup, ApiAction, ApiParam, ApiResponseSchema, ApiServer, SchemaNode, } from './parser/types.js';
|
|
23
23
|
export { resolveRefs } from './parser/RefResolver.js';
|
|
24
|
+
export { isSwagger2, convertSwagger2ToV3 } from './parser/Swagger2Converter.js';
|
|
24
25
|
export { compileZod, compileInputSchema, compileResponseSchema } from './schema/ZodCompiler.js';
|
|
25
26
|
export { mapEndpoints, inferAnnotations } from './mapper/EndpointMapper.js';
|
|
26
27
|
export { emitFiles } from './emitter/CodeEmitter.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC1E,YAAY,EACR,eAAe,EAAE,YAAY,EAAE,YAAY,EAC3C,aAAa,EAAE,YAAY,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EACR,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EACtC,iBAAiB,EAAE,SAAS,EAAE,UAAU,GAC3C,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"A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} from './config/ConfigLoader.js';
|
|
|
20
20
|
// ── Parser ───────────────────────────────────────────────
|
|
21
21
|
export { parseOpenAPI } from './parser/OpenApiParser.js';
|
|
22
22
|
export { resolveRefs } from './parser/RefResolver.js';
|
|
23
|
+
export { isSwagger2, convertSwagger2ToV3 } from './parser/Swagger2Converter.js';
|
|
23
24
|
// ── Zod Compiler ─────────────────────────────────────────
|
|
24
25
|
export { compileZod, compileInputSchema, compileResponseSchema } from './schema/ZodCompiler.js';
|
|
25
26
|
// ── Endpoint Mapper ──────────────────────────────────────
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAK1E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGzE,4DAA4D;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAK1E,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGzE,4DAA4D;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAKzD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEhF,4DAA4D;AAC5D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhG,4DAA4D;AAC5D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,4DAA4D;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEtF,4DAA4D;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { ApiSpec, ApiGroup, ApiAction, ApiParam, ApiResponseSchema, ApiServer, SchemaNode } from './types.js';
|
|
2
2
|
export type { ApiSpec, ApiGroup, ApiAction, ApiParam, ApiResponseSchema, ApiServer, SchemaNode };
|
|
3
3
|
/**
|
|
4
|
-
* Parse an OpenAPI 3.x specification into the normalized IR.
|
|
4
|
+
* Parse an OpenAPI 3.x or Swagger 2.0 specification into the normalized IR.
|
|
5
|
+
*
|
|
6
|
+
* Swagger 2.0 documents are automatically converted to OpenAPI 3.0
|
|
7
|
+
* format before processing.
|
|
5
8
|
*
|
|
6
9
|
* @param input - YAML string, JSON string, or pre-parsed object
|
|
7
10
|
* @returns Normalized {@link ApiSpec}
|
|
8
|
-
* @throws If the input is not a valid OpenAPI
|
|
11
|
+
* @throws If the input is not a valid OpenAPI document
|
|
9
12
|
*/
|
|
10
13
|
export declare function parseOpenAPI(input: string | object): ApiSpec;
|
|
11
14
|
//# sourceMappingURL=OpenApiParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiParser.d.ts","sourceRoot":"","sources":["../../src/parser/OpenApiParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpenApiParser.d.ts","sourceRoot":"","sources":["../../src/parser/OpenApiParser.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACR,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EACtC,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAC3C,MAAM,YAAY,CAAC;AAIpB,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AAiDjG;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAyG5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenApiParser — OpenAPI 3.x → IR Converter
|
|
2
|
+
* OpenApiParser — OpenAPI 3.x / Swagger 2.0 → IR Converter
|
|
3
3
|
*
|
|
4
4
|
* Accepts YAML or JSON input (string or pre-parsed object) and produces
|
|
5
5
|
* a normalized {@link ApiSpec} intermediate representation. Resolves all
|
|
@@ -10,21 +10,29 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { parse as parseYaml } from 'yaml';
|
|
12
12
|
import { resolveRefs } from './RefResolver.js';
|
|
13
|
+
import { isSwagger2, convertSwagger2ToV3 } from './Swagger2Converter.js';
|
|
13
14
|
// ── HTTP Methods ─────────────────────────────────────────
|
|
14
15
|
const HTTP_METHODS = new Set(['get', 'post', 'put', 'patch', 'delete', 'head', 'options', 'trace']);
|
|
15
16
|
// ── Parser ───────────────────────────────────────────────
|
|
16
17
|
/**
|
|
17
|
-
* Parse an OpenAPI 3.x specification into the normalized IR.
|
|
18
|
+
* Parse an OpenAPI 3.x or Swagger 2.0 specification into the normalized IR.
|
|
19
|
+
*
|
|
20
|
+
* Swagger 2.0 documents are automatically converted to OpenAPI 3.0
|
|
21
|
+
* format before processing.
|
|
18
22
|
*
|
|
19
23
|
* @param input - YAML string, JSON string, or pre-parsed object
|
|
20
24
|
* @returns Normalized {@link ApiSpec}
|
|
21
|
-
* @throws If the input is not a valid OpenAPI
|
|
25
|
+
* @throws If the input is not a valid OpenAPI document
|
|
22
26
|
*/
|
|
23
27
|
export function parseOpenAPI(input) {
|
|
24
|
-
|
|
28
|
+
let raw = typeof input === 'string' ? parseInput(input) : input;
|
|
29
|
+
// Auto-convert Swagger 2.0 → OpenAPI 3.0
|
|
30
|
+
if (isSwagger2(raw)) {
|
|
31
|
+
raw = convertSwagger2ToV3(raw);
|
|
32
|
+
}
|
|
25
33
|
// Validate OpenAPI version
|
|
26
34
|
if (!raw.openapi?.startsWith('3.')) {
|
|
27
|
-
throw new Error(`Unsupported OpenAPI version: "${raw.openapi ?? 'missing'}".
|
|
35
|
+
throw new Error(`Unsupported OpenAPI version: "${raw.openapi ?? 'missing'}". OpenAPI 3.x or Swagger 2.0 required.`);
|
|
28
36
|
}
|
|
29
37
|
// Resolve all $ref pointers in-place
|
|
30
38
|
resolveRefs(raw);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiParser.js","sourceRoot":"","sources":["../../src/parser/OpenApiParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"OpenApiParser.js","sourceRoot":"","sources":["../../src/parser/OpenApiParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAmDzE,4DAA4D;AAE5D,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,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Y,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,OAAO,YAAY,EAAE,MAAgC,CAAC;AAC1D,CAAC;AAED,+BAA+B;AAC/B,SAAS,gBAAgB,CAAC,GAA4C;IAClE,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IAEpB,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,kBAAkB,CAAC,EAAE,MAAgC,CAAC;QACxF,SAAS,CAAC,IAAI,CAAC;YACX,UAAU;YACV,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACtE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swagger2Converter — Swagger 2.0 → OpenAPI 3.0 Adapter
|
|
3
|
+
*
|
|
4
|
+
* Converts a Swagger 2.0 document into an OpenAPI 3.0-compatible
|
|
5
|
+
* structure so the existing parser can handle both versions.
|
|
6
|
+
*
|
|
7
|
+
* Handles:
|
|
8
|
+
* - `host` + `basePath` + `schemes` → `servers`
|
|
9
|
+
* - `definitions` → `components.schemas`
|
|
10
|
+
* - `parameters` with `in: body` → `requestBody`
|
|
11
|
+
* - `produces`/`consumes` → per-operation `content` types
|
|
12
|
+
* - `$ref` prefix rewrite (`#/definitions/` → `#/components/schemas/`)
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
type AnyObj = Record<string, any>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns `true` if the input looks like a Swagger 2.0 document.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isSwagger2(raw: Record<string, unknown>): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a Swagger 2.0 document into an OpenAPI 3.0-equivalent object.
|
|
23
|
+
*
|
|
24
|
+
* The output is NOT a valid 3.0 spec in every edge case, but it is
|
|
25
|
+
* structurally close enough for the existing parser to produce a
|
|
26
|
+
* correct {@link ApiSpec} IR.
|
|
27
|
+
*/
|
|
28
|
+
export declare function convertSwagger2ToV3(raw: Record<string, unknown>): AnyObj;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=Swagger2Converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swagger2Converter.d.ts","sourceRoot":"","sources":["../../src/parser/Swagger2Converter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAgDH,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAIlC;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAGhE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAiBxE"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swagger2Converter — Swagger 2.0 → OpenAPI 3.0 Adapter
|
|
3
|
+
*
|
|
4
|
+
* Converts a Swagger 2.0 document into an OpenAPI 3.0-compatible
|
|
5
|
+
* structure so the existing parser can handle both versions.
|
|
6
|
+
*
|
|
7
|
+
* Handles:
|
|
8
|
+
* - `host` + `basePath` + `schemes` → `servers`
|
|
9
|
+
* - `definitions` → `components.schemas`
|
|
10
|
+
* - `parameters` with `in: body` → `requestBody`
|
|
11
|
+
* - `produces`/`consumes` → per-operation `content` types
|
|
12
|
+
* - `$ref` prefix rewrite (`#/definitions/` → `#/components/schemas/`)
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
// ── Public ───────────────────────────────────────────────
|
|
17
|
+
/**
|
|
18
|
+
* Returns `true` if the input looks like a Swagger 2.0 document.
|
|
19
|
+
*/
|
|
20
|
+
export function isSwagger2(raw) {
|
|
21
|
+
const ver = raw['swagger'];
|
|
22
|
+
return typeof ver === 'string' && ver.startsWith('2.');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Convert a Swagger 2.0 document into an OpenAPI 3.0-equivalent object.
|
|
26
|
+
*
|
|
27
|
+
* The output is NOT a valid 3.0 spec in every edge case, but it is
|
|
28
|
+
* structurally close enough for the existing parser to produce a
|
|
29
|
+
* correct {@link ApiSpec} IR.
|
|
30
|
+
*/
|
|
31
|
+
export function convertSwagger2ToV3(raw) {
|
|
32
|
+
const doc = raw;
|
|
33
|
+
const v3 = {
|
|
34
|
+
openapi: '3.0.0',
|
|
35
|
+
info: doc.info ?? { title: 'Untitled', version: '0.0.0' },
|
|
36
|
+
servers: buildServers(doc),
|
|
37
|
+
paths: convertPaths(doc.paths ?? {}, doc.consumes, doc.produces),
|
|
38
|
+
tags: doc.tags,
|
|
39
|
+
};
|
|
40
|
+
// Move definitions → components.schemas
|
|
41
|
+
if (doc.definitions) {
|
|
42
|
+
v3['components'] = { schemas: doc.definitions };
|
|
43
|
+
}
|
|
44
|
+
return v3;
|
|
45
|
+
}
|
|
46
|
+
// ── Internals ────────────────────────────────────────────
|
|
47
|
+
function buildServers(doc) {
|
|
48
|
+
const host = doc.host ?? 'localhost';
|
|
49
|
+
const basePath = doc.basePath ?? '/';
|
|
50
|
+
const schemes = doc.schemes ?? ['https'];
|
|
51
|
+
return schemes.map(s => ({ url: `${s}://${host}${basePath}`.replace(/\/+$/, '') }));
|
|
52
|
+
}
|
|
53
|
+
function convertPaths(paths, globalConsumes, globalProduces) {
|
|
54
|
+
const converted = {};
|
|
55
|
+
const httpMethods = new Set(['get', 'post', 'put', 'patch', 'delete', 'head', 'options']);
|
|
56
|
+
for (const [path, pathItem] of Object.entries(paths)) {
|
|
57
|
+
if (!pathItem || typeof pathItem !== 'object')
|
|
58
|
+
continue;
|
|
59
|
+
const newPathItem = {};
|
|
60
|
+
for (const [key, value] of Object.entries(pathItem)) {
|
|
61
|
+
if (!httpMethods.has(key)) {
|
|
62
|
+
// Copy non-HTTP keys (e.g. path-level parameters)
|
|
63
|
+
if (key === 'parameters') {
|
|
64
|
+
newPathItem[key] = convertNonBodyParams(value);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
newPathItem[key] = value;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const op = value;
|
|
72
|
+
const newOp = {
|
|
73
|
+
operationId: op.operationId,
|
|
74
|
+
summary: op.summary,
|
|
75
|
+
description: op.description,
|
|
76
|
+
tags: op.tags,
|
|
77
|
+
deprecated: op.deprecated,
|
|
78
|
+
};
|
|
79
|
+
// Split parameters into body vs non-body
|
|
80
|
+
const rawParams = op.parameters ?? [];
|
|
81
|
+
const bodyParam = rawParams.find(p => p.in === 'body');
|
|
82
|
+
const formParams = rawParams.filter(p => p.in === 'formData');
|
|
83
|
+
const otherParams = rawParams.filter(p => p.in !== 'body' && p.in !== 'formData');
|
|
84
|
+
// Convert non-body params (add schema wrapper for v2 type→schema)
|
|
85
|
+
newOp['parameters'] = convertNonBodyParams(otherParams);
|
|
86
|
+
// body → requestBody
|
|
87
|
+
if (bodyParam) {
|
|
88
|
+
const consumes = op.consumes ?? globalConsumes ?? ['application/json'];
|
|
89
|
+
const content = {};
|
|
90
|
+
for (const mime of consumes) {
|
|
91
|
+
content[mime] = { schema: rewriteRefs(bodyParam.schema ?? {}) };
|
|
92
|
+
}
|
|
93
|
+
newOp['requestBody'] = {
|
|
94
|
+
required: bodyParam.required ?? false,
|
|
95
|
+
...(bodyParam.description ? { description: bodyParam.description } : {}),
|
|
96
|
+
content,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// formData → requestBody (multipart or urlencoded)
|
|
100
|
+
if (!bodyParam && formParams.length > 0) {
|
|
101
|
+
const consumes = op.consumes ?? globalConsumes ?? ['application/x-www-form-urlencoded'];
|
|
102
|
+
const properties = {};
|
|
103
|
+
const required = [];
|
|
104
|
+
for (const fp of formParams) {
|
|
105
|
+
properties[fp.name] = { type: fp.type ?? 'string' };
|
|
106
|
+
if (fp.description)
|
|
107
|
+
properties[fp.name]['description'] = fp.description;
|
|
108
|
+
if (fp.required)
|
|
109
|
+
required.push(fp.name);
|
|
110
|
+
}
|
|
111
|
+
const schema = { type: 'object', properties };
|
|
112
|
+
if (required.length > 0)
|
|
113
|
+
schema['required'] = required;
|
|
114
|
+
const content = {};
|
|
115
|
+
for (const mime of consumes) {
|
|
116
|
+
content[mime] = { schema };
|
|
117
|
+
}
|
|
118
|
+
newOp['requestBody'] = { content };
|
|
119
|
+
}
|
|
120
|
+
// Convert responses
|
|
121
|
+
if (op.responses) {
|
|
122
|
+
const produces = op.produces ?? globalProduces ?? ['application/json'];
|
|
123
|
+
const newResponses = {};
|
|
124
|
+
for (const [code, resp] of Object.entries(op.responses)) {
|
|
125
|
+
const newResp = {};
|
|
126
|
+
if (resp.description)
|
|
127
|
+
newResp['description'] = resp.description;
|
|
128
|
+
if (resp.schema) {
|
|
129
|
+
newResp['content'] = {};
|
|
130
|
+
for (const mime of produces) {
|
|
131
|
+
newResp['content'][mime] = { schema: rewriteRefs(resp.schema) };
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
newResponses[code] = newResp;
|
|
135
|
+
}
|
|
136
|
+
newOp['responses'] = newResponses;
|
|
137
|
+
}
|
|
138
|
+
newPathItem[key] = newOp;
|
|
139
|
+
}
|
|
140
|
+
converted[path] = newPathItem;
|
|
141
|
+
}
|
|
142
|
+
return converted;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Convert v2 parameters (which embed type directly) to v3 format (schema wrapper).
|
|
146
|
+
*/
|
|
147
|
+
function convertNonBodyParams(params) {
|
|
148
|
+
return params.map(p => {
|
|
149
|
+
if (p.schema)
|
|
150
|
+
return p; // Already has schema (v3 style)
|
|
151
|
+
const schema = {};
|
|
152
|
+
if (p.type)
|
|
153
|
+
schema['type'] = p.type;
|
|
154
|
+
if (p.format)
|
|
155
|
+
schema['format'] = p.format;
|
|
156
|
+
if (p.enum)
|
|
157
|
+
schema['enum'] = p.enum;
|
|
158
|
+
if (p.default !== undefined)
|
|
159
|
+
schema['default'] = p.default;
|
|
160
|
+
if (p.items)
|
|
161
|
+
schema['items'] = p.items;
|
|
162
|
+
const converted = {
|
|
163
|
+
name: p.name,
|
|
164
|
+
in: p.in,
|
|
165
|
+
schema,
|
|
166
|
+
};
|
|
167
|
+
if (p.required !== undefined)
|
|
168
|
+
converted['required'] = p.required;
|
|
169
|
+
if (p.description)
|
|
170
|
+
converted['description'] = p.description;
|
|
171
|
+
return converted;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Deep-rewrite `$ref` paths from v2 format to v3 format.
|
|
176
|
+
* `#/definitions/Pet` → `#/components/schemas/Pet`
|
|
177
|
+
*/
|
|
178
|
+
function rewriteRefs(obj) {
|
|
179
|
+
if (obj === null || obj === undefined)
|
|
180
|
+
return obj;
|
|
181
|
+
if (typeof obj !== 'object')
|
|
182
|
+
return obj;
|
|
183
|
+
if (Array.isArray(obj)) {
|
|
184
|
+
return obj.map(item => rewriteRefs(item));
|
|
185
|
+
}
|
|
186
|
+
const result = {};
|
|
187
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
188
|
+
if (key === '$ref' && typeof value === 'string') {
|
|
189
|
+
result[key] = value.replace('#/definitions/', '#/components/schemas/');
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
result[key] = rewriteRefs(value);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=Swagger2Converter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Swagger2Converter.js","sourceRoot":"","sources":["../../src/parser/Swagger2Converter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkDH,4DAA4D;AAE5D;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAA4B;IACnD,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;IAC3B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAA4B;IAC5D,MAAM,GAAG,GAAG,GAA6B,CAAC;IAE1C,MAAM,EAAE,GAAW;QACf,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE;QACzD,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC;QAC1B,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC;QAChE,IAAI,EAAE,GAAG,CAAC,IAAI;KACjB,CAAC;IAEF,wCAAwC;IACxC,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;QAClB,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC;IACpD,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAED,4DAA4D;AAE5D,SAAS,YAAY,CAAC,GAAgB;IAClC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,I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I,MAAM,CAAC,OAAO,CAAC,GAAa,CAAC,EAAE,CAAC;QACvD,IAAI,GAAG,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,uBAAuB,CAAC,CAAC;QAC3E,CAAC;aAAM,CAAC;YACJ,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@vinkius-core/mcp-fusion-openapi-gen",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "OpenAPI-to-MCP Fusion Server Generator. Parses OpenAPI 3.x specs and generates a complete, ready-to-run MCP Server with full MVA tool stacks (Presenters, Tools, Registry, Server) — all features configurable via YAML.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"openapi-gen": "./dist/cli.js"
|
|
10
|
-
},
|
|
11
|
-
"exports": {
|
|
12
|
-
".": {
|
|
13
|
-
"import": "./dist/index.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"lint": "eslint src/",
|
|
20
|
-
"lint:fix": "eslint src/ --fix",
|
|
21
|
-
"test": "vitest run",
|
|
22
|
-
"test:coverage": "vitest run --coverage",
|
|
23
|
-
"prepublishOnly": "npm run build"
|
|
24
|
-
},
|
|
25
|
-
"keywords": [
|
|
26
|
-
"mcp",
|
|
27
|
-
"openapi",
|
|
28
|
-
"swagger",
|
|
29
|
-
"code-generator",
|
|
30
|
-
"mcp-fusion",
|
|
31
|
-
"zod",
|
|
32
|
-
"mva",
|
|
33
|
-
"presenter",
|
|
34
|
-
"ai",
|
|
35
|
-
"llm"
|
|
36
|
-
],
|
|
37
|
-
"author": "Vinkius Labs",
|
|
38
|
-
"repository": {
|
|
39
|
-
"type": "git",
|
|
40
|
-
"url": "git+https://github.com/vinkius-labs/mcp-fusion.git",
|
|
41
|
-
"directory": "packages/openapi"
|
|
42
|
-
},
|
|
43
|
-
"bugs": {
|
|
44
|
-
"url": "https://github.com/vinkius-labs/mcp-fusion/issues"
|
|
45
|
-
},
|
|
46
|
-
"homepage": "https://mcp-fusion.vinkius.com/",
|
|
47
|
-
"files": [
|
|
48
|
-
"dist",
|
|
49
|
-
"README.md"
|
|
50
|
-
],
|
|
51
|
-
"engines": {
|
|
52
|
-
"node": ">=18.0.0"
|
|
53
|
-
},
|
|
54
|
-
"publishConfig": {
|
|
55
|
-
"access": "public"
|
|
56
|
-
},
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"yaml": "^2.7.0"
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"@vinkius-core/mcp-fusion": "^2.0.0",
|
|
62
|
-
"zod": "^3.25.1 || ^4.0.0"
|
|
63
|
-
},
|
|
64
|
-
"license": "Apache-2.0",
|
|
65
|
-
"devDependencies": {
|
|
66
|
-
"@types/node": "^25.3.0",
|
|
67
|
-
"@vinkius-core/mcp-fusion": ">=2.14.0"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@vinkius-core/mcp-fusion-openapi-gen",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "OpenAPI-to-MCP Fusion Server Generator. Parses OpenAPI 3.x and Swagger 2.0 specs and generates a complete, ready-to-run MCP Server with full MVA tool stacks (Presenters, Tools, Registry, Server) — all features configurable via YAML.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"openapi-gen": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"lint": "eslint src/",
|
|
20
|
+
"lint:fix": "eslint src/ --fix",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:coverage": "vitest run --coverage",
|
|
23
|
+
"prepublishOnly": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"mcp",
|
|
27
|
+
"openapi",
|
|
28
|
+
"swagger",
|
|
29
|
+
"code-generator",
|
|
30
|
+
"mcp-fusion",
|
|
31
|
+
"zod",
|
|
32
|
+
"mva",
|
|
33
|
+
"presenter",
|
|
34
|
+
"ai",
|
|
35
|
+
"llm"
|
|
36
|
+
],
|
|
37
|
+
"author": "Vinkius Labs",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/vinkius-labs/mcp-fusion.git",
|
|
41
|
+
"directory": "packages/openapi"
|
|
42
|
+
},
|
|
43
|
+
"bugs": {
|
|
44
|
+
"url": "https://github.com/vinkius-labs/mcp-fusion/issues"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://mcp-fusion.vinkius.com/",
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"README.md"
|
|
50
|
+
],
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=18.0.0"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"yaml": "^2.7.0"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"@vinkius-core/mcp-fusion": "^2.0.0",
|
|
62
|
+
"zod": "^3.25.1 || ^4.0.0"
|
|
63
|
+
},
|
|
64
|
+
"license": "Apache-2.0",
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/node": "^25.3.0",
|
|
67
|
+
"@vinkius-core/mcp-fusion": ">=2.14.0"
|
|
68
|
+
}
|
|
69
|
+
}
|