From 3a0e0c0c8103041d3a0fffb927c267d6803db6c9 Mon Sep 17 00:00:00 2001 From: jay23606 <4602056+jay23606@users.noreply.github.com> Date: Sun, 25 Oct 2026 18:25:16 -0400 Subject: [PATCH] fix(metaculus): add missing GetPosts query parameters --- core/specs/metaculus/Metaculus.yaml | 22 ++++++++++++++- core/src/exchanges/metaculus/api.ts | 28 +++++++++++++++++++ .../metaculus-get-posts-params.test.ts | 27 ++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 core/test/exchanges/metaculus-get-posts-params.test.ts diff --git a/core/specs/metaculus/Metaculus.yaml b/core/specs/metaculus/Metaculus.yaml index a0eb3738..bb4e360a 100644 --- a/core/specs/metaculus/Metaculus.yaml +++ b/core/specs/metaculus/Metaculus.yaml @@ -1030,6 +1030,26 @@ paths: tags: - Feed parameters: + - in: query + name: acting_user + schema: + type: integer + description: Filters posts by acting or proxy user ID. + - in: query + name: categories + schema: + type: string + description: Comma-separated category slugs to filter posts. + - in: query + name: include_cp_history + schema: + type: boolean + description: Includes community prediction history in the response. + - in: query + name: include_descriptions + schema: + type: boolean + description: Includes full question descriptions in the response. - in: query name: tournaments schema: @@ -2067,4 +2087,4 @@ paths: items: $ref: '#/components/schemas/Comment' '400': - description: Invalid request format \ No newline at end of file + description: Invalid request format diff --git a/core/src/exchanges/metaculus/api.ts b/core/src/exchanges/metaculus/api.ts index 0d32f8dc..d9e59ffd 100644 --- a/core/src/exchanges/metaculus/api.ts +++ b/core/src/exchanges/metaculus/api.ts @@ -52,6 +52,34 @@ export const metaculusApiSpec = { "Feed" ], "parameters": [ + { + "in": "query", + "name": "acting_user", + "schema": { + "type": "integer" + } + }, + { + "in": "query", + "name": "categories", + "schema": { + "type": "string" + } + }, + { + "in": "query", + "name": "include_cp_history", + "schema": { + "type": "boolean" + } + }, + { + "in": "query", + "name": "include_descriptions", + "schema": { + "type": "boolean" + } + }, { "in": "query", "name": "tournaments", diff --git a/core/test/exchanges/metaculus-get-posts-params.test.ts b/core/test/exchanges/metaculus-get-posts-params.test.ts new file mode 100644 index 00000000..cd08ba4a --- /dev/null +++ b/core/test/exchanges/metaculus-get-posts-params.test.ts @@ -0,0 +1,27 @@ +import { readFileSync } from 'fs'; +import { safeLoad } from 'js-yaml'; +import { metaculusApiSpec } from '../../src/exchanges/metaculus/api'; + +const expectedParameters = [ + { name: 'acting_user', schema: { type: 'integer' } }, + { name: 'categories', schema: { type: 'string' } }, + { name: 'include_cp_history', schema: { type: 'boolean' } }, + { name: 'include_descriptions', schema: { type: 'boolean' } }, +]; + +function expectParameters(spec: any) { + const parameters = spec.paths['/posts/'].get.parameters; + for (const expected of expectedParameters) { + expect(parameters).toEqual(expect.arrayContaining([expect.objectContaining(expected)])); + } +} + +describe('Metaculus GetPosts query parameters', () => { + test('keeps the YAML source and generated API definition in sync', () => { + const yaml = readFileSync(`${__dirname}/../../specs/metaculus/Metaculus.yaml`, 'utf8'); + const sourceSpec = safeLoad(yaml); + + expectParameters(sourceSpec); + expectParameters(metaculusApiSpec); + }); +});