swagger-mcp-server 1.0.0 → 1.0.1
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/build/swagger_mcp_server.js +3 -12
- package/build/swagger_parser.js +18 -12
- package/package.json +1 -1
|
@@ -107,8 +107,7 @@ export class SwaggerMcpServer {
|
|
|
107
107
|
}
|
|
108
108
|
const pathParams = endpoint.parameters.filter(p => p.in === 'path');
|
|
109
109
|
const queryParams = endpoint.parameters.filter(p => p.in === 'query');
|
|
110
|
-
const
|
|
111
|
-
const otherParams = endpoint.parameters.filter(p => !['path', 'query', 'body'].includes(p.in));
|
|
110
|
+
const otherParams = endpoint.parameters.filter(p => !['path', 'query'].includes(p.in));
|
|
112
111
|
if (pathParams.length > 0) {
|
|
113
112
|
result += `### Path Parameters\n`;
|
|
114
113
|
for (const param of pathParams) {
|
|
@@ -123,13 +122,6 @@ export class SwaggerMcpServer {
|
|
|
123
122
|
}
|
|
124
123
|
result += `\n`;
|
|
125
124
|
}
|
|
126
|
-
if (bodyParams.length > 0) {
|
|
127
|
-
result += `### Body Parameters\n`;
|
|
128
|
-
for (const param of bodyParams) {
|
|
129
|
-
result += `- \`${param.name}\` (${param.type}${param.required ? ', required' : ''}): ${param.description}\n`;
|
|
130
|
-
}
|
|
131
|
-
result += `\n`;
|
|
132
|
-
}
|
|
133
125
|
if (otherParams.length > 0) {
|
|
134
126
|
result += `### Other Parameters\n`;
|
|
135
127
|
for (const param of otherParams) {
|
|
@@ -150,8 +142,7 @@ export class SwaggerMcpServer {
|
|
|
150
142
|
result += `### Example Request\n`;
|
|
151
143
|
result += "```http\n";
|
|
152
144
|
result += `${endpoint.method.toUpperCase()} ${exampleUrl}\n`;
|
|
153
|
-
|
|
154
|
-
if (hasRequestBody) {
|
|
145
|
+
if (endpoint.requestBodyExample) {
|
|
155
146
|
result += "Content-Type: application/json\n";
|
|
156
147
|
}
|
|
157
148
|
for (const param of otherParams) {
|
|
@@ -159,7 +150,7 @@ export class SwaggerMcpServer {
|
|
|
159
150
|
result += `${param.name}: ${param.example || 'example-value'}\n`;
|
|
160
151
|
}
|
|
161
152
|
}
|
|
162
|
-
if (
|
|
153
|
+
if (endpoint.requestBodyExample) {
|
|
163
154
|
result += "\n";
|
|
164
155
|
result += JSON.stringify(endpoint.requestBodyExample, null, 2);
|
|
165
156
|
}
|
package/build/swagger_parser.js
CHANGED
|
@@ -110,18 +110,24 @@ export class SwaggerParser {
|
|
|
110
110
|
return {};
|
|
111
111
|
}
|
|
112
112
|
resolveSuccessExampleResponse(operation) {
|
|
113
|
-
if (operation.responses
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
113
|
+
if (operation.responses) {
|
|
114
|
+
for (const code in operation.responses) {
|
|
115
|
+
const codeNum = parseInt(code, 10);
|
|
116
|
+
if (!isNaN(codeNum) && Math.floor(codeNum / 100) === 2) {
|
|
117
|
+
const successResponse = operation.responses[code];
|
|
118
|
+
if (successResponse.content && successResponse.content['application/json']) {
|
|
119
|
+
const content = successResponse.content['application/json'];
|
|
120
|
+
if (content.example) {
|
|
121
|
+
return content.example;
|
|
122
|
+
}
|
|
123
|
+
if (content.schema && content.schema.example) {
|
|
124
|
+
return content.schema.example;
|
|
125
|
+
}
|
|
126
|
+
if (content.schema) {
|
|
127
|
+
return this.generateSampleFromSchema(content.schema);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {};
|
|
125
131
|
}
|
|
126
132
|
}
|
|
127
133
|
}
|