Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/openapi-mcp-server/client/__tests__/http-client-upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ import fs from 'fs'
import FormData from 'form-data'

vi.mock('fs')
vi.mock('form-data')
vi.mock('form-data', () => {
const MockFormData = vi.fn().mockImplementation(() => ({
append: vi.fn(),
getHeaders: vi.fn()
}))
MockFormData.prototype.append = vi.fn()
MockFormData.prototype.getHeaders = vi.fn()
return {
default: MockFormData
}
})

describe('HttpClient File Upload', () => {
let client: HttpClient
Expand Down Expand Up @@ -81,7 +91,6 @@ describe('HttpClient File Upload', () => {
const mockFormDataHeaders = { 'content-type': 'multipart/form-data; boundary=---123' }

vi.mocked(fs.createReadStream).mockReturnValue(mockFileStream as any)
vi.mocked(FormData.prototype.append).mockImplementation(() => {})
vi.mocked(FormData.prototype.getHeaders).mockReturnValue(mockFormDataHeaders)

const uploadPath = mockOpenApiSpec.paths['/upload']
Expand Down Expand Up @@ -127,15 +136,13 @@ describe('HttpClient File Upload', () => {
})

it('should handle multiple file uploads', async () => {
const mockFormData = new FormData()
const mockFileStream1 = { pipe: vi.fn() }
const mockFileStream2 = { pipe: vi.fn() }
const mockFormDataHeaders = { 'content-type': 'multipart/form-data; boundary=---123' }

vi.mocked(fs.createReadStream)
.mockReturnValueOnce(mockFileStream1 as any)
.mockReturnValueOnce(mockFileStream2 as any)
vi.mocked(FormData.prototype.append).mockImplementation(() => {})
vi.mocked(FormData.prototype.getHeaders).mockReturnValue(mockFormDataHeaders)

const operation: OpenAPIV3.OperationObject = {
Expand Down
10 changes: 5 additions & 5 deletions src/openapi-mcp-server/openapi/__tests__/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ describe('OpenAPIToMCPConverter', () => {
const getPetMethod = tools.API.methods.find((m) => m.name === 'getPet')
expect(getPetMethod).toBeDefined()

// We just check that the description includes the error references now.
expect(getPetMethod?.description).toContain('404: The specified resource was not found')
// The description should be the operation summary with Notion prefix
expect(getPetMethod?.description).toBe('Notion | Get a pet by ID')
})

it('handles recursive schema references without expanding them', () => {
Expand Down Expand Up @@ -964,7 +964,7 @@ describe('OpenAPIToMCPConverter - Additional Complex Tests', () => {
methods: [
{
name: 'getAB',
description: 'Get an A-B object',
description: 'Notion | Get an A-B object',
// Error responses might not be listed here since none are defined.
// Just end the description with no Error Responses section.
inputSchema: {
Expand Down Expand Up @@ -1047,7 +1047,7 @@ describe('OpenAPIToMCPConverter - Additional Complex Tests', () => {
},
{
name: 'createAB',
description: 'Create an A-B object',
description: 'Notion | Create an A-B object',
inputSchema: {
type: 'object',
properties: {
Expand Down Expand Up @@ -1279,7 +1279,7 @@ describe('OpenAPIToMCPConverter - Additional Complex Tests', () => {
methods: [
{
name: 'getComposed',
description: 'Get a composed resource',
description: 'Notion | Get a composed resource',
inputSchema: {
type: 'object',
properties: {},
Expand Down