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

feat: endpoint /api/v1/genes/lookup with OpenAPI (#587) #589

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

holtgrewe
Copy link
Contributor

@holtgrewe holtgrewe commented Nov 13, 2024

Summary by CodeRabbit

  • New Features

    • Updated gene lookup endpoint to /api/v1/genes/lookup, with the previous endpoint marked as deprecated.
    • Introduced new request structure GenesLookupQuery and response structures GenesLookupResponse and GenesLookupResultEntry for improved clarity and functionality.
    • Enhanced OpenAPI documentation for the gene lookup service, including new response types and detailed endpoint information.
  • Bug Fixes

    • Streamlined error handling for gene database availability.
  • Documentation

    • Expanded API documentation to include new components and endpoint details.

@holtgrewe holtgrewe linked an issue Nov 13, 2024 that may be closed by this pull request
@holtgrewe holtgrewe changed the title feat: endpoint /api/v1/genes/search with OpenAPI (#587) feat: endpoint /api/v1/genes/lookup with OpenAPI (#587) Nov 13, 2024
@holtgrewe holtgrewe enabled auto-merge (squash) November 13, 2024 08:54
Copy link

coderabbitai bot commented Nov 13, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request focus on updating the gene lookup functionality in the server's API. The endpoint has been changed from /genes/lookup to /api/v1/genes/lookup, with the previous endpoint marked as deprecated. A new GenesLookupQuery struct replaces the old Request struct, and the handling functions have been refactored for better separation of concerns. The OpenAPI documentation has been enhanced to include the new endpoint and response types, improving the API's clarity and usability.

Changes

File Path Change Summary
src/server/run/genes_lookup.rs - Updated endpoint from /genes/lookup to /api/v1/genes/lookup (deprecated previous endpoint).
- Replaced Request struct with pub(crate) struct GenesLookupQuery.
- Refactored handle function into handle_impl and handle_with_openapi.
- Introduced pub(crate) struct GenesLookupResultEntry and pub(crate) struct GenesLookupResponse for response handling.
- Streamlined error handling and response formatting.
src/server/run/mod.rs - Integrated genes_lookup::handle_with_openapi into OpenAPI documentation.
- Added GenesLookupResponse and GenesLookupResultEntry to OpenAPI components schemas.
openapi.schema.yaml - Added new endpoint /api/v1/genes/lookup with method GET.
- Defined query parameter q and response schemas GenesLookupResponse and GenesLookupResultEntry.

Possibly related issues

Possibly related PRs

  • feat: endpoint /api/v1/genes/lookup with OpenAPI (#587) #589: The changes in this PR directly relate to the main PR as they both involve the implementation of the /api/v1/genes/lookup endpoint, including the introduction of the GenesLookupQuery, GenesLookupResponse, and GenesLookupResultEntry structs, as well as the refactoring of the handling functions.

Poem

In the garden where genes reside,
A new path blooms, with joy and pride.
From old to new, the changes flow,
With clearer signs for all to know.
Hops and skips, let’s celebrate,
A brighter API, oh, how great! 🐇✨

Warning

Rate limit exceeded

@holtgrewe has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 66055a2 and 19bf233.


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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@holtgrewe holtgrewe force-pushed the 587-add-endpoint-apiv1geneslookup-with-openapi-schema branch from 66055a2 to 19bf233 Compare November 13, 2024 09:02
Copy link

@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: 0

🧹 Outside diff range and nitpick comments (4)
src/server/run/genes_lookup.rs (4)

65-66: Update the function docstring to reflect accurate functionality

The docstring for the handle function currently states:

/// Query for annotations for one variant.

However, this function handles gene lookups, not variant annotations. Please update the docstring to accurately describe its purpose to maintain clarity and consistency in the codebase.


89-89: Complete the incomplete docstring

The docstring for GenesLookupResponse is incomplete:

/// Result for `async fn handle_with_openapi(

Please provide a full description of the GenesLookupResponse struct to enhance code readability and maintain proper documentation standards.


81-81: Remove the unnecessary trailing comma in the comment

The comment for the query field has an extra comma:

/// The query string,

Please remove the trailing comma for grammatical correctness:

/// The query string

68-76: Deprecation notice for the old endpoint

The function handle still provides the deprecated /genes/lookup endpoint. To assist users in migrating to the new API version, consider adding a deprecation warning or response header indicating that this endpoint will be removed in future releases.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c3e92ea and 66055a2.

📒 Files selected for processing (2)
  • src/server/run/genes_lookup.rs (4 hunks)
  • src/server/run/mod.rs (4 hunks)
🔇 Additional comments (4)
src/server/run/mod.rs (4)

41-41: LGTM: Clean import of new gene lookup types

The import follows the module's naming conventions and is properly grouped with other response type imports.


58-58: LGTM: Proper integration of gene lookup handler in OpenAPI paths

The handler is correctly placed and maintains the alphabetical ordering of endpoints.


120-121: LGTM: Complete schema documentation for gene lookup types

Both response and entry types are properly included in the OpenAPI components schemas, maintaining alphabetical order.


149-149: Verify the endpoint transition strategy

The code shows both genes_lookup::handle and genes_lookup::handle_with_openapi services being registered. While this allows for a smooth transition, we should ensure there's a plan to:

  1. Mark the old endpoint as deprecated
  2. Communicate the deprecation to API consumers
  3. Eventually remove the old endpoint
✅ Verification successful

Transition strategy is already properly implemented

The code shows a well-implemented transition strategy:

  1. The old endpoint /genes/lookup is properly marked as deprecated in the module documentation.
  2. The new endpoint /api/v1/genes/lookup is documented with OpenAPI.
  3. Both endpoints share the same implementation through handle_impl, ensuring consistent behavior.
  4. The transition is part of a broader API versioning effort (v1) as seen in the changelog.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the old endpoint is marked as deprecated in the handler
rg -A 5 "genes_lookup::handle.*deprecated" 

# Look for any documentation about the deprecation
fd README.md --exec grep -A 5 "genes/lookup.*deprecated" {} \;

Length of output: 112


Script:

#!/bin/bash
# Check both handler implementations
ast-grep --pattern 'fn handle($$$) {
  $$$
}'

# Look for any OpenAPI documentation or deprecation notices
rg -l "genes.*lookup" 

# Check if there are any deprecation markers in the code
rg -i "deprecat" 

Length of output: 533


Script:

#!/bin/bash
# Check the specific content of genes_lookup.rs to see how deprecation is handled
cat src/server/run/genes_lookup.rs

# Check changelog for any mentions of the transition
cat CHANGELOG.md

Length of output: 41745

@holtgrewe holtgrewe merged commit a71d62a into main Nov 13, 2024
8 checks passed
@holtgrewe holtgrewe deleted the 587-add-endpoint-apiv1geneslookup-with-openapi-schema branch November 13, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add endpoint /api/v1/genes/lookup with OpenAPI schema
1 participant