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
22 changes: 21 additions & 1 deletion core/specs/metaculus/Metaculus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -2067,4 +2087,4 @@ paths:
items:
$ref: '#/components/schemas/Comment'
'400':
description: Invalid request format
description: Invalid request format
28 changes: 28 additions & 0 deletions core/src/exchanges/metaculus/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions core/test/exchanges/metaculus-get-posts-params.test.ts
Original file line number Diff line number Diff line change
@@ -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);
});
});