Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing REST API docs to include route changes #3401

Merged
merged 2 commits into from
Nov 19, 2024
Merged

Conversation

Defi-Moses
Copy link
Collaborator

@Defi-Moses Defi-Moses commented Nov 19, 2024

Merging the /txInfo endpoints with their relevant /swap or /bridge endpoints. Updating the docs to reflect this and then also adding more clarity on how the docs work.

Docs likely need more iteration.

Summary by CodeRabbit

  • Documentation
    • Revised Synapse REST API documentation for clarity on read-only status and integration capabilities.
    • Added new API endpoint information and consolidated deprecated endpoints into updated versions.
    • Enhanced descriptions for /bridge endpoint, including new required parameters and detailed response structures.
    • Improved overall formatting and consistency across API documentation.

4b78d54: docs preview link

@Defi-Moses Defi-Moses requested a review from trajan0x as a code owner November 19, 2024 09:53
Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Walkthrough

The changes involve significant updates to the Synapse REST API documentation, particularly enhancing clarity regarding the API's read-only nature and its integration capabilities with the Synapse liquidity network. Key updates include the deprecation of the /bridgeTxInfo and /swapTxInfo endpoints, with users directed to utilize the /bridge and /swap endpoints instead. The documentation now includes detailed descriptions of the API's functionality, new required parameters, and improved response structures, ensuring developers have comprehensive guidance for using the API effectively.

Changes

File Change Summary
docs/bridge/docs/02-Bridge/02-REST-API.md Expanded introduction, added API endpoint information, updated versions table, clarified API functionality.
packages/rest-api/src/routes/bridgeTxInfoRoute.ts Updated OpenAPI documentation to indicate deprecation of /bridgeTxInfo in favor of /bridge. No functional changes.
packages/rest-api/src/routes/swapTxInfoRoute.ts Updated OpenAPI documentation to indicate deprecation of /swapTxInfo in favor of /swap. No functional changes.
packages/rest-api/swagger.json Deprecated /bridgeTxInfo and /swapTxInfo endpoints, added new parameter to /bridge, updated response structures.

Possibly related PRs

Suggested labels

size/m, M-docs, Sol, Typescript

Suggested reviewers

  • trajan0x
  • abtestingalpha
  • bigboydiamonds

Poem

In the land of code where rabbits hop,
The API's clear, no chance of a flop.
With bridges and swaps, oh what a delight,
Our docs now shine, so developers take flight!
Hop along, dear friends, to the Synapse way,
With tokens and liquidity, let’s play all day! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

cloudflare-workers-and-pages bot commented Nov 19, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: e5d43fb
Status: ✅  Deploy successful!
Preview URL: https://e39fba68.sanguine-fe.pages.dev
Branch Preview URL: https://docs-api-improvements.sanguine-fe.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
docs/bridge/docs/02-Bridge/02-REST-API.md (2)

7-15: Add deprecation notice in the introduction section

Consider adding a prominent notice about the deprecation of /bridgeTxInfo and /swapTxInfo endpoints early in the introduction. This would help users understand the migration path upfront.

Add this paragraph after line 15:

The API is available at [`https://api.synapseprotocol.com/`](https://api.synapseprotocol.com/).

+ > **Important:** The `/bridgeTxInfo` and `/swapTxInfo` endpoints have been deprecated. Please use the `/bridge` and `/swap` endpoints respectively, which now return the transaction data directly. See the [Previous versions](#previous-versions) section for more details.

Documentation needs comprehensive update to reflect API consolidation

The review needs to be expanded as there are multiple documentation inconsistencies:

  1. The commented-out API documentation is outdated and conflicts with the November 19, 2024 changelog that shows /bridgeTxInfo was consolidated into /bridge
  2. The blog post from October 10, 2024 still references the deprecated endpoints
  3. The APIFlow component in docs/bridge/src/components/APIFlow.tsx still references /bridgeTxInfo

Action items:

  • Remove the deprecated /bridgeTxInfo and /swapTxInfo endpoint documentation
  • Update the /bridge and /swap endpoint documentation to include the new transaction data response fields
  • Update the blog post to reflect the latest API changes
  • Update the APIFlow component to use the consolidated endpoints
🔗 Analysis chain

Line range hint 31-326: Update the commented API documentation

The commented-out API documentation section needs to be updated to:

  1. Remove the deprecated /bridgeTxInfo and /swapTxInfo endpoint documentation
  2. Update the /bridge and /swap endpoint documentation to include the transaction data in their response structures
  3. Uncomment the documentation once updated

Let's verify if there are any remaining references to the deprecated endpoints in other documentation files:


Let me gather more information about the updated API endpoints to ensure we provide accurate guidance.


Let me check the blog post and other API documentation to understand the full scope of the API changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for references to deprecated endpoints in documentation
rg -i "bridgeTxInfo|swapTxInfo" docs/

Length of output: 1552


Script:

#!/bin/bash
# Search for updated endpoint documentation and changelog entries
rg -A 5 -B 5 "consolidated into the /bridge endpoint" docs/

# Check for any other API documentation files
fd -e md -e mdx "api|endpoint" docs/

Length of output: 1966


Script:

#!/bin/bash
# Check the blog post about API changes
cat docs/bridge/blog-posts/2024-10-10-rest-api-post.md

# Check the current /bridge endpoint documentation
rg -A 10 "/bridge" docs/bridge/docs/02-Bridge/02-REST-API.md

Length of output: 7771

packages/rest-api/swagger.json (1)

399-400: Consider enhancing migration documentation

While the deprecation notices are clear, it would be helpful to add more detailed migration guidance for users. Consider:

  1. Adding examples showing how to migrate from the old endpoints to the new ones
  2. Documenting any differences in request/response formats between old and new endpoints
  3. Providing a migration timeline/deadline

Example addition to the description:

-"description": "[Deprecated] Originally used to get Bridge transaction information",
+"description": "[Deprecated] Originally used to get Bridge transaction information. To migrate, use the /bridge endpoint which returns the same transaction data in its response. Migration example: GET /bridgeTxInfo?fromChain=1&... -> GET /bridge?fromChain=1&... The /bridge response includes the transaction data in the returned quote object. Migration deadline: December 2024",

Also applies to: 1348-1349

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between aec6dce and e5d43fb.

📒 Files selected for processing (4)
  • docs/bridge/docs/02-Bridge/02-REST-API.md (2 hunks)
  • packages/rest-api/src/routes/bridgeTxInfoRoute.ts (1 hunks)
  • packages/rest-api/src/routes/swapTxInfoRoute.ts (1 hunks)
  • packages/rest-api/swagger.json (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/rest-api/src/routes/bridgeTxInfoRoute.ts
🔇 Additional comments (4)
packages/rest-api/src/routes/swapTxInfoRoute.ts (2)

21-22: LGTM! Documentation changes align with PR objectives.

The OpenAPI documentation now correctly indicates that this endpoint is deprecated in favor of /swap.


21-22: Verify the replacement endpoint implementation.

Since this endpoint is being deprecated in favor of /swap, we should verify:

  1. The existence and documentation of the /swap endpoint
  2. Feature parity between the endpoints
  3. Non-breaking changes for existing clients
✅ Verification successful

Let me gather more information about the /swap endpoint implementation.


Deprecation notice is accurate and well-implemented

The /swap endpoint fully replaces /swapTxInfo with enhanced functionality:

  • It provides all the original transaction information
  • Adds call data when an address is provided
  • Has comprehensive OpenAPI documentation
  • Maintains backward compatibility with additional features

The migration path is clear:

  • Original endpoint is properly marked as deprecated
  • Documentation explicitly points users to the /swap endpoint
  • New endpoint has identical base functionality plus enhancements
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the replacement endpoint implementation

# Check if the /swap endpoint exists and is documented
echo "Checking for /swap endpoint implementation..."
fd -t f "swapRoute.ts" "packages/rest-api/src/routes"

# Check OpenAPI documentation for /swap endpoint
echo "Checking OpenAPI documentation for /swap endpoint..."
rg -A 10 "/swap:" "packages/rest-api/src/**/*.ts"

# Look for any existing usages of /swapTxInfo that need migration
echo "Checking for existing usages that need migration..."
rg -g "!*.{md,txt}" "/swapTxInfo"

Length of output: 2231


Script:

#!/bin/bash
# Check the implementation and documentation of /swap endpoint
echo "Checking /swap endpoint implementation..."
cat packages/rest-api/src/routes/swapRoute.ts

echo "\nChecking swagger documentation..."
cat packages/rest-api/swagger.json | jq '.paths."/swap"'

echo "\nChecking for call data in /swap response..."
rg -A 5 "callData" packages/rest-api/src/controllers/swapController.ts

Length of output: 13562

packages/rest-api/swagger.json (2)

399-400: LGTM! Clear deprecation notice for /bridgeTxInfo

The deprecation notice clearly indicates that users should migrate to the /bridge endpoint which now includes the transaction data in its response.


1348-1349: LGTM! Clear deprecation notice for /swapTxInfo

The deprecation notice clearly indicates that users should migrate to the /swap endpoint which now includes the transaction data in its response.

Comment on lines +21 to +22
* summary: "[Deprecated] in favor of using the /swap endpoint, which now returns call data
* description: "[Deprecated] Originally used to get Swap transaction information
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance deprecation handling with proper HTTP headers and migration guidance.

While the documentation indicates deprecation, the implementation should follow API deprecation best practices:

  1. Add a deprecation warning header to responses
  2. Include a sunset date
  3. Provide specific migration steps to the new /swap endpoint

Consider implementing these changes:

 router.get(
   '/',
   normalizeNativeTokenAddress(['fromToken', 'toToken']),
   checksumAddresses(['fromToken', 'toToken']),
+  (req, res, next) => {
+    res.set({
+      'Deprecation': 'true',
+      'Sunset': '2025-01-01',
+      'Link': '</swap>; rel="successor-version"',
+      'Warning': '299 - "This endpoint is deprecated. Please migrate to /swap endpoint which provides the same functionality plus call data."'
+    });
+    next();
+  },
   [
     check('chain')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* summary: "[Deprecated] in favor of using the /swap endpoint, which now returns call data
* description: "[Deprecated] Originally used to get Swap transaction information
* summary: "[Deprecated] in favor of using the /swap endpoint, which now returns call data
* description: "[Deprecated] Originally used to get Swap transaction information
router.get(
'/',
normalizeNativeTokenAddress(['fromToken', 'toToken']),
checksumAddresses(['fromToken', 'toToken']),
(req, res, next) => {
res.set({
'Deprecation': 'true',
'Sunset': '2025-01-01',
'Link': '</swap>; rel="successor-version"',
'Warning': '299 - "This endpoint is deprecated. Please migrate to /swap endpoint which provides the same functionality plus call data."'
});
next();
},
[
check('chain')

@@ -17,6 +26,7 @@ Get read-only data from on-chain Synapse contracts, and generate Bridge and Swap
| Date | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 2024&#8209;10&#8209;01 | [https://synapse-rest-api-v2.herokuapp.com/](https://synapse-rest-api-v2.herokuapp.com/) is no longer maintained and has been fully deprecated as of October 2024. |
| 2024&#8209;11&#8209;19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) the /bridgeTxInfo endpoint has been consolidated into the /bridge endpoint, which now returns call data |
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Complete the version history entry

The version history entry should mention both endpoint consolidations and provide clear migration guidance.

Update the entry to include both changes:

-| 2024&#8209;11&#8209;19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) the /bridgeTxInfo endpoint has been consolidated into the /bridge endpoint, which now returns call data                   |
+| 2024&#8209;11&#8209;19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) - The `/bridgeTxInfo` and `/swapTxInfo` endpoints have been consolidated into the `/bridge` and `/swap` endpoints respectively. The consolidated endpoints now return transaction data directly. Users should update their integrations accordingly. |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| 2024&#8209;11&#8209;19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) the /bridgeTxInfo endpoint has been consolidated into the /bridge endpoint, which now returns call data |
| 2024&#8209;11&#8209;19 | [https://api.synapseprotocol.com/](https://api.synapseprotocol.com/) - The `/bridgeTxInfo` and `/swapTxInfo` endpoints have been consolidated into the `/bridge` and `/swap` endpoints respectively. The consolidated endpoints now return transaction data directly. Users should update their integrations accordingly. |

Copy link

codecov bot commented Nov 19, 2024

Bundle Report

Changes will decrease total bundle size by 3.51MB (-9.86%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sdk-router-@synapsecns/sdk-router-esm* 255.26kB 609 bytes (0.24%) ⬆️
sdk-router-@synapsecns/sdk-router-cjs* 117.55kB 312 bytes (0.27%) ⬆️
explorer-ui-server-cjs* 724.75kB 141.31kB (-16.32%) ⬇️
explorer-ui-client-array-push* 2.17MB 146.19kB (-6.32%) ⬇️
synapse-interface-client-array-push* 7.41MB 132.39kB (1.82%) ⬆️
synapse-interface-server-cjs* 1.65MB 160.39kB (10.73%) ⬆️
widget-cjs-esm* 271.27kB 2.03kB (-0.74%) ⬇️
docs-bridge-client-array-push 7.34MB 563.15kB (-7.13%) ⬇️
docs-bridge-server-cjs 11.57MB 3.3MB (-22.21%) ⬇️
synapse-constants-esm-cjs* 174.63kB 174.63kB (100%) ⬆️
synapse-constants-cjs-esm* 174.18kB 174.18kB (100%) ⬆️

ℹ️ *Bundle size includes cached data from a previous commit

@Defi-Moses Defi-Moses merged commit fc48390 into master Nov 19, 2024
38 of 39 checks passed
@Defi-Moses Defi-Moses deleted the docs/api-improvements branch November 19, 2024 17:02
This was referenced Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant