SAK-52288 webapi Add scorm rest documentation#14336
SAK-52288 webapi Add scorm rest documentation#14336adrianfish wants to merge 2 commits intosakaiproject:masterfrom
Conversation
https://sakaiproject.atlassian.net/browse/SAK-52288 This change also normalises the test file layout, bringing the scorm test into the same package as the other tests.
WalkthroughUpdated documentation URL and added SCORM API docs; refactored ScormController formatting and changed getSession to return 404 when missing; reorganized test packages to Changes
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
webapi/src/test/java/org/sakaiproject/webapi/controllers/test/LoginControllerTests.java (2)
106-114: Replacevarwith explicit types per coding guidelines.The use of
varfor local variable type inference violates the project's coding guidelines. Explicit types are required for all local variable declarations.♻️ Proposed fix
- var auth = mock(Authentication.class); + Authentication auth = mock(Authentication.class); when(authenticationManager.authenticate(any())).thenReturn(auth); - var session = mock(Session.class); + Session session = mock(Session.class); when(session.getId()).thenReturn("session1"); when(sessionManager.startSession()).thenReturn(session); - var username = "user1"; - var password = "password1"; + String username = "user1"; + String password = "password1";
135-136: Replacevarwith explicit types.Same issue as above—use explicit
Stringtype declarations.♻️ Proposed fix
- var username = "user1"; - var password = "password1"; + String username = "user1"; + String password = "password1";
🤖 Fix all issues with AI agents
In
`@webapi/src/test/java/org/sakaiproject/webapi/controllers/test/ScormControllerTest.java`:
- Around line 153-157: The test "closeSessionReturnsNoContent" expects 204 but
ScormController.closeSession() currently returns void with no `@ResponseStatus`,
producing 200; fix by adding `@ResponseStatus`(HttpStatus.NO_CONTENT) to the
ScormController.closeSession method (to follow REST best practices) and update
the test in ScormControllerTest.closeSessionReturnsNoContent to assert
status().isNoContent() so the controller and test agree.
🧹 Nitpick comments (2)
webapi/src/test/java/org/sakaiproject/webapi/controllers/test/BaseControllerTests.java (1)
58-62: Empty catch block silently swallows exceptions.While the fallback to the original URI is reasonable, the empty catch block loses diagnostic information that could help debugging. Consider logging the exception.
♻️ Suggested improvement
public URI getUri() { try { return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), "/api" + uri.getPath(), uri.getQuery(), uri.getFragment()); - } catch (Exception e) { + } catch (Exception e) { + // URI construction failed; fall back to original } return uri; }webapi/src/main/asciidoc/webapi.adoc (1)
69-81: Consider adding the session cookie reminder for consistency.Other API sections (Announcements, Calendar) include
__See the login api about session cookies__to remind users about authentication. The Scorm API section would benefit from the same note.♻️ Suggested addition
=== Scorm API +__See the login api about session cookies__ + Create a Scorm session: include::{snippets}/create-scorm-session/http-request.adoc[]
https://sakaiproject.atlassian.net/browse/SAK-52288
This change also normalises the test file layout, bringing the scorm test into the same package as the other tests.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.