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

Update error messages in swagger #814

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

Andreass2
Copy link
Collaborator

@Andreass2 Andreass2 commented Mar 12, 2025

Description

Include specific error messages in swagger

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

Summary by CodeRabbit

  • Documentation
    • Enhanced API documentation to provide detailed response codes and clear error messages.
    • Improved clarity on expected outcomes for various scenarios, ensuring API consumers have better guidance on success and error responses.

Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

📝 Walkthrough

Walkthrough

This pull request updates the XML documentation comments in two controller classes. In both the AttachmentController and CorrespondenceController, method documentation is enhanced with detailed HTTP response codes and descriptions. Each method now specifies various response outcomes (e.g., 200, 400, 401, 404, 502) along with error message details in the <returns> tags. The changes aim to clarify the API's behavior for consumers by providing precise response information for various request scenarios.

Changes

File(s) Change Summary
src/Altinn.Correspondence.API/.../AttachmentController.cs, src/Altinn.Correspondence.API/.../CorrespondenceController.cs Enhanced XML documentation for API methods. In AttachmentController, response codes for methods such as InitializeAttachment, UploadAttachmentData, etc., have been detailed. In CorrespondenceController, documentation now includes comprehensive response code annotations and structured error messages for methods like InitializeCorrespondences, UploadCorrespondences, and several others.

Possibly related PRs

  • Fix scope in xmldoc #797: Modifies scope descriptions in the XML documentation of the AttachmentController, indicating a direct code-level relationship with the documentation changes in this PR.

Suggested labels

kind/documentation, ignore-for-release

Suggested reviewers

  • Ceredron

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 470beb2 and 4a0884a.

📒 Files selected for processing (2)
  • src/Altinn.Correspondence.API/Controllers/AttachmentController.cs (6 hunks)
  • src/Altinn.Correspondence.API/Controllers/CorrespondenceController.cs (10 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (16)
src/Altinn.Correspondence.API/Controllers/AttachmentController.cs (6)

31-42: Great addition of detailed error responses for InitializeAttachment

The detailed response documentation significantly improves the Swagger API documentation by clearly specifying all possible response codes and providing specific error messages for 400 scenarios.


72-85: Well-documented error responses for UploadAttachmentData

Comprehensive documentation of all potential response scenarios including specific 400 error cases, 401 authentication errors, 404 for missing attachments, and 502 for upload failures. This will be very helpful for API consumers.


130-132: Clear response documentation for GetAttachmentOverview

Appropriate response codes and descriptions added for the GetAttachmentOverview endpoint.


162-164: Proper response documentation for GetAttachmentDetails

Good addition of response codes and descriptions that match the ProducesResponseType attributes.


195-204: Thorough error documentation for DeleteAttachment

Excellent documentation of all possible response scenarios, particularly the detailed explanations for various 400 error cases.


234-236: Complete response documentation for DownloadAttachmentData

Good documentation of success and error responses for the download endpoint.

src/Altinn.Correspondence.API/Controllers/CorrespondenceController.cs (10)

43-82: Excellent comprehensive error documentation for InitializeCorrespondences

Very thorough documentation of all possible response scenarios with detailed explanations for various error cases. The bulleted list format makes the different error scenarios easy to understand. This significantly improves the API's usability.


117-156: Well-documented error responses for UploadCorrespondences

Comprehensive documentation matching the InitializeCorrespondences method, which maintains consistency across similar endpoints.


193-201: Good response documentation for GetCorrespondenceOverview

Clear documentation of response codes and descriptions. The slight formatting difference on line 193 (extra space) doesn't affect functionality.


232-240: Clear response documentation for GetCorrespondenceDetails

Proper documentation of response codes and descriptions with the same formatting note as the previous method.


310-318: Well-structured error responses for GetCorrespondences

Good documentation of success and error responses with bulleted lists for better readability.


360-363: Proper response documentation for MarkAsRead

Good documentation of response codes and descriptions, correctly matching the ProducesResponseType attributes.

Also applies to: 369-369


399-402: Clear response documentation for Confirm

Well-documented response scenarios matching the endpoint's behavior.

Also applies to: 408-408


438-441: Appropriate response documentation for Archive

Good documentation of all possible response scenarios.

Also applies to: 447-447


478-487: Detailed error responses for Purge

Excellent documentation of success and error responses with a comprehensive list of potential error scenarios.


523-528: Complete response documentation for DownloadCorrespondenceAttachmentData

Good documentation of all possible response scenarios, particularly distinguishing between different 404 error cases.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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 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 to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@Andreass2 Andreass2 added the kind/documentation Improvements or additions to documentation label Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant