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.
@@ -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 bodyParams = endpoint.parameters.filter(p => p.in === 'body');
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
- const hasRequestBody = bodyParams.length > 0;
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 (hasRequestBody) {
153
+ if (endpoint.requestBodyExample) {
163
154
  result += "\n";
164
155
  result += JSON.stringify(endpoint.requestBodyExample, null, 2);
165
156
  }
@@ -110,18 +110,24 @@ export class SwaggerParser {
110
110
  return {};
111
111
  }
112
112
  resolveSuccessExampleResponse(operation) {
113
- if (operation.responses && operation.responses['200']) {
114
- const successResponse = operation.responses['200'];
115
- if (successResponse.content && successResponse.content['application/json']) {
116
- const content = successResponse.content['application/json'];
117
- if (content.example) {
118
- return content.example;
119
- }
120
- if (content.schema && content.schema.example) {
121
- return content.schema.example;
122
- }
123
- if (content.schema) {
124
- return this.generateSampleFromSchema(content.schema);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-mcp-server",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "main": "build/index.js",
6
6
  "bin": {