Skip to content

Commit 8653abd

Browse files
committed
chore(dev-hub) Fix Open API foruna ref
1 parent deb2f4e commit 8653abd

File tree

7 files changed

+121
-31
lines changed

7 files changed

+121
-31
lines changed

apps/developer-hub/content/docs/entropy/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"error-codes",
2121
"[Example Applications](https://github.com/pyth-network/pyth-examples/tree/main/entropy)",
2222
"[Entropy Explorer](https://entropy-explorer.pyth.network/)",
23-
"[Fortuna API Reference](https://fortuna.dourolabs.app/docs/)",
23+
"[Fortuna API Reference](/openapi/fortuna)",
2424
"---Understanding Entropy---",
2525
"protocol-design",
2626
"fees"

apps/developer-hub/content/docs/openapi/operation/route/chain_ids.mdx renamed to apps/developer-hub/content/docs/openapi/fortuna/chain_ids.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Get the list of supported chain ids
3+
description: Get the list of supported chain ids
34
full: true
45
_openapi:
56
method: GET
@@ -13,6 +14,9 @@ _openapi:
1314

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

16-
Get the list of supported chain ids
17-
18-
<APIPage document={"https://fortuna.dourolabs.app/docs/openapi.json"} operations={[{"path":"/v1/chains","method":"get"}]} webhooks={[]} hasHead={false} />
17+
<APIPage
18+
document={"https://fortuna-staging.dourolabs.app/docs/openapi.json"}
19+
operations={[{ path: "/v1/chains", method: "get" }]}
20+
webhooks={[]}
21+
hasHead={false}
22+
/>

apps/developer-hub/content/docs/openapi/operation/route/explorer.mdx renamed to apps/developer-hub/content/docs/openapi/fortuna/explorer.mdx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
---
22
title: Returns the logs of all requests captured by the keeper.
3+
description: >-
4+
Returns the logs of all requests captured by the keeper.
5+
6+
7+
This endpoint allows you to filter the logs by a specific network ID, a query
8+
string (which can be a transaction hash, sender address, or sequence number),
9+
and a time range.
10+
11+
This is useful for debugging and monitoring the requests made to the Entropy
12+
contracts on various chains.
313
full: true
414
_openapi:
515
method: GET
@@ -22,9 +32,9 @@ _openapi:
2232

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

25-
Returns the logs of all requests captured by the keeper.
26-
27-
This endpoint allows you to filter the logs by a specific network ID, a query string (which can be a transaction hash, sender address, or sequence number), and a time range.
28-
This is useful for debugging and monitoring the requests made to the Entropy contracts on various chains.
29-
30-
<APIPage document={"https://fortuna.dourolabs.app/docs/openapi.json"} operations={[{"path":"/v1/logs","method":"get"}]} webhooks={[]} hasHead={false} />
35+
<APIPage
36+
document={"https://fortuna-staging.dourolabs.app/docs/openapi.json"}
37+
operations={[{ path: "/v1/logs", method: "get" }]}
38+
webhooks={[]}
39+
hasHead={false}
40+
/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Overview
3+
---
4+
5+
{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
6+
7+
<Cards>
8+
<Card
9+
href="/openapi/fortuna/chain_ids"
10+
title="Get the list of supported chain ids"
11+
description="Get the list of supported chain ids"
12+
/>
13+
<Card
14+
href="/openapi/fortuna/revelation"
15+
title="Reveal the random value for a given sequence number and blockchain."
16+
description="Reveal the random value for a given sequence number and blockchain.\n\nGiven a sequence number, retrieve the corresponding random value that this provider has committed to.\nThis endpoint will not return the random value unless someone has requested the sequence number on-chain.\n\nEvery blockchain supported by this service has a distinct sequence of random numbers and chain_id.\nCallers must pass the appropriate chain_id to ensure they fetch the correct random number."
17+
/>
18+
<Card
19+
href="/openapi/fortuna/explorer"
20+
title="Returns the logs of all requests captured by the keeper."
21+
description="Returns the logs of all requests captured by the keeper.\n\nThis endpoint allows you to filter the logs by a specific network ID, a query string (which can be a transaction hash, sender address, or sequence number), and a time range.\nThis is useful for debugging and monitoring the requests made to the Entropy contracts on various chains."
22+
/>
23+
</Cards>

apps/developer-hub/content/docs/openapi/operation/route/revelation.mdx renamed to apps/developer-hub/content/docs/openapi/fortuna/revelation.mdx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
---
22
title: Reveal the random value for a given sequence number and blockchain.
3+
description: >-
4+
Reveal the random value for a given sequence number and blockchain.
5+
6+
7+
Given a sequence number, retrieve the corresponding random value that this
8+
provider has committed to.
9+
10+
This endpoint will not return the random value unless someone has requested
11+
the sequence number on-chain.
12+
13+
14+
Every blockchain supported by this service has a distinct sequence of random
15+
numbers and chain_id.
16+
17+
Callers must pass the appropriate chain_id to ensure they fetch the correct
18+
random number.
319
full: true
420
_openapi:
521
method: GET
@@ -28,12 +44,11 @@ _openapi:
2844

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

31-
Reveal the random value for a given sequence number and blockchain.
32-
33-
Given a sequence number, retrieve the corresponding random value that this provider has committed to.
34-
This endpoint will not return the random value unless someone has requested the sequence number on-chain.
35-
36-
Every blockchain supported by this service has a distinct sequence of random numbers and chain_id.
37-
Callers must pass the appropriate chain_id to ensure they fetch the correct random number.
38-
39-
<APIPage document={"https://fortuna.dourolabs.app/docs/openapi.json"} operations={[{"path":"/v1/chains/{chain_id}/revelations/{sequence}","method":"get"}]} webhooks={[]} hasHead={false} />
47+
<APIPage
48+
document={"https://fortuna-staging.dourolabs.app/docs/openapi.json"}
49+
operations={[
50+
{ path: "/v1/chains/{chain_id}/revelations/{sequence}", method: "get" },
51+
]}
52+
webhooks={[]}
53+
hasHead={false}
54+
/>
Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
import { generateFiles } from "fumadocs-openapi";
22

3-
import { openapi } from "../src/lib/openapi";
3+
import { openapi, products } from "../src/lib/openapi";
44

5-
const outDir = "./content/docs/openapi/operation/route";
5+
const outDir = "./content/docs/openapi/";
66

77
export async function generateDocs() {
8-
await generateFiles({
9-
input: openapi,
10-
output: outDir,
11-
per: 'operation',
12-
includeDescription: true,
13-
});
8+
await generateFiles({
9+
input: openapi,
10+
output: outDir,
11+
per: "operation",
12+
name: (output, document) => {
13+
// Extract product name from the OpenAPI document info
14+
const productName = getProductName(document.info.title || "unknown");
15+
16+
if (output.type === "operation") {
17+
const operation =
18+
document.paths?.[output.item.path]?.[output.item.method];
19+
const operationId =
20+
operation?.operationId ??
21+
output.item.path.replaceAll(/[^a-zA-Z0-9]/g, "_");
22+
return `${productName}/${operationId}`;
23+
}
24+
25+
return `${productName}/webhooks/${output.item.name}`;
26+
},
27+
index: {
28+
url: {
29+
baseUrl: "/openapi/",
30+
contentDir: "./content/docs/openapi",
31+
},
32+
items: Object.keys(products).map((productName) => ({
33+
path: `${productName}/index.mdx`,
34+
})),
35+
},
36+
});
37+
}
38+
39+
function getProductName(title: string): string {
40+
// Match the title to a product name
41+
const titleLower = title.toLowerCase();
42+
for (const [name] of Object.entries(products)) {
43+
if (titleLower.includes(name)) {
44+
return name;
45+
}
46+
}
47+
return "unknown";
1448
}
1549

16-
await generateDocs();
50+
await generateDocs();
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { createOpenAPI } from "fumadocs-openapi/server";
22

3-
export const fortunaOpenApiJson =
4-
"https://fortuna.dourolabs.app/docs/openapi.json";
3+
export const products = {
4+
fortuna: {
5+
name: "fortuna",
6+
openApiUrl: "https://fortuna-staging.dourolabs.app/docs/openapi.json",
7+
},
8+
};
59

610
export const openapi = createOpenAPI({
7-
input: [fortunaOpenApiJson],
11+
input: Object.values(products).map((product) => product.openApiUrl),
812
});

0 commit comments

Comments
 (0)