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

fix: Add missing return types for Transmissions and Activities in OpenAPI spec #1244

Merged
merged 10 commits into from
Oct 10, 2024

Conversation

oskogstad
Copy link
Collaborator

@oskogstad oskogstad commented Oct 7, 2024

Description

Related Issue(s)

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)

Documentation

  • Documentation is updated (either in docs-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)

Summary by CodeRabbit

  • New Features

    • Introduced multiple new schemas for dialog activity and transmission handling, enhancing metadata management.
    • Updated API endpoints to return detailed lists of dialog activities and their attachments.
    • Enhanced data structures with new properties for better clarity and functionality in dialog activities and transmissions.
    • Improved Swagger configurations for better documentation clarity and specificity for dialog activity and transmission endpoints.
    • Added support for notification conditions in the API, improving the handling of related queries.
  • Bug Fixes

    • Improved response structure of dialog activity and transmission endpoints to ensure accurate data retrieval.

@oskogstad oskogstad requested a review from a team as a code owner October 7, 2024 14:53
Copy link
Contributor

coderabbitai bot commented Oct 7, 2024

📝 Walkthrough

Walkthrough

The pull request introduces multiple new schemas and updates existing ones in the OpenAPI specification for the Dialogporten API. New schemas include various DTOs related to dialog activities and transmissions, enhancing the API's capability to provide detailed information. The endpoints have been updated to return these new schemas, and property descriptions and types have been refined for consistency.

Changes

File Path Change Summary
docs/schema/V1/swagger.verified.json Added new schemas: GetDialogActivityDto, GetDialogActivityDtoSO, GetDialogActivityPerformedByActorDto, GetDialogActivityPerformedByActorDtoSO, GetDialogDialogTransmissionAttachmentDto, GetDialogDialogTransmissionAttachmentDtoSO, GetDialogDialogTransmissionAttachmentUrlDto, GetDialogDialogTransmissionAttachmentUrlDtoSO, GetDialogDialogTransmissionContentDto, GetDialogDialogTransmissionContentDtoSO, GetDialogDialogTransmissionDto, GetDialogDialogTransmissionDtoSO, SearchDialogActivityDto, SearchDialogActivityDtoSO, SearchDialogTransmissionAttachmentDto, SearchDialogTransmissionAttachmentDtoSO, SearchDialogTransmissionAttachmentUrlDto, SearchDialogTransmissionAttachmentUrlDtoSO, SearchDialogTransmissionContentDto, SearchDialogTransmissionContentDtoSO, SearchDialogTransmissionDto, SearchDialogTransmissionDtoSO, SearchDialogTransmissionSenderActorDto, and SearchDialogTransmissionSenderActorDtoSO. Updated existing schemas to reference new attachment schemas and refined property descriptions and types.
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivityEndpoint.cs Updated class signature to extend Endpoint<GetDialogActivityQuery, GetDialogActivityDto>, allowing it to return a DTO.
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivitySwaggerConfig.cs Updated ProducesOneOf method to specify GetDialogActivityDto, clarifying the expected response type.
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Search/SearchDialogActivityEndpoint.cs Updated class signature to extend Endpoint<SearchDialogActivityQuery, List<SearchDialogActivityDto>>, enabling it to return a list of DTOs.
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Get/GetDialogActivitySwaggerConfig.cs Updated ProducesOneOf method to specify GetDialogActivityDto. Added a new class GetDialogActivityEndpointSummary for endpoint documentation.
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/NotificationCondition/NotificationConditionEndpoint.cs Updated class signature to extend Endpoint<NotificationConditionQuery, NotificationConditionDto>, allowing it to return a DTO.
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/NotificationCondition/NotificationConditionSwaggerConfig.cs Added new class NotificationConditionSwaggerConfig implementing ISwaggerConfig and defined methods for operation ID and description. Updated SearchDialogActivityEndpointSummary constructor for enhanced documentation.
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Search/SearchDialogActivityEndpoint.cs Updated class signature to extend Endpoint<SearchDialogActivityQuery, List<SearchDialogActivityDto>>, enabling it to return a list of DTOs.

Possibly related PRs

Suggested reviewers

  • MagnusSandgren

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 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.

elsand
elsand previously approved these changes Oct 8, 2024
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: 7

🧹 Outside diff range and nitpick comments (3)
src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/MappingProfile.cs (1)

