hirosystems / stacks-blockchain-api

API for the Stacks blockchain
https://stacks-blockchain-api.vercel.app
GNU General Public License v3.0
170 stars 108 forks source link

Broken anchors in API docs #1860

Closed diwakergupta closed 1 month ago

diwakergupta commented 5 months ago

Describe the bug

Surfaced via the broken anchors check in Docusaurus, while building Hiro docs:

- Broken anchor on source page path = /api/fetch-fee-rate:
   -> linking to #operation/post_fee_transaction (resolved as: /api/fetch-fee-rate#operation/post_fee_transaction)
- Broken anchor on source page path = /api/get-block-by-burnchain-block-hash:
   -> linking to #operation/get_blocks (resolved as: /api/get-block-by-burnchain-block-hash#operation/get_blocks)
- Broken anchor on source page path = /api/get-block-by-burnchain-height:
   -> linking to #operation/get_blocks (resolved as: /api/get-block-by-burnchain-height#operation/get_blocks)
- Broken anchor on source page path = /api/get-block-by-hash:
   -> linking to #operation/get_block (resolved as: /api/get-block-by-hash#operation/get_block)
- Broken anchor on source page path = /api/get-block-by-height:
   -> linking to #operation/get_block (resolved as: /api/get-block-by-height#operation/get_block)
- Broken anchor on source page path = /api/get-recent-blocks:
   -> linking to #operation/get_blocks (resolved as: /api/get-recent-blocks#operation/get_blocks)
- Broken anchor on source page path = /api/transactions-by-block-hash:
   -> linking to #operation/get_transactions_by_block (resolved as: /api/transactions-by-block-hash#operation/get_transactions_by_block)
- Broken anchor on source page path = /api/transactions-by-block-height:
   -> linking to #operation/get_transactions_by_block (resolved as: /api/transactions-by-block-height#operation/get_transactions_by_block)

To Reproduce

Just follow any of the links mentioned above. For instance, https://docs.hiro.so/api/fetch-fee-rate links to https://docs.hiro.so/api/fetch-fee-rate#operation/post_fee_transaction which doesn't exist.

ryanwaits commented 5 months ago

ok so i think this issue arises due to a mismatch in page structures between redoc and docusaurus when handling openapi documentation.

in redoc, each openapi tag gets its own page, and operations under that tag are referenced via # anchors (e.g. #operation/get_blocks). in contrast, docusaurus generates a separate webpage for each API operation.

so when we pull in the openapi.yaml from the blockchain api repo into docs, the original markdown links referenced in the openapi.yaml file use redocs anchor system. and so when imported into docusarus, these markdown links are being interpreted as related to the current page of docusaurus, which leads to incorrect URLs and subsequently broken links in our documentation.

ill keep looking into solutions for this