diff --git a/packages/openapi-codegen/src/parser.test.ts b/packages/openapi-codegen/src/parser.test.ts index b490c12..2897e6d 100644 --- a/packages/openapi-codegen/src/parser.test.ts +++ b/packages/openapi-codegen/src/parser.test.ts @@ -87,4 +87,64 @@ describe('parseOpenApi name resolution', () => { ]); expect(tools[0].inputSchema.required).toEqual(['spaceId', 'agentId', 'prompt']); }); + + it('parses an OpenAPI 3.1 Xquik search endpoint', () => { + const tools = parseOpenApi({ + '/api/v1/x/tweets/search': { + get: { + operationId: 'searchTweets', + summary: 'Search recent public posts', + parameters: [ + { + name: 'q', + in: 'query', + required: true, + schema: { type: 'string', minLength: 1 }, + }, + { + name: 'limit', + in: 'query', + required: false, + schema: { type: 'integer', minimum: 1, maximum: 100 }, + }, + ], + responses: { + '200': { + description: 'Search results', + content: { + 'application/json': { + schema: { + type: 'object', + required: ['data'], + properties: { + data: { + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'string' }, + text: { type: 'string' }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + } as never); + + expect(tools).toHaveLength(1); + expect(tools[0].name).toBe('searchTweets'); + expect(tools[0].description).toBe('Search recent public posts'); + expect(tools[0].method).toBe('get'); + expect(tools[0].path).toBe('/api/v1/x/tweets/search'); + expect(tools[0].queryParamsSchema?.required).toEqual(['q']); + expect(tools[0].queryParamsSchema?.properties).toHaveProperty('q'); + expect(tools[0].queryParamsSchema?.properties).toHaveProperty('limit'); + expect(tools[0].outputSchema.properties).toHaveProperty('data'); + }); });