[#40] fix: return server capabilities at GET / and add GET /version-info#42
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
bb5bfc1 to
16201cf
Compare
- 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
16201cf to
9b778c4
Compare
bburda
approved these changes
Nov 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
Briefly describe what changed and why.
Issue
Link the related issue (required):
Type
Testing
How was this tested / how should reviewers verify it?
Checklist