Forráskód Böngészése

chore(dev-hub) Fix Open API foruna ref

Aditya Arora 2 hónapja
szülő
commit
8653abd0f7

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

@@ -20,7 +20,7 @@
     "error-codes",
     "[Example Applications](https://github.com/pyth-network/pyth-examples/tree/main/entropy)",
     "[Entropy Explorer](https://entropy-explorer.pyth.network/)",
-    "[Fortuna API Reference](https://fortuna.dourolabs.app/docs/)",
+    "[Fortuna API Reference](/openapi/fortuna)",
     "---Understanding Entropy---",
     "protocol-design",
     "fees"

+ 7 - 3
apps/developer-hub/content/docs/openapi/operation/route/chain_ids.mdx → apps/developer-hub/content/docs/openapi/fortuna/chain_ids.mdx

@@ -1,5 +1,6 @@
 ---
 title: Get the list of supported chain ids
+description: Get the list of supported chain ids
 full: true
 _openapi:
   method: GET
@@ -13,6 +14,9 @@ _openapi:
 
 {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
 
-Get the list of supported chain ids
-
-<APIPage document={"https://fortuna.dourolabs.app/docs/openapi.json"} operations={[{"path":"/v1/chains","method":"get"}]} webhooks={[]} hasHead={false} />
+<APIPage
+  document={"https://fortuna-staging.dourolabs.app/docs/openapi.json"}
+  operations={[{ path: "/v1/chains", method: "get" }]}
+  webhooks={[]}
+  hasHead={false}
+/>

+ 16 - 6
apps/developer-hub/content/docs/openapi/operation/route/explorer.mdx → apps/developer-hub/content/docs/openapi/fortuna/explorer.mdx

@@ -1,5 +1,15 @@
 ---
 title: Returns the logs of all requests captured by the keeper.
+description: >-
+  Returns the logs of all requests captured by the keeper.
+
+
+  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.
+
+  This is useful for debugging and monitoring the requests made to the Entropy
+  contracts on various chains.
 full: true
 _openapi:
   method: GET
@@ -22,9 +32,9 @@ _openapi:
 
 {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
 
-Returns the logs of all requests captured by the keeper.
-
-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.
-This is useful for debugging and monitoring the requests made to the Entropy contracts on various chains.
-
-<APIPage document={"https://fortuna.dourolabs.app/docs/openapi.json"} operations={[{"path":"/v1/logs","method":"get"}]} webhooks={[]} hasHead={false} />
+<APIPage
+  document={"https://fortuna-staging.dourolabs.app/docs/openapi.json"}
+  operations={[{ path: "/v1/logs", method: "get" }]}
+  webhooks={[]}
+  hasHead={false}
+/>

+ 23 - 0
apps/developer-hub/content/docs/openapi/fortuna/index.mdx

@@ -0,0 +1,23 @@
+---
+title: Overview
+---
+
+{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
+
+<Cards>
+  <Card
+    href="/openapi/fortuna/chain_ids"
+    title="Get the list of supported chain ids"
+    description="Get the list of supported chain ids"
+  />
+  <Card
+    href="/openapi/fortuna/revelation"
+    title="Reveal the random value for a given sequence number and blockchain."
+    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."
+  />
+  <Card
+    href="/openapi/fortuna/explorer"
+    title="Returns the logs of all requests captured by the keeper."
+    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."
+  />
+</Cards>

+ 24 - 9
apps/developer-hub/content/docs/openapi/operation/route/revelation.mdx → apps/developer-hub/content/docs/openapi/fortuna/revelation.mdx

@@ -1,5 +1,21 @@
 ---
 title: Reveal the random value for a given sequence number and blockchain.
+description: >-
+  Reveal the random value for a given sequence number and blockchain.
+
+
+  Given a sequence number, retrieve the corresponding random value that this
+  provider has committed to.
+
+  This endpoint will not return the random value unless someone has requested
+  the sequence number on-chain.
+
+
+  Every blockchain supported by this service has a distinct sequence of random
+  numbers and chain_id.
+
+  Callers must pass the appropriate chain_id to ensure they fetch the correct
+  random number.
 full: true
 _openapi:
   method: GET
@@ -28,12 +44,11 @@ _openapi:
 
 {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
 
-Reveal the random value for a given sequence number and blockchain.
-
-Given a sequence number, retrieve the corresponding random value that this provider has committed to.
-This endpoint will not return the random value unless someone has requested the sequence number on-chain.
-
-Every blockchain supported by this service has a distinct sequence of random numbers and chain_id.
-Callers must pass the appropriate chain_id to ensure they fetch the correct random number.
-
-<APIPage document={"https://fortuna.dourolabs.app/docs/openapi.json"} operations={[{"path":"/v1/chains/{chain_id}/revelations/{sequence}","method":"get"}]} webhooks={[]} hasHead={false} />
+<APIPage
+  document={"https://fortuna-staging.dourolabs.app/docs/openapi.json"}
+  operations={[
+    { path: "/v1/chains/{chain_id}/revelations/{sequence}", method: "get" },
+  ]}
+  webhooks={[]}
+  hasHead={false}
+/>

+ 43 - 9
apps/developer-hub/scripts/generate-docs.ts

@@ -1,16 +1,50 @@
 import { generateFiles } from "fumadocs-openapi";
 
-import { openapi } from "../src/lib/openapi";
+import { openapi, products } from "../src/lib/openapi";
 
-const outDir = "./content/docs/openapi/operation/route";
+const outDir = "./content/docs/openapi/";
 
 export async function generateDocs() {
-    await generateFiles({
-        input: openapi,
-        output: outDir,
-        per: 'operation',
-        includeDescription: true,
-    });
+  await generateFiles({
+    input: openapi,
+    output: outDir,
+    per: "operation",
+    name: (output, document) => {
+      // Extract product name from the OpenAPI document info
+      const productName = getProductName(document.info.title || "unknown");
+
+      if (output.type === "operation") {
+        const operation =
+          document.paths?.[output.item.path]?.[output.item.method];
+        const operationId =
+          operation?.operationId ??
+          output.item.path.replaceAll(/[^a-zA-Z0-9]/g, "_");
+        return `${productName}/${operationId}`;
+      }
+
+      return `${productName}/webhooks/${output.item.name}`;
+    },
+    index: {
+      url: {
+        baseUrl: "/openapi/",
+        contentDir: "./content/docs/openapi",
+      },
+      items: Object.keys(products).map((productName) => ({
+        path: `${productName}/index.mdx`,
+      })),
+    },
+  });
+}
+
+function getProductName(title: string): string {
+  // Match the title to a product name
+  const titleLower = title.toLowerCase();
+  for (const [name] of Object.entries(products)) {
+    if (titleLower.includes(name)) {
+      return name;
+    }
+  }
+  return "unknown";
 }
 
-await generateDocs();
+await generateDocs();

+ 7 - 3
apps/developer-hub/src/lib/openapi.ts

@@ -1,8 +1,12 @@
 import { createOpenAPI } from "fumadocs-openapi/server";
 
-export const fortunaOpenApiJson =
-  "https://fortuna.dourolabs.app/docs/openapi.json";
+export const products = {
+  fortuna: {
+    name: "fortuna",
+    openApiUrl: "https://fortuna-staging.dourolabs.app/docs/openapi.json",
+  },
+};
 
 export const openapi = createOpenAPI({
-  input: [fortunaOpenApiJson],
+  input: Object.values(products).map((product) => product.openApiUrl),
 });