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

Development: Add check for REST endpoints to be in kebab case #9210

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from

Conversation

SimonEntholzer
Copy link
Contributor

@SimonEntholzer SimonEntholzer commented Aug 12, 2024

Checklist

General

  • I tested all changes and their related features with all corresponding user types on a test server.
  • This is a small issue that I tested locally and was confirmed by another developer on a test server.
  • I chose a title conforming to the naming conventions for pull requests.

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).

Client

Motivation and Context

The Artemis documentation states that REST endpoints should be written in kebab case: documentation

Description

This PR adds a test in the ResourceArchitecureTest.java, to check if all REST endpoints use kebab-case (and not camel case e.g.), and fixes the endpoints which are not defined correctly.

Steps for Testing

In theory functionality wise nothing should have changed, as only some endpoint URLs were refactored/renamed.
You can check if features related to the following refactored endpoints still work correctly:

  1. LTI onlineCourseConfiguration
  2. lockedSubmissions, withLatestResult
  3. exerciseGroups
  4. cleanupBuildPlan, buildArtifact
  5. aeolus templateScripts

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Screenshots

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Updated URL paths for various REST API endpoints to improve consistency and readability, including:
      • templateScripts to template-scripts
      • onlineCourseConfiguration to online-course-configuration
      • lockedSubmissions to locked-submissions
      • exerciseGroups to exercise-groups
      • cleanupBuildPlan to cleanup-build-plan
      • buildArtifact to build-artifact
  • Bug Fixes

    • Corrected URL references in test cases to align with the updated endpoint naming conventions.
  • Documentation

    • Updated documentation to reflect the revised URL structures for enhanced usability.

@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) cypress Pull requests that update cypress tests. (Added Automatically!) labels Aug 16, 2024
@SimonEntholzer SimonEntholzer changed the title Development: Architecture test for checking if REST calls use kebab case Development: Add check if REST endpoints use kebab case Aug 16, 2024
@SimonEntholzer SimonEntholzer added ready for review and removed cypress Pull requests that update cypress tests. (Added Automatically!) labels Aug 16, 2024
@SimonEntholzer SimonEntholzer marked this pull request as ready for review August 16, 2024 07:37
@SimonEntholzer SimonEntholzer requested a review from a team as a code owner August 16, 2024 07:37
Copy link

coderabbitai bot commented Aug 16, 2024

Walkthrough

The recent changes involve standardizing REST API endpoint URLs by replacing camelCase with hyphenated formats across various resources. This adjustment enhances clarity and consistency while ensuring that existing functionalities remain unchanged. The updates affect multiple classes and services, streamlining the API structure and updating documentation accordingly.

Changes

Files Change Summary
src/main/java/de/tum/in/www1/artemis/web/rest/AeolusTemplateResource.java, CourseResource.java, ExamResource.java, ExerciseGroupResource.java, ParticipationResource.java Updated URL paths for multiple endpoints to use hyphens instead of camelCase for improved readability.
src/main/webapp/app/course/manage/course-management.service.ts, exam/manage/exam-management.service.ts, exercises/programming/shared/service/aeolus.service.ts, exercises/shared/participation/participation.service.ts Altered HTTP request URLs to integrate hyphenated formats while maintaining existing functionality.
src/test/cypress/support/pageobjects/exam/ExamExerciseGroupCreationPage.ts, support/requests/ExamAPIRequests.ts Standardized URL patterns in test files to align with updated RESTful conventions.
src/test/java/de/tum/in/www1/artemis/... (various test files) Modified API endpoint URLs in tests to reflect new hyphenated naming conventions, ensuring compliance with updated paths.
src/test/java/de/tum/in/www1/artemis/architecture/ResourceArchitectureTest.java Added tests to enforce kebab-case naming conventions for REST endpoints across the application.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant Service

    Client->>API: GET /template-scripts/{language}/{projectType}
    API->>Service: Route request to getAeolusTemplateScript
    Service-->>API: Return template script
    API-->>Client: Send template script response
Loading
sequenceDiagram
    participant Client
    participant API
    participant Service

    Client->>API: PUT /courses/{courseId}/online-course-configuration
    API->>Service: Update course configuration
    Service-->>API: Acknowledge update
    API-->>Client: Confirmation response
Loading

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 or @coderabbitai title 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.

Tip

Early access features: enabled

We are currently testing new code review model(s) that may lead to higher noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

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: 9

@SimonEntholzer SimonEntholzer changed the title Development: Add check if REST endpoints use kebab case Development: Add check for REST endpoints to kebab case Aug 16, 2024
@github-actions github-actions bot added the cypress Pull requests that update cypress tests. (Added Automatically!) label Aug 16, 2024
iyannsch
iyannsch previously approved these changes Sep 13, 2024
Copy link
Contributor

@iyannsch iyannsch left a comment

Choose a reason for hiding this comment

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

reapprove code

N0W0RK
N0W0RK previously approved these changes Sep 14, 2024
janthoXO
janthoXO previously approved these changes Sep 21, 2024
Copy link
Contributor

@janthoXO janthoXO left a comment

Choose a reason for hiding this comment

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

looks good
does it make sense to add a test for the client side as well? or maybe something that gives at least a compiler warning when using an URL in a httpclient method that is not in kebab case

@SimonEntholzer
Copy link
Contributor Author

looks good does it make sense to add a test for the client side as well? or maybe something that gives at least a compiler warning when using an URL in a httpclient method that is not in kebab case

Might be useful, but I'm not sure on how that would be achieved, and I'm also not sure if it would be worth the effort. Especially because this test here, will not allow any corresponding endpoints at the server, so the client couldn't really use such an endpoint anyway.

@SimonEntholzer SimonEntholzer changed the title Development: Add check for REST endpoints to kebab case Development: Add check for REST endpoints to be in kebab case Sep 22, 2024
Copy link
Contributor

@pzdr7 pzdr7 left a comment

Choose a reason for hiding this comment

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

Thanks for the quick change. Code

Copy link

@raffifasaro raffifasaro left a comment

Choose a reason for hiding this comment

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

Code LGTM

Copy link
Contributor

@asliayk asliayk left a comment

Choose a reason for hiding this comment

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

code lgtm

Copy link
Contributor

@iyannsch iyannsch left a comment

Choose a reason for hiding this comment

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

Reapprove code

Copy link
Contributor

@Strohgelaender Strohgelaender left a comment

Choose a reason for hiding this comment

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

code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) code quality playwright ready for review server Pull requests that update Java code. (Added Automatically!) tests
Projects
Status: Ready For Review
Development

Successfully merging this pull request may close these issues.

10 participants