Line range hint 1-37: Summary: DTO renaming in AutoMapper configurations

The changes in this file involve renaming two DTOs in the AutoMapper configurations:

  1. GetDialogTransmissionAttachmentDto to GetDialogDialogTransmissionAttachmentDto
  2. GetDialogTransmissionAttachmentUrlDto to GetDialogDialogTransmissionAttachmentUrlDto

These modifications align with the PR objective of improving the clarity and completeness of the API documentation. The changes are consistent and don't introduce any logical alterations or new functionality.

To maintain consistency and prevent future naming discrepancies, consider implementing a naming convention guideline for DTOs and enforcing it through code reviews or static analysis tools.

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/GetDialogTransmissionDto.cs (2)

26-29: Improve the XML documentation for clarity

The summary for IsAuthorized has a minor grammatical error and can be clarified. Consider rephrasing it as:

"Flag indicating whether the authenticated user is authorized for this transmission. If not, the embedded content and attachments will not be available."


112-118: Ensure consistent collection initialization

In GetDialogTransmissionAttachmentDto, the lists DisplayName and Urls are initialized using the shorthand syntax = [];. While this is acceptable in modern C#, ensure that this style is consistently used throughout the codebase and aligns with your team's coding standards.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 28ab757 and 8829345.

📒 Files selected for processing (10)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/GetDialogTransmissionDto.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/GetDialogDto.cs (3 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/MappingProfile.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/GetDialogTransmissionDto.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogDto.cs (3 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/MappingProfile.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/MappingProfile.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogTransmissions/Get/GetDialogTransmissionSwaggerConfig.cs (2 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogTransmissions/Search/SearchDialogTransmissionSwaggerConfig.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogTransmissions/Get/GetDialogTransmissionSwaggerConfig.cs (2 hunks)
🧰 Additional context used
🔇 Additional comments (18)
src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/MappingProfile.cs (2)

33-34: LGTM. Verify renamed DTO usage and custom mapping.

The mapping from GetDialogDialogTransmissionAttachmentUrlDto to AttachmentUrl looks correct, including the custom mapping for ConsumerType. This change aligns with the renaming mentioned in the summary.

To ensure consistency and correct functionality, let's verify the usage of the renamed DTO and the custom mapping across the codebase:

#!/bin/bash
# Description: Check for any remaining occurrences of the old DTO name, confirm usage of the new name, and verify the custom mapping.

# Test 1: Search for any remaining occurrences of the old name
echo "Searching for any remaining occurrences of 'GetDialogTransmissionAttachmentUrlDto':"
rg --type csharp 'GetDialogTransmissionAttachmentUrlDto'

# Test 2: Confirm usage of the new name
echo "Confirming usage of 'GetDialogDialogTransmissionAttachmentUrlDto':"
rg --type csharp 'GetDialogDialogTransmissionAttachmentUrlDto'

# Test 3: Verify the custom mapping for ConsumerType
echo "Verifying custom mapping for ConsumerType:"
rg --type csharp 'ConsumerType' -C 3

32-32: LGTM. Verify renamed DTO usage.

The mapping from GetDialogDialogTransmissionAttachmentDto to Attachment looks correct. This change aligns with the renaming mentioned in the summary.

To ensure consistency, let's verify the usage of the renamed DTO across the codebase:

✅ Verification successful

LGTM. Renamed DTO usage verified successfully.

No remaining occurrences of GetDialogTransmissionAttachmentDto found in the codebase. The mapping from GetDialogDialogTransmissionAttachmentDto to Attachment has been successfully updated.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining occurrences of the old DTO name and confirm usage of the new name.

# Test 1: Search for any remaining occurrences of the old name
echo "Searching for any remaining occurrences of 'GetDialogTransmissionAttachmentDto':"
rg --type csharp 'GetDialogTransmissionAttachmentDto'

# Test 2: Confirm usage of the new name
echo "Confirming usage of 'GetDialogDialogTransmissionAttachmentDto':"
rg --type csharp 'GetDialogDialogTransmissionAttachmentDto'

Length of output: 131959

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogTransmissions/Get/GetDialogTransmissionSwaggerConfig.cs (2)

Line range hint 1-40: Summary: Changes align with PR objectives and improve API specification.

The modifications in this file, particularly the explicit return type specification in ProducesOneOf<GetDialogTransmissionDto>, directly address the PR objective of adding missing return types for Transmissions in the OpenAPI spec. The OperationId change also contributes to API consistency.

The GetDialogTransmissionEndpointSummary class remains unchanged, which is appropriate as it already contained the necessary documentation.

Overall, these changes enhance type safety, improve API documentation, and maintain consistency with other parts of the codebase.


13-13: Approve OperationId change, but verify impact.

The change from "GetDialogTransmissionEU" to "GetDialogTransmission" looks good as it simplifies the operation ID. However, ensure that this change is reflected in the API documentation and that any client code relying on this operation ID is updated accordingly.

To verify the impact of this change, run the following script:

✅ Verification successful

OperationId Change Verified

The OperationId has been successfully updated to "GetDialogTransmission" with no references to "GetDialogTransmissionEU" found in the codebase. Ensure that the API documentation and any external client code are updated accordingly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for occurrences of the old operation ID in the codebase

# Search for the old operation ID
echo "Searching for 'GetDialogTransmissionEU':"
rg --type-not cs "GetDialogTransmissionEU"

# Search for potential client code using the old operation ID
echo "Searching for potential client code using 'GetDialogTransmissionEU':"
rg --type cs "GetDialogTransmissionEU"

# Check if the new operation ID is used consistently
echo "Checking for consistent use of 'GetDialogTransmission':"
rg --type cs "GetDialogTransmission"

Length of output: 5336


Script:

#!/bin/bash
# Description: Confirm the usage of the new operation ID in the codebase

echo "Searching for 'GetDialogTransmission':"
rg --type cs "GetDialogTransmission"

Length of output: 13242

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogTransmissions/Get/GetDialogTransmissionSwaggerConfig.cs (1)

17-19: LGTM! Improved Swagger configuration specificity.

The change to ProducesOneOf<GetDialogTransmissionDto> enhances the API documentation by explicitly defining the expected response type for the dialog transmission endpoint. This improvement aligns well with the PR objective of adding missing return types for Transmissions in the OpenAPI spec.

Benefits:

  1. Clearer API contract for consumers
  2. Improved type safety in generated client code
  3. Better alignment with OpenAPI best practices
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/MappingProfile.cs (1)

65-66: Approve the mapping update with suggestions for improvement.

The update to GetDialogDialogTransmissionAttachmentUrlDto is consistent with the previous change and aligns with the PR objectives. However, consider the following points:

  1. The naming convention with repeated "Dialog" seems redundant. Consider simplifying it to GetDialogTransmissionAttachmentUrlDto or justifying the repetition.
  2. Ensure that this change is consistently applied across the codebase to maintain coherence.

To verify the impact and consistency of this change, run the following script:

#!/bin/bash
# Search for usages of the old and new DTO names
echo "Searching for old DTO name (GetDialogTransmissionAttachmentUrlDto):"
rg "GetDialogTransmissionAttachmentUrlDto" --type cs

echo "\nSearching for new DTO name (GetDialogDialogTransmissionAttachmentUrlDto):"
rg "GetDialogDialogTransmissionAttachmentUrlDto" --type cs

echo "\nChecking for any remaining inconsistencies:"
rg "DialogTransmissionAttachmentUrl.*Dto" --type cs
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogDto.cs (4)

240-240: Improved naming consistency for transmission attachments.

The change from List<GetDialogTransmissionAttachmentDto> to List<GetDialogDialogTransmissionAttachmentDto> enhances the naming consistency. This new name more clearly indicates that these attachments are specifically for dialog transmissions.


Line range hint 639-654: Enhanced clarity in class naming for transmission attachments.

The renaming of GetDialogTransmissionAttachmentDto to GetDialogDialogTransmissionAttachmentDto and the update of the Urls property type improve the clarity of the class hierarchy. These changes make it more explicit that these DTOs are specifically related to dialog transmissions.


657-657: Consistent renaming for transmission attachment URL DTO.

The renaming of GetDialogTransmissionAttachmentUrlDto to GetDialogDialogTransmissionAttachmentUrlDto is consistent with the previous changes. This maintains a uniform naming convention throughout the related DTOs, enhancing the overall clarity of the code structure.


Line range hint 1-680: Summary: Improved naming consistency enhances code clarity.

The changes in this file are part of a broader refactoring effort to improve naming consistency across the DTO classes related to dialog transmissions and attachments. By explicitly including "Dialog" in the class names, the relationship between these DTOs and the dialog context is now more apparent. This enhancement in naming conventions contributes to better code readability and maintainability, making it easier for developers to understand the purpose and context of each DTO.

While no functional changes were introduced, these naming improvements are valuable for the long-term maintainability of the codebase. Good job on this refactoring effort!

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/GetDialogDto.cs (4)

230-230: Property type updated for better consistency

The property type for Attachments has been updated from GetDialogTransmissionAttachmentDto to GetDialogDialogTransmissionAttachmentDto. This change improves naming consistency across the codebase.


Line range hint 632-647: Class and property type renamed for consistency

The GetDialogTransmissionAttachmentDto class has been renamed to GetDialogDialogTransmissionAttachmentDto, and the Urls property type has been updated to GetDialogDialogTransmissionAttachmentUrlDto. These changes improve naming consistency across the codebase.


Line range hint 650-674: Class renamed for consistency

The GetDialogTransmissionAttachmentUrlDto class has been renamed to GetDialogDialogTransmissionAttachmentUrlDto. This change improves naming consistency across the codebase.


Line range hint 1-674: Summary: Improved naming consistency across DTO classes

The changes in this file focus on renaming classes and updating property types to improve naming consistency across the codebase. Specifically:

  1. GetDialogTransmissionAttachmentDtoGetDialogDialogTransmissionAttachmentDto
  2. GetDialogTransmissionAttachmentUrlDtoGetDialogDialogTransmissionAttachmentUrlDto
  3. Updated property types to reflect the new class names

These changes enhance the readability and maintainability of the code without introducing any logical modifications or potential issues.

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/GetDialogTransmissionDto.cs (3)

112-112: ⚠️ Potential issue

Fix incorrect list initialization syntax for Urls property

At line 112, the Urls property is initialized using an empty array [], which is invalid in C#. To initialize a list, use new List<GetDialogTransmissionAttachmentUrlDto>() or new().

Apply this diff to fix the issue:

- public List<GetDialogTransmissionAttachmentUrlDto> Urls { get; set; } = [];
+ public List<GetDialogTransmissionAttachmentUrlDto> Urls { get; set; } = new();

Likely invalid or redundant comment.


107-107: ⚠️ Potential issue

Fix incorrect list initialization syntax for DisplayName property

At line 107, the DisplayName property is initialized using an empty array [], which is invalid in C#. To initialize a list, use new List<LocalizationDto>() or new().

Apply this diff to fix the issue:

- public List<LocalizationDto> DisplayName { get; set; } = [];
+ public List<LocalizationDto> DisplayName { get; set; } = new();

Likely invalid or redundant comment.


58-58: ⚠️ Potential issue

Fix incorrect list initialization syntax for Attachments property

At line 58, the Attachments property is initialized using an empty array [], which is invalid in C#. To initialize a list, use new List<GetDialogTransmissionAttachmentDto>() or new().

Apply this diff to fix the issue:

- public List<GetDialogTransmissionAttachmentDto> Attachments { get; set; } = [];
+ public List<GetDialogTransmissionAttachmentDto> Attachments { get; set; } = new();

Likely invalid or redundant comment.

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/GetDialogTransmissionDto.cs (1)

139-145: ⚠️ Potential issue

Remove unnecessary null initialization for nullable properties

In GetDialogTransmissionAttachmentUrlDto, the property MediaType is declared as nullable (string?) and is initialized to null!. Since MediaType is already nullable, the initialization to null! is unnecessary and can be omitted.

Apply this diff to fix the issue:

-public string? MediaType { get; set; } = null!;
+public string? MediaType { get; set; }

Likely invalid or redundant comment.

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

🧹 Outside diff range and nitpick comments (1)
docs/schema/V1/swagger.verified.json (1)

2561-2565: LGTM: Added id property to transmission attachment DTOs

The addition of the id property with a GUID format to GetDialogTransmissionAttachmentDto, GetDialogTransmissionAttachmentDtoSO, GetDialogTransmissionAttachmentUrlDto, and GetDialogTransmissionAttachmentUrlDtoSO is a good improvement. This allows for unique identification of attachments and attachment URLs, enhancing tracking and management capabilities.

Consider adding a brief description for the id property in each DTO to clarify its purpose and usage, similar to other properties in the schema. For example:

"id": {
  "description": "The unique identifier for the transmission attachment in UUIDv7 format.",
  "format": "guid",
  "type": "string"
}

Also applies to: 2592-2596

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8829345 and 21b05e9.

📒 Files selected for processing (1)
  • docs/schema/V1/swagger.verified.json (12 hunks)
🧰 Additional context used
🔇 Additional comments (3)
docs/schema/V1/swagger.verified.json (3)

1745-1846: LGTM: New transmission attachment DTOs added

The new schemas for GetDialogDialogTransmissionAttachmentDto, GetDialogDialogTransmissionAttachmentDtoSO, GetDialogDialogTransmissionAttachmentUrlDto, and GetDialogDialogTransmissionAttachmentUrlDtoSO have been successfully added. These additions provide a clear structure for handling dialog transmission attachments, with appropriate separation between end-user and service owner DTOs.


1897-1897: LGTM: Updated references to new attachment DTOs

The GetDialogDialogTransmissionDto and GetDialogDialogTransmissionDtoSO have been updated to reference the newly added GetDialogDialogTransmissionAttachmentDto and GetDialogDialogTransmissionAttachmentDtoSO respectively. This change ensures consistency and provides a more detailed structure for transmission attachments.

Also applies to: 1966-1966


5492-5497: LGTM: Updated transmission endpoints to use new DTOs

The API endpoints for transmissions have been successfully updated to use the new DTO structures:

  1. GetDialogTransmissionList now returns an array of SearchDialogTransmissionDto
  2. GetDialogTransmission now returns a GetDialogTransmissionDto
  3. Corresponding changes have been made for the service owner (SO) versions of these endpoints

These updates provide more detailed and consistent information about transmissions, aligning with best practices for API design by using search DTOs for list endpoints and detailed DTOs for individual transmission retrieval.

Also applies to: 5546-5552, 6894-6899, 7053-7059

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

🧹 Outside diff range and nitpick comments (5)
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Search/SearchDialogActivityEndpoint.cs (1)

9-9: LGTM! Consider adding XML documentation.

The change to Endpoint<SearchDialogActivityQuery, List<SearchDialogActivityDto>> is a good improvement. It explicitly defines the return type, enhancing type safety and API clarity.

Consider adding XML documentation to the class to describe its purpose and the return type. This would further improve the API documentation:

/// <summary>
/// Endpoint for searching dialog activities.
/// </summary>
/// <remarks>
/// This endpoint returns a list of SearchDialogActivityDto objects.
/// </remarks>
public sealed class SearchDialogActivityEndpoint : Endpoint<SearchDialogActivityQuery, List<SearchDialogActivityDto>>
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/NotificationCondition/NotificationConditionSwaggerConfig.cs (2)

Line range hint 19-19: Implement GetExample method or provide a reason for the exception.

The GetExample method is currently throwing a NotImplementedException. Consider implementing this method to provide an example for the Swagger documentation, or if it's intentionally left unimplemented, add a comment explaining why.

Would you like assistance in implementing the GetExample method or adding an explanatory comment?


Line range hint 22-36: LGTM: SearchDialogActivityEndpointSummary implementation with a minor suggestion.

The implementation of SearchDialogActivityEndpointSummary is well-structured and informative. The summary, description, and response definitions are clear and follow best practices.

Consider extracting the formatted string for the 401 Unauthorized response into a constant or a separate method for better maintainability and reusability. For example:

private static string GetUnauthorizedMessage(string scope) =>
    Constants.SwaggerSummary.ServiceOwnerAuthenticationFailure.FormatInvariant(scope);

// Usage in constructor
Responses[StatusCodes.Status401Unauthorized] = GetUnauthorizedMessage(AuthorizationScope.NotificationConditionCheck);

This change would make it easier to update the message format in the future if needed.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Get/GetDialogActivitySwaggerConfig.cs (1)

Line range hint 24-39: Great addition: GetDialogActivityEndpointSummary class improves API documentation.

The new GetDialogActivityEndpointSummary class significantly enhances the API documentation by providing clear and concise descriptions for the endpoint and its various response scenarios. This addition:

  1. Improves the overall clarity of the API.
  2. Aligns with best practices for API documentation.
  3. Uses constants for common response descriptions, promoting consistency across the API.

Excellent work on improving the documentation!

Consider adding a brief example or more specific details about what information is returned in the 200 OK response. This could further enhance the usefulness of the documentation for API consumers.

docs/schema/V1/swagger.verified.json (1)

Line range hint 1-7289: Consistent naming conventions with room for description improvements

The specification demonstrates consistent use of naming conventions:

  • camelCase for properties
  • PascalCase for schema names

Descriptions are provided for most properties and schemas, which is commendable. However, there's potential for enhancing some descriptions to provide more context or examples, particularly for complex properties or those with specific constraints.

Consider reviewing and potentially expanding descriptions for properties that might benefit from additional context or examples, especially for complex data types or properties with specific constraints or usage scenarios.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 21b05e9 and 93ee798.

📒 Files selected for processing (8)
  • docs/schema/V1/swagger.verified.json (22 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivityEndpoint.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivitySwaggerConfig.cs (2 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Search/SearchDialogActivityEndpoint.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Get/GetDialogActivitySwaggerConfig.cs (2 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/NotificationCondition/NotificationConditionEndpoint.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/NotificationCondition/NotificationConditionSwaggerConfig.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Search/SearchDialogActivityEndpoint.cs (1 hunks)
🧰 Additional context used
🔇 Additional comments (17)
src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Search/SearchDialogActivityEndpoint.cs (1)

9-9: Verify OpenAPI specification update

The change in the return type should be reflected in the OpenAPI specification. Please ensure that the corresponding OpenAPI documentation has been updated to show that this endpoint returns a list of SearchDialogActivityDto objects.

Run the following script to check if the OpenAPI specification has been updated:

If the script doesn't return any results, it might indicate that the OpenAPI specification hasn't been updated to reflect the change in the return type.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivityEndpoint.cs (1)

9-9: LGTM! Consider updating the OpenAPI specification.

The change to include GetDialogActivityDto as the return type in the Endpoint<> generic parameter is a good improvement. It enhances type safety and aligns with the PR objective of adding missing return types.

To ensure consistency, please verify that the OpenAPI specification has been updated to reflect this change. You can run the following script to check for updates in the OpenAPI spec file:

If the OpenAPI spec hasn't been updated, consider adding this task to your PR checklist.

✅ Verification successful

Verified! The OpenAPI specification has been updated accordingly.

The GetDialogActivityDto is correctly referenced in the swagger.verified.json, ensuring that the OpenAPI specification reflects the changes made in the endpoint. No further action is required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for updates in the OpenAPI spec file related to GetDialogActivityDto

# Test: Search for GetDialogActivityDto in the OpenAPI spec file
rg --type yaml 'GetDialogActivityDto' -C 5

Length of output: 42


Script:

#!/bin/bash
# Description: Comprehensive search for 'GetDialogActivityDto' in OpenAPI specification files (YAML and JSON)

# Search in YAML and JSON files for 'GetDialogActivityDto'
rg --type yaml --type json 'GetDialogActivityDto' -C 5

Length of output: 2949

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Search/SearchDialogActivityEndpoint.cs (3)

9-9: Improved type safety and API contract clarity.

The updated class signature now includes the response type List<SearchDialogActivityDto>. This change:

  1. Aligns with FastEndpoints best practices.
  2. Enhances type safety.
  3. Makes the API contract more explicit.
  4. Provides better documentation for API consumers.

Line range hint 28-35: LGTM: HandleAsync implementation consistent with updated signature.

The HandleAsync method implementation is already aligned with the updated class signature. It correctly handles the list of DTOs returned by _sender.Send(req, ct) and uses appropriate pattern matching for different response scenarios. No changes were needed in the method body, which demonstrates good forward-thinking in the original design.


Line range hint 1-35: Summary: Improved API contract with minimal code changes.

The update to SearchDialogActivityEndpoint enhances the API contract by explicitly specifying the response type List<SearchDialogActivityDto> in the class signature. This change:

  1. Improves type safety and clarity.
  2. Aligns with FastEndpoints best practices.
  3. Requires no changes to the existing method implementations, indicating a well-designed initial structure.

The focused nature of this change minimizes the risk of introducing bugs while significantly improving the API's documentation and type safety.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/NotificationCondition/NotificationConditionEndpoint.cs (1)

9-9: Improved type safety and API documentation

The addition of NotificationConditionDto as a second generic type parameter to the Endpoint<> base class is a positive change. It explicitly defines the response type for this endpoint, which:

  1. Enhances type safety by ensuring the endpoint returns the expected DTO.
  2. Improves API documentation, aligning with the PR objective of adding missing return types for Transmissions in the OpenAPI spec.
  3. Makes the class signature consistent with the HandleAsync method implementation, which already returns a DTO.

This change contributes to a more robust and self-documenting API design.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivitySwaggerConfig.cs (3)

16-18: Excellent addition of the return type specification!

The change to ProducesOneOf<GetDialogActivityDto>() is a valuable improvement. It explicitly defines the return type for the GetDialogActivity operation, which enhances the clarity and accuracy of the API documentation. This modification aligns perfectly with the PR objective of adding missing return types for Transmissions in the OpenAPI spec.

Benefits of this change:

  1. Improved API documentation
  2. Better type safety
  3. Enhanced developer experience for API consumers

Line range hint 20-20: Verify the intention of GetExample() method

The GetExample() method is currently throwing a NotImplementedException. While this might be intentional, it's worth confirming if this is the desired behavior or if there's a plan to implement this method in the future.

If it's intentional, consider adding a comment explaining why the method is not implemented. If it's meant to be implemented later, you might want to add a TODO comment.

Could you please clarify the intention behind this implementation?


Line range hint 1-39: Overall, the changes and existing code look good

The modification to explicitly specify the return type in ProducesOneOf<GetDialogActivityDto>() is a valuable improvement to the API documentation. The rest of the file, including the comprehensive GetDialogActivityEndpointSummary, is well-structured and informative.

The only suggestion for potential improvement is to clarify the intention behind the GetExample() method implementation.

Great job on enhancing the API documentation!

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/NotificationCondition/NotificationConditionSwaggerConfig.cs (2)

13-18: LGTM: NotificationConditionSwaggerConfig implementation.

The implementation of NotificationConditionSwaggerConfig looks good. The OperationId property and SetDescription method are well-defined and follow best practices.


Line range hint 1-36: Overall, the file is well-implemented with minor suggestions for improvement.

The NotificationConditionSwaggerConfig and SearchDialogActivityEndpointSummary classes are well-structured and follow best practices. The suggested improvements (implementing GetExample and extracting the unauthorized message) are minor and would enhance maintainability without affecting functionality.

src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/DialogActivities/Get/GetDialogActivitySwaggerConfig.cs (2)

1-1: LGTM: New using statement added correctly.

The new using statement for Digdir.Domain.Dialogporten.Application.Features.V1.ServiceOwner.DialogActivities.Queries.Get is correctly added. This import is necessary for the GetDialogActivityDto used in the ProducesOneOf method.


17-19: Excellent: Return type specified for ProducesOneOf method.

The ProducesOneOf method has been updated to explicitly specify GetDialogActivityDto as the return type. This change:

  1. Improves the clarity of the API specification.
  2. Aligns with the PR objective of adding missing return types for Transmissions in the OpenAPI spec.
  3. Enhances type safety and documentation.

Great job on making this improvement!

docs/schema/V1/swagger.verified.json (4)

Line range hint 943-2984: New schemas added successfully

The new schemas (GetDialogActivityDto, GetDialogActivityDtoSO, GetDialogActivityPerformedByActorDto, GetDialogActivityPerformedByActorDtoSO, GetDialogDialogTransmissionAttachmentDto, GetDialogDialogTransmissionAttachmentDtoSO, GetDialogDialogTransmissionAttachmentUrlDto, GetDialogDialogTransmissionAttachmentUrlDtoSO, GetDialogTransmissionContentDto, GetDialogTransmissionContentDtoSO, GetDialogTransmissionDto, and GetDialogTransmissionDtoSO) have been added correctly. They follow consistent naming conventions and have well-defined properties with appropriate types and descriptions.


Line range hint 2685-2984: Existing schemas updated appropriately

The modifications to existing schemas have been implemented correctly:

  1. GetDialogTransmissionAttachmentDto and GetDialogTransmissionAttachmentDtoSO now include an 'id' field, providing a unique identifier for attachments.
  2. GetDialogTransmissionDto and GetDialogTransmissionDtoSO have been updated to reference the newly defined attachment schemas, ensuring consistency with the new structure.

These changes improve the overall coherence of the API specification.


Line range hint 1-7289: Proper use of OpenAPI specification features

The OpenAPI specification demonstrates correct usage of OpenAPI 3.0.0 features:

  1. Well-structured components and schemas
  2. Properly defined path operations
  3. Correct use of $ref for schema reuse
  4. Appropriate definition and application of security schemes

The overall structure follows OpenAPI best practices, making the API documentation clear and easy to understand.


Line range hint 1-7289: Summary: Comprehensive and well-implemented API specification updates

The changes made to the Dialogporten API OpenAPI specification are comprehensive and well-implemented. Key improvements include:

  1. Addition of new schemas for activities, transmissions, and related entities
  2. Updates to existing schemas to maintain consistency with the new structure
  3. Consistent use of naming conventions and descriptive property documentation
  4. Proper utilization of OpenAPI 3.0.0 features

These updates significantly enhance the clarity and completeness of the API documentation, which will benefit both API consumers and maintainers. The structure remains coherent, and the new additions integrate seamlessly with the existing specification.

Great job on improving the Dialogporten API documentation!

@oskogstad oskogstad changed the title fix: Add missing return types for Transmissions in OpenAPI spec fix: Add missing return types for Transmissions and Activities in OpenAPI spec Oct 8, 2024
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: 1

🧹 Outside diff range and nitpick comments (1)
docs/schema/V1/swagger.verified.json (1)

Line range hint 1876-2097: Transmission schemas are well-structured, but consider simplifying names

The new Transmission-related schemas (GetDialogDialogTransmissionAttachmentDto, GetDialogDialogTransmissionAttachmentDtoSO, etc.) are well-structured and provide detailed representations for transmissions, their attachments, and content. They follow the good practice of separating end-user and service owner views.

However, there's some redundancy in the naming. Consider simplifying the names by removing one instance of "Dialog" from each. For example:

  • GetDialogDialogTransmissionAttachmentDto -> GetDialogTransmissionAttachmentDto
  • GetDialogDialogTransmissionContentDto -> GetDialogTransmissionContentDto

This would make the names more concise while still maintaining clarity.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 93ee798 and 9b86f71.

📒 Files selected for processing (1)
  • docs/schema/V1/swagger.verified.json (22 hunks)
🧰 Additional context used
🔇 Additional comments (2)
docs/schema/V1/swagger.verified.json (2)

943-1073: New Activity schemas look good!

The newly added schemas (GetDialogActivityDto, GetDialogActivityDtoSO, GetDialogActivityPerformedByActorDto, GetDialogActivityPerformedByActorDtoSO) are well-structured and consistent with existing naming conventions. They provide a clear separation between end-user and service owner views, which is a good practice for maintaining different levels of information access.


Line range hint 2692-2930: Updates to existing Transmission schemas look good

The updates to existing schemas (GetDialogTransmissionAttachmentDto, GetDialogTransmissionAttachmentDtoSO, GetDialogTransmissionDto, GetDialogTransmissionDtoSO) successfully incorporate references to the newly added schemas. These changes enhance the detail and structure of the transmission-related data while maintaining consistency with the new schemas.

The updates appear to be well-implemented and should improve the overall representation of transmission data in the API.

docs/schema/V1/swagger.verified.json Show resolved Hide resolved
Copy link

sonarcloud bot commented Oct 9, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
14.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@oskogstad oskogstad merged commit 972870d into main Oct 10, 2024
21 of 22 checks passed
@oskogstad oskogstad deleted the fix/open-api-broken-return-type-on-transmissions branch October 10, 2024 08:16
oskogstad pushed a commit that referenced this pull request Oct 10, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.23.0](v1.22.0...v1.23.0)
(2024-10-10)


### Features

* **infra:** upgrade postgresql SKU in test
([#1257](#1257))
([5a751af](5a751af))
* **webAPI:** Add legacy HTML support for MainContentReference
([#1256](#1256))
([482b38a](482b38a))


### Bug Fixes

* Add missing return types for Transmissions and Activities in OpenAPI
spec ([#1244](#1244))
([972870d](972870d))
* **graphQL:** Missing MediaType on dialog attachment url
([#1264](#1264))
([3919343](3919343))
* Refactor probes and add more health checks
([#1159](#1159))
([6889a96](6889a96))
* **webapi:** ensure correct health checks are used in probes
([#1249](#1249))
([f951152](f951152))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
@coderabbitai coderabbitai bot mentioned this pull request Oct 12, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants