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

chore: Exclude Microsoft.AspNetCore namespace from swagger #1414

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

Fargekritt
Copy link
Contributor

@Fargekritt Fargekritt commented Nov 7, 2024

Description

Related Issue(s)

  • #{issue number}

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 new schemas for dialog and transmission management, enhancing the API's capabilities.
  • Improvements
    • Renamed existing schemas for better clarity and organization.
    • Updated API documentation to accurately reflect current implementation.
  • Bug Fixes
    • Adjusted references in the schema to ensure correct paths for newly named components.

@Fargekritt Fargekritt requested a review from a team as a code owner November 7, 2024 08:04
Copy link
Contributor

coderabbitai bot commented Nov 7, 2024

📝 Walkthrough

Walkthrough

The pull request introduces significant changes to the swagger.verified.json file, including the renaming of specific schema components and the addition of new schemas related to dialog and transmission management. The TypeNameConverter class has also been updated to exclude the Microsoft.AspNetCore namespace from type name generation. These modifications enhance the clarity of the API documentation and ensure that it accurately reflects the current implementation.

Changes

File Path Change Summary
docs/schema/V1/swagger.verified.json - Renamed schemas: MicrosoftAspNetCoreJsonPatchOperations_OperationJsonPatchOperations_Operation
- Renamed schemas: MicrosoftAspNetCoreJsonPatchOperations_OperationTypeJsonPatchOperations_OperationType
- Added schemas: V1ServiceOwnerDialogsCommandsCreate_DialogCommand, V1ServiceOwnerDialogsCommandsUpdate_Dialog, V1ServiceOwnerDialogTransmissionsCreate_TransmissionRequest, V1ServiceOwnerDialogTransmissionsQueriesGet_Transmission, V1ServiceOwnerDialogTransmissionsQueriesGet_Content, V1ServiceOwnerDialogTransmissionsQueriesGet_Attachment, V1ServiceOwnerDialogTransmissionsQueriesGet_AttachmentUrl, V1ServiceOwnerDialogTransmissionsQueriesSearch_Transmission, V1ServiceOwnerDialogTransmissionsQueriesSearch_Attachment, V1ServiceOwnerDialogTransmissionsQueriesSearch_AttachmentUrl, V1ServiceOwnerDialogTransmissionsQueriesSearch_Content
src/Digdir.Domain.Dialogporten.WebApi/Common/Swagger/TypeNameConverter.cs - Added "Microsoft.AspNetCore." to ExcludedNamespacePrefixes array in TypeNameConverter. No changes to public entity declarations.

Possibly related PRs

  • chore: Manually set operationId of Patch #1410: The changes in this PR involve updates to the swagger.verified.json file, specifically the operation IDs for dialog-related endpoints, which directly relates to the modifications made in the main PR regarding schema updates and naming conventions in the same file.

Suggested reviewers

  • knuhau

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.

Copy link

sonarqubecloud bot commented Nov 7, 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: 0

🧹 Outside diff range and nitpick comments (1)
src/Digdir.Domain.Dialogporten.WebApi/Common/Swagger/TypeNameConverter.cs (1)

18-21: Consider adding a comment explaining the namespace exclusion rationale.

While the implementation is correct, it would be helpful to document why certain namespaces are excluded, particularly for maintenance purposes.

Add a comment above the array:

     private static readonly string[] ExcludedNamespacePostfixes = [];
+    // Exclude common framework and internal namespaces to produce cleaner type names in Swagger documentation
     private static readonly string[] ExcludedNamespacePrefixes =
     [
         "FastEndpoints",
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ca18a99 and 6c98e14.

📒 Files selected for processing (2)
  • docs/schema/V1/swagger.verified.json (4 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Common/Swagger/TypeNameConverter.cs (1 hunks)
🔇 Additional comments (4)
src/Digdir.Domain.Dialogporten.WebApi/Common/Swagger/TypeNameConverter.cs (1)

19-20: LGTM! Changes align with PR objectives.

The addition of "Microsoft.AspNetCore." to the excluded namespaces will simplify type names in the Swagger documentation by removing this common prefix.

Let's verify the impact on the swagger documentation:

✅ Verification successful

Changes are safe and working as intended

The addition of "Microsoft.AspNetCore." to ExcludedNamespacePrefixes is correctly implemented and will effectively exclude Microsoft.AspNetCore namespaces from type names in Swagger documentation. The code shows:

  1. The TypeNameConverter is properly used in Program.cs for Swagger type name conversion
  2. The implementation correctly handles namespace exclusions through the ExcludePrefix method
  3. The change aligns with existing exclusion patterns like "FastEndpoints" and "Digdir.Domain.Dialogporten.*"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining Microsoft.AspNetCore references in swagger files
# that might have been missed by this change

# Look for any Microsoft.AspNetCore references in swagger files
rg -t json "Microsoft\.AspNetCore" --glob "swagger*.json"

Length of output: 59


Script:

#!/bin/bash
# Let's first check if there are any swagger files in the repository
fd "swagger.*\.json$"

# Let's also check the implementation of TypeNameConverter to understand its usage
rg -l "TypeNameConverter"

# And examine how the TypeNameConverter is being used
ast-grep --pattern 'class TypeNameConverter {
  $$$
}'

Length of output: 347


Script:

#!/bin/bash
# Let's examine the verified swagger file to check if type names are properly shortened
cat docs/schema/V1/swagger.verified.json

# Let's also check how TypeNameConverter is used in Program.cs
rg -A 5 "TypeNameConverter" src/Digdir.Domain.Dialogporten.WebApi/Program.cs

# And check its implementation
cat src/Digdir.Domain.Dialogporten.WebApi/Common/Swagger/TypeNameConverter.cs

Length of output: 269512

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

Line range hint 149-192: LGTM: Clean namespace rename from MicrosoftAspNetCore to JsonPatch

The schema renaming from MicrosoftAspNetCoreJsonPatchOperations_Operation to JsonPatchOperations_Operation and MicrosoftAspNetCoreJsonPatchOperations_OperationType to JsonPatchOperations_OperationType has been implemented correctly. The schema structure remains unchanged and all references have been properly updated.


6051-6051: LGTM: Endpoint schema reference updated correctly

The PATCH endpoint's schema reference has been properly updated to use the renamed JsonPatchOperations_Operation schema, maintaining consistency with the namespace changes.


Line range hint 1-6500: Verify complete removal of Microsoft.AspNetCore namespace

Let's verify that all references to the Microsoft.AspNetCore namespace have been removed from the specification.

✅ Verification successful

Based on the search results, there are still multiple references to Microsoft.AspNetCore namespace in the codebase, but the file we're reviewing (docs/schema/V1/swagger.verified.json) does not contain any such references. The search results show references in other files like Program.cs, Controllers, and test projects, but none in the swagger specification file.

No Microsoft.AspNetCore references found in the swagger specification

The swagger specification has been properly cleaned up and does not contain any references to Microsoft.AspNetCore namespace. All references found are in the actual implementation files which is expected since the project uses ASP.NET Core framework.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to Microsoft.AspNetCore
# Test: Expect no matches as all references should have been renamed

echo "Searching for Microsoft.AspNetCore references..."
rg -i "microsoft\.aspnetcore" 

echo "Searching for MicrosoftAspNetCore references..."
rg -i "microsoftaspnetcore"

Length of output: 5512

@Fargekritt Fargekritt changed the title chore : Exclude Microsoft.AspNetCore namespace in swagger chore : Exclude Microsoft.AspNetCore namespace from swagger Nov 7, 2024
@Fargekritt Fargekritt changed the title chore : Exclude Microsoft.AspNetCore namespace from swagger chore: Exclude Microsoft.AspNetCore namespace from swagger Nov 7, 2024
@Fargekritt Fargekritt merged commit 7f84176 into main Nov 11, 2024
23 of 26 checks passed
@Fargekritt Fargekritt deleted the chore/exclude-microsoftAspNetCore-from-swagger branch November 11, 2024 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants