Skip to content

Conversation

@mfaferek93
Copy link
Collaborator

@mfaferek93 mfaferek93 commented Nov 29, 2025

  • GET / now returns server capabilities and entry points per REQ_INTEROP_010 (name, version, endpoints list, capabilities object)
  • Add GET /version-info for version information per REQ_INTEROP_001 (status, version, timestamp)
  • Update test_01_root_endpoint to verify capabilities response
  • Add test_01b_version_info_endpoint for new endpoint
  • Update Postman collection with new requests

Pull Request

Summary

Briefly describe what changed and why.


Issue

Link the related issue (required):


Type

  • Bug fix
  • New feature or tests
  • Breaking change
  • Documentation only

Testing

How was this tested / how should reviewers verify it?


Checklist

  • Breaking changes are clearly described (and announced in docs / changelog if needed)
  • Tests were added or updated if needed
  • Docs were updated if behavior or public API changed

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the gateway's root endpoint to provide server capabilities discovery (REQ_INTEROP_010) and adds a new /version-info endpoint for version information (REQ_INTEROP_001). The changes improve API discoverability by clearly separating concerns: the root endpoint now serves as a capabilities and endpoints directory, while the new endpoint provides runtime version and status information.

  • Modified GET / to return server capabilities (name, version, endpoints list, capabilities object) instead of just status and version
  • Added GET /version-info endpoint to provide status, version, and timestamp information
  • Updated integration tests to verify both endpoint responses with comprehensive assertions

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/ros2_medkit_gateway/src/rest_server.cpp Refactored handle_root() to return capabilities response; added handle_version_info() for new endpoint
src/ros2_medkit_gateway/include/ros2_medkit_gateway/rest_server.hpp Added handle_version_info() method declaration
src/ros2_medkit_gateway/test/test_integration.test.py Updated test_01_root_endpoint to verify capabilities; added test_01b_version_info_endpoint
postman/collections/ros2-medkit-gateway.postman_collection.json Renamed "GET Gateway Info" to "GET Server Capabilities"; added "GET Version Info" request with descriptions
Comments suppressed due to low confidence (1)

src/ros2_medkit_gateway/src/rest_server.cpp:204

  • The version string "0.1.0" is hardcoded in two places (lines 171 and 204). Consider extracting this to a constant or reading from package.xml to maintain consistency and simplify version management. This would prevent version mismatches between the package.xml and the API responses.
            {"version", "0.1.0"},
            {"endpoints", json::array({
                "/health",
                "/version-info",
                "/areas",
                "/components",
                "/areas/{area_id}/components",
                "/components/{component_id}/data",
                "/components/{component_id}/data/{topic_name}"
            })},
            {"capabilities", {
                {"discovery", true},
                {"data_access", true}
            }}
        };

        res.set_content(response.dump(2), "application/json");
    } catch (const std::exception& e) {
        res.status = StatusCode::InternalServerError_500;
        res.set_content(
            json{{"error", "Internal server error"}}.dump(),
            "application/json"
        );
        RCLCPP_ERROR(rclcpp::get_logger("rest_server"), "Error in handle_root: %s", e.what());
    }
}

void RESTServer::handle_version_info(const httplib::Request& req, httplib::Response& res) {
    (void)req;  // Unused parameter

    try {
        json response = {
            {"status", "ROS 2 Medkit Gateway running"},
            {"version", "0.1.0"},

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

bburda
bburda previously approved these changes Nov 29, 2025
Copy link
Collaborator

@bburda bburda left a comment

Choose a reason for hiding this comment

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

LGTM

@mfaferek93 mfaferek93 changed the base branch from 19/GET/components/component_id/data/topic_name to main November 29, 2025 19:17
@mfaferek93 mfaferek93 dismissed bburda’s stale review November 29, 2025 19:17

The base branch was changed.

  - GET / now returns server capabilities and entry points per REQ_INTEROP_010
    (name, version, endpoints list, capabilities object)
  - Add GET /version-info for version information per REQ_INTEROP_001
    (status, version, timestamp)
  - Update test_01_root_endpoint to verify capabilities response
  - Add test_01b_version_info_endpoint for new endpoint
  - Update Postman collection with new requests
@mfaferek93 mfaferek93 merged commit 9984654 into main Nov 29, 2025
3 checks passed
@mfaferek93 mfaferek93 deleted the 40/fix/GET/root branch December 6, 2025 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working milestone-1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] GET / returns version info instead of server capabilities

2 participants