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

622-ergaenzen-der-apiresponses-annotation-wahlvorbereitung-service #932

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

DanielOber
Copy link
Contributor

@DanielOber DanielOber commented Mar 9, 2025

Beschreibung:

  • neue default config für swagger hinzugefügt
  • api-responses angepasst, falls nötig

Definition of Done (DoD):

Backend

  • Swagger-API vollständig

Referenzen1:

Verwandt mit Issue #622

Closes #

Summary by CodeRabbit

  • Chores

    • Upgraded the core dependency and integrated new Swagger support to improve overall service performance and enable API documentation enhancements.
  • Documentation

    • Enhanced API documentation across multiple endpoints by detailing response codes and descriptions, providing clearer guidance and expectations for API consumers.

Footnotes

  1. Nicht zutreffende Referenzen vor dem Speichern entfernen

Copy link
Contributor

coderabbitai bot commented Mar 9, 2025

Walkthrough

The pull request updates the dependency configuration and enhances API documentation across several components. In the project's Maven configuration, the version for a common library is updated (from 1.2.0 to 1.4.0) and a new Swagger dependency is added. The Spring Boot application's package scanning is extended to include a Swagger-related package. Across multiple controller classes, the OpenAPI documentation is refined by adding explicit response annotations to the endpoint operations. These annotations now specify expected HTTP response codes (such as 200 and 201) along with their corresponding descriptions for both GET and POST methods. Additionally, any necessary import statements for these annotations are incorporated.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 generate docstrings to generate docstrings for this 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 or `` to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or `` 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.

Copy link
Contributor

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

🧹 Nitpick comments (2)
wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/waehlerverzeichnis/WaehlerverzeichnisController.java (2)

45-51: Document all possible response scenarios.

The GET method can return either an OK response with a body or a NO_CONTENT response (204) as indicated by the okWithBodyOrNoContent method call on line 55. Consider documenting both possible response types.

@Operation(
        description = "Angaben über das Wählerverzeichnis des Urnenwahllokals {wahlbezirkID}",
        responses = {
                @ApiResponse(
                        responseCode = "200", description = "Wählerverzeichnis erfolgreich zurückgegeben."
-                ) }
+                ),
+                @ApiResponse(
+                        responseCode = "204", description = "Kein Wählerverzeichnis für den angegebenen Wahlbezirk und die Wählerverzeichnisnummer gefunden."
+                ) 
+        }
)

32-51: Consider documenting potential error responses.

Both methods only document successful responses but don't document potential error responses (e.g., 400 for invalid input, 404 for resource not found, 500 for server errors). Consider adding these to provide comprehensive API documentation.

Example for additional API responses:

@ApiResponse(responseCode = "400", description = "Ungültige Eingabe oder Format."),
@ApiResponse(responseCode = "404", description = "Wahlbezirk oder Wählerverzeichnis nicht gefunden."),
@ApiResponse(responseCode = "500", description = "Serverfehler bei der Verarbeitung der Anfrage.")
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e87f55 and a6e0944.

📒 Files selected for processing (9)
  • wls-wahlvorbereitung-service/pom.xml (2 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/MicroServiceApplication.java (1 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/briefwahlvorbereitung/BriefwahlvorbereitungController.java (2 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/eroeffnungsuhrzeit/EroeffnungsUhrzeitController.java (2 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/fortsetzungsuhrzeit/FortsetzungsUhrzeitController.java (2 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/unterbrechungsuhrzeit/UnterbrechungsUhrzeitController.java (2 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/urnenwahlschliessungsuhrzeit/UrnenwahlSchliessungsUhrzeitController.java (2 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/urnenwahlvorbereitung/UrnenwahlvorbereitungController.java (2 hunks)
  • wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/waehlerverzeichnis/WaehlerverzeichnisController.java (3 hunks)
🔇 Additional comments (21)
wls-wahlvorbereitung-service/pom.xml (2)

40-40: LGTM: Dependency version update

The version update for wls.common.version from 1.2.0 to 1.4.0 looks good as it enables access to the latest features and improvements.


165-169: LGTM: Added Swagger dependency

This addition of the Swagger dependency from the wls-common library aligns well with the PR objective of adding a default configuration for Swagger to enhance API documentation.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/MicroServiceApplication.java (1)

31-32: LGTM: Added Swagger package to component scanning

The inclusion of the swagger package in scanBasePackages is necessary to enable the Spring component scanning to detect the swagger configuration classes from the newly added dependency.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/fortsetzungsuhrzeit/FortsetzungsUhrzeitController.java (3)

6-6: LGTM: Added import for ApiResponse

Added the necessary import for the ApiResponse annotation used in the OpenAPI documentation.


27-33: LGTM: Enhanced API documentation

Added proper OpenAPI response documentation for the GET endpoint, clearly specifying the expected HTTP 200 response code and description.


41-47: LGTM: Enhanced API documentation

Added proper OpenAPI response documentation for the POST endpoint, clearly specifying the expected HTTP 201 response code and description.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/eroeffnungsuhrzeit/EroeffnungsUhrzeitController.java (2)

6-6: LGTM: Added import for ApiResponse

Added the necessary import for the ApiResponse annotation used in the OpenAPI documentation.


27-33: LGTM: Enhanced API documentation

Added proper OpenAPI response documentation for the GET endpoint, clearly specifying the expected HTTP 200 response code and description.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/unterbrechungsuhrzeit/UnterbrechungsUhrzeitController.java (3)

6-6: Added necessary import for API response documentation.

The import for ApiResponse from the OpenAPI annotations is required for the response documentation that has been added to the operations.


27-33: Improved API documentation with response specifications.

The @Operation annotation has been enhanced with proper response documentation, specifying a 200 status code and description for successful retrieval of the interruption time. This improves the OpenAPI documentation and makes the API behavior more transparent to consumers.


41-47: Completed API documentation with response specifications.

The POST operation now correctly specifies the 201 status code with an appropriate description, which aligns with the actual implementation (see @ResponseStatus(HttpStatus.CREATED) at line 49). This makes the API contract clearer and more consistent.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/urnenwahlvorbereitung/UrnenwahlvorbereitungController.java (3)

6-6: Added necessary import for API response documentation.

The import for ApiResponse from the OpenAPI annotations is required for the response documentation that has been added to the operations.


27-33: Enhanced API documentation with response specifications.

The GET operation now properly documents the 200 response code with a clear description, improving the OpenAPI/Swagger documentation and making the API behavior more transparent to consumers.


41-47: Completed API documentation with appropriate response code.

The POST operation now correctly documents the 201 status code with a descriptive message, which matches the actual implementation (see @ResponseStatus(HttpStatus.CREATED) at line 49). This improves the API contract clarity.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/urnenwahlschliessungsuhrzeit/UrnenwahlSchliessungsUhrzeitController.java (3)

6-6: Added necessary import for API response documentation.

The import for ApiResponse annotation is required for the response documentation that has been added to the operations.


27-33: Improved API documentation with response specifications.

The GET operation now properly documents the 200 response code with a descriptive message, enhancing the OpenAPI/Swagger documentation for this endpoint.


41-47: Enhanced API documentation with proper response code.

The POST operation now correctly specifies the 201 status code with an appropriate description, matching the implementation's @ResponseStatus(HttpStatus.CREATED) at line 49. This ensures consistency between the documented and actual behavior.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/briefwahlvorbereitung/BriefwahlvorbereitungController.java (3)

6-6: Added necessary import for API response documentation.

The import for ApiResponse from the OpenAPI annotations package is required for the response documentation that has been added to the operations.


27-33: Enhanced API documentation with response specifications.

The GET operation now properly documents the 200 response code with a clear description, improving the OpenAPI/Swagger documentation and making the API behavior more transparent to consumers.


41-47: Completed API documentation with appropriate response code.

The POST operation now correctly specifies the 201 status code with a descriptive message, matching the implementation's @ResponseStatus(HttpStatus.CREATED) at line 49. This ensures consistency between the documented and actual behavior.

wls-wahlvorbereitung-service/src/main/java/de/muenchen/oss/wahllokalsystem/wahlvorbereitungservice/rest/waehlerverzeichnis/WaehlerverzeichnisController.java (1)

7-7: Appropriate import for API response documentation.

The import for ApiResponse annotation is correctly added to support the OpenAPI documentation for endpoint responses.

Comment on lines +41 to +47
@Operation(
description = "Aktualisiert die Eroeffnungsuhrzeit des Wahllokals {wahlbezirkID}",
responses = {
@ApiResponse(
responseCode = "201", description = "Fortsetzungsuhrzeit erfolgreich gespeichert."
) }
)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect API response description

The response description for the POST endpoint incorrectly references "Fortsetzungsuhrzeit" instead of "Eroeffnungsuhrzeit".

Apply this diff to fix the description:

-                            responseCode = "201", description = "Fortsetzungsuhrzeit erfolgreich gespeichert."
+                            responseCode = "201", description = "Eroeffnungsuhrzeit erfolgreich gespeichert."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Operation(
description = "Aktualisiert die Eroeffnungsuhrzeit des Wahllokals {wahlbezirkID}",
responses = {
@ApiResponse(
responseCode = "201", description = "Fortsetzungsuhrzeit erfolgreich gespeichert."
) }
)
@Operation(
description = "Aktualisiert die Eroeffnungsuhrzeit des Wahllokals {wahlbezirkID}",
responses = {
@ApiResponse(
responseCode = "201", description = "Eroeffnungsuhrzeit erfolgreich gespeichert."
) }
)

Comment on lines +32 to +36
description = "Speichern der Angaben über das Wählerverzeichnis des Urnenwahllokals {wahlbezirkID}. Wird je aktivem Wählerverzeichnis einmal gespeichert und per wvzNummer dem jeweiligen zugeordnet.",
responses = {
@ApiResponse(
responseCode = "200", description = "Angaben über das Wählerverzeichnis des Urnenwahllokals erfolgreich gespeichert."
) }
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

API response code mismatch with actual endpoint behavior.

There's an inconsistency between the documented response code and the actual behavior of the endpoint. The method is annotated with @ResponseStatus(HttpStatus.CREATED) on line 30, indicating a 201 status code, but the API documentation specifies a 200 response code.

@Operation(
        description = "Speichern der Angaben über das Wählerverzeichnis des Urnenwahllokals {wahlbezirkID}. Wird je aktivem Wählerverzeichnis einmal gespeichert und per wvzNummer dem jeweiligen zugeordnet.",
        responses = {
                @ApiResponse(
-                       responseCode = "200", description = "Angaben über das Wählerverzeichnis des Urnenwahllokals erfolgreich gespeichert."
+                       responseCode = "201", description = "Angaben über das Wählerverzeichnis des Urnenwahllokals erfolgreich gespeichert."
                ) }
)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description = "Speichern der Angaben über das Wählerverzeichnis des Urnenwahllokals {wahlbezirkID}. Wird je aktivem Wählerverzeichnis einmal gespeichert und per wvzNummer dem jeweiligen zugeordnet.",
responses = {
@ApiResponse(
responseCode = "200", description = "Angaben über das Wählerverzeichnis des Urnenwahllokals erfolgreich gespeichert."
) }
@Operation(
description = "Speichern der Angaben über das Wählerverzeichnis des Urnenwahllokals {wahlbezirkID}. Wird je aktivem Wählerverzeichnis einmal gespeichert und per wvzNummer dem jeweiligen zugeordnet.",
responses = {
@ApiResponse(
responseCode = "201", description = "Angaben über das Wählerverzeichnis des Urnenwahllokals erfolgreich gespeichert."
) }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant