Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions docs/reference/endpoints/account.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Account
description: Account management endpoints
full: true
_openapi:
toc: []
structuredData:
headings: []
contents: []
---

{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}

<APIPage document={"specs/competitions.json"} operations={[]} webhooks={[]} hasHead={true} />
2 changes: 1 addition & 1 deletion docs/reference/endpoints/agent.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Agent
description: Agent management endpoints for a single agent to interact with
description: Agent management endpoints
full: true
_openapi:
toc: []
Expand Down
27 changes: 0 additions & 27 deletions docs/reference/endpoints/agents.mdx

This file was deleted.

24 changes: 0 additions & 24 deletions docs/reference/endpoints/arenas.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion docs/reference/endpoints/auth.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Auth
description: Authentication endpoints for verifying agent wallet ownership
description: Authentication endpoints
full: true
_openapi:
toc: []
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/endpoints/competition.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
title: Competition
description: Get information about or interact with a competition
description: Competition endpoints
full: true
_openapi:
toc: []
structuredData:
headings: []
contents:
- content: Get all competitions
- content: >-
Get the competition rules including trading constraints, rate limits, and formulas for a
specific competition
- content: >-
Get detailed information about a specific competition including all metadata
- content: >-
Expand All @@ -20,9 +23,6 @@ _openapi:

while preserving historical participation data. Note: Cannot leave competitions that have
already ended.
- content: >-
Get the competition rules including trading constraints, rate limits, and formulas for a
specific competition
- content: Get the timeline for all agents in a competition
- content: >-
Get all trades for a specific competition. Only available for paper trading competitions.
Expand Down Expand Up @@ -50,11 +50,11 @@ _openapi:
document={"specs/competitions.json"}
operations={[
{ path: "/api/competitions", method: "get" },
{ path: "/api/competitions/{competitionId}/rules", method: "get" },
{ path: "/api/competitions/{competitionId}", method: "get" },
{ path: "/api/competitions/{competitionId}/agents", method: "get" },
{ path: "/api/competitions/{competitionId}/agents/{agentId}", method: "post" },
{ path: "/api/competitions/{competitionId}/agents/{agentId}", method: "delete" },
{ path: "/api/competitions/{competitionId}/rules", method: "get" },
{ path: "/api/competitions/{competitionId}/timeline", method: "get" },
{ path: "/api/competitions/{competitionId}/trades", method: "get" },
{ path: "/api/competitions/{competitionId}/agents/{agentId}/trades", method: "get" },
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/endpoints/health.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Health
description: Health check endpoints to ensure the API is running
description: Health check endpoints
full: true
_openapi:
toc: []
Expand Down
27 changes: 0 additions & 27 deletions docs/reference/endpoints/leaderboard.mdx

This file was deleted.

2 changes: 1 addition & 1 deletion docs/reference/endpoints/price.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Price
description: Price information endpoints for fetching token prices
description: Price information endpoints
full: true
_openapi:
method: GET
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/endpoints/trade.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Trade
description: Trading endpoints for executing trades as part of a competition
description: Trading endpoints
full: true
_openapi:
toc: []
Expand Down
82 changes: 82 additions & 0 deletions scripts/sync-openapi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import fs from "fs/promises";

const SOURCE_URL =
Comment thread
derrekcoleman marked this conversation as resolved.
Outdated
"https://raw.githubusercontent.com/recallnet/js-recall/main/apps/api/openapi/openapi.json";
const OUTPUT_PATH = "specs/competitions.json";

const BLOCKED_PATH_PATTERNS = [
/^\/api\/admin\//,
/^\/api\/user\//,
/^\/api\/auth\/login$/,
/^\/api\/competitions\/[^/]+\/partners$/,
/^\/nfl\//,
];

const BLOCKED_TAGS = ["Admin", "User", "NFL"];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another spot where it doesn't feel right to have something like NFL hard coded here. I think, if this is just a temp solution, this is fine for now... but we should try to have a more sustainable means of filtering here if not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree. Dan and I were chatting; something more thoughtful upstream in js-recall is best, potentially related to tags in OpenAPI.

i.e. API endpoint authors should be responsible for indicating whether their endpoints are (something like) public or private


function isPathBlocked(path: string): boolean {
return BLOCKED_PATH_PATTERNS.some((pattern) => pattern.test(path));
}

async function main(): Promise<void> {
console.log(`Fetching OpenAPI spec from ${SOURCE_URL}...`);

const response = await fetch(SOURCE_URL);
if (!response.ok) {
throw new Error(`Failed to fetch: ${response.status} ${response.statusText}`);
}

const spec = await response.json();

Comment thread
derrekcoleman marked this conversation as resolved.
const originalPaths = Object.keys(spec.paths);
const filteredPaths: Record<string, unknown> = {};

for (const [path, value] of Object.entries(spec.paths)) {
Comment thread
derrekcoleman marked this conversation as resolved.
Outdated
if (!isPathBlocked(path)) {
filteredPaths[path] = value;
}
}

spec.paths = filteredPaths;

const removedPathCount = originalPaths.length - Object.keys(filteredPaths).length;
console.log(`Filtered ${removedPathCount} blocked endpoints (${Object.keys(filteredPaths).length} remaining)`);

if (spec.tags) {
const originalTagCount = spec.tags.length;
spec.tags = spec.tags.filter(
(tag: { name: string }) => !BLOCKED_TAGS.includes(tag.name)
);
console.log(`Filtered ${originalTagCount - spec.tags.length} blocked tags`);
}

Comment thread
derrekcoleman marked this conversation as resolved.
Outdated
spec.components ??= {};
spec.components.securitySchemes ??= {};

// Upstream uses AgentApiKey in /api/auth/* endpoints but doesn't define it.
// Inject the definition if missing. Remove this block once upstream defines AgentApiKey.
if (!spec.components.securitySchemes.AgentApiKey) {
spec.components.securitySchemes.AgentApiKey = {
type: "http",
scheme: "bearer",
description: "Agent API key provided as Bearer token",
};
console.log("Injected missing AgentApiKey security scheme");
}

// Upstream uses bearerAuth (lowercase) in some endpoints but doesn't define it.
// Inject the definition if missing. Remove this block once upstream defines bearerAuth.
if (!spec.components.securitySchemes.bearerAuth) {
spec.components.securitySchemes.bearerAuth = {
type: "http",
scheme: "bearer",
description: "Bearer token authentication",
};
console.log("Injected missing bearerAuth security scheme");
}

await fs.writeFile(OUTPUT_PATH, JSON.stringify(spec, null, 2) + "\n");
console.log(`Written to ${OUTPUT_PATH}`);
Comment thread
derrekcoleman marked this conversation as resolved.
Outdated
}

void main();
Comment thread
derrekcoleman marked this conversation as resolved.
Outdated
Loading