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 prefixes in Swagger TypeNameConverter exlude list #1992

Merged
merged 4 commits into from
Mar 3, 2025

Conversation

oskogstad
Copy link
Collaborator

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)

@oskogstad oskogstad requested a review from a team as a code owner March 3, 2025 09:49
@oskogstad oskogstad changed the title fix: Add missing prefixes in exclude list fix: Add missing prefixes in Swagger TypeNameConverter exlude list Mar 3, 2025
Copy link
Contributor

coderabbitai bot commented Mar 3, 2025

📝 Walkthrough

Walkthrough

This pull request applies extensive renaming and refactoring across the API documentation and client interface code. In the Swagger specification file, several schema names and operation IDs are updated (e.g., replacing "SearchTag" with "Tag" and modifying JWKS-related names). The type name conversion logic is refined by expanding excluded prefixes and streamlining methods. In the Refitter interface, classes and method signatures are renamed to remove redundant suffixes. Additionally, the old schema suffix generator is removed in favor of introducing a new short name generator, with adjustments made in the program configuration for Swagger.

Changes

File(s) Change Summary
docs/schema/V1/swagger.verified.json Renamed multiple API schemas (e.g., *SearchTag*Tag) and updated numerous operation IDs; removed and added JWKS schema definitions.
src/Digdir.Domain…/Common/Swagger/TypeNameConverter.cs Expanded ExcludedClassPrefixes array and streamlined logic in the WriteNonGenericType and ExcludePrefix methods.
src/Digdir.Library…/Features/V1/RefitterInterface.cs Renamed classes and method signatures to remove redundant “Search” suffixes and updated schema reference names for consistency.
src/Digdir.Domain…/Common/Extensions/AspNetCoreOpenApiDocumentGeneratorSettingsExtensions.cs Removed the AddServiceOwnerSuffixToSchemas method that modified schema name generation.
src/Digdir.Domain…/Common/Json/{ShortNameGenerator.cs, SuffixedSchemaNameGenerator.cs} Added a new ShortNameGenerator implementing ISchemaNameGenerator using ToShortName; removed the old SuffixedSchemaNameGenerator class.
src/Digdir.Domain…/Program.cs Replaced the call to AddServiceOwnerSuffixToSchemas() with an assignment of a new ShortNameGenerator to the Swagger schema settings.

Possibly related PRs

Suggested reviewers

  • knuhau
  • MagnusSandgren

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa77a7 and e3a36d5.

📒 Files selected for processing (1)
  • src/Digdir.Library.Dialogporten.WebApiClient.WebApiSample/Program.cs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Dry run deploy apps / Deploy job sync-resource-policy-information-job to test
  • GitHub Check: Dry run deploy apps / Deploy job sync-subject-resource-mappings-job to test
  • GitHub Check: build / build-and-test
🔇 Additional comments (1)
src/Digdir.Library.Dialogporten.WebApiClient.WebApiSample/Program.cs (1)

29-29: Method name updated to remove redundant "Get" prefix

The method call has been updated from V1ServiceOwnerDialogsGetGetDialog to V1ServiceOwnerDialogsGetDialog, removing the duplicated "Get" prefix. This change improves naming consistency in the API and aligns with the PR's objective of refining the Swagger type name conversion logic.

✨ Finishing Touches
  • 📝 Generate Docstrings

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

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

🧹 Nitpick comments (2)
src/Digdir.Domain.Dialogporten.WebApi/Common/Swagger/TypeNameConverter.cs (2)

12-12: Expanded prefix exclusion list enhances naming consistency.

The updated list of excluded prefixes now includes "Purge", "Restore", "Search", and "Get" in addition to the existing prefixes. This change improves naming consistency by removing redundant action verbs from type names when generating API documentation and client code.

This change is a good example of maintaining consistent API naming conventions. By expanding the excluded prefixes, you're ensuring more uniform type names across your API surface, which improves developer experience and code readability.


69-69: Minor white space correction in comment.

A space was removed from the comment text, improving consistency.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7f8cf52 and 1fce871.

📒 Files selected for processing (4)
  • docs/schema/V1/swagger.verified.json (29 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/Common/Swagger/TypeNameConverter.cs (2 hunks)
  • src/Digdir.Library.Dialogporten.WebApiClient.WebApiSample/Program.cs (1 hunks)
  • src/Digdir.Library.Dialogporten.WebApiClient/Features/V1/RefitterInterface.cs (17 hunks)
🔇 Additional comments (27)
src/Digdir.Library.Dialogporten.WebApiClient.WebApiSample/Program.cs (1)

29-29:

✅ Verification successful

Method name updated to match new API naming convention.

The method call has been updated from V1ServiceOwnerDialogsGetGetDialog to V1ServiceOwnerDialogsGetDialog, removing the redundant "Get" prefix. This change aligns with the expanded exclude list in TypeNameConverter.cs.

Let's check if there are any other instances of method calls that might need similar updates:


🏁 Script executed:

#!/bin/bash
# Search for similar method patterns that might still have redundant prefixes
rg -o "V1ServiceOwnerDialogs\w+Get\w+" --type cs

Length of output: 3624


Subject: Verified API Naming Consistency

The method call in src/Digdir.Library.Dialogporten.WebApiClient.WebApiSample/Program.cs was correctly updated from V1ServiceOwnerDialogsGetGetDialog to V1ServiceOwnerDialogsGetDialog, removing the redundant "Get" and aligning with the new API naming convention. In addition, a repository-wide search revealed several method patterns (e.g. V1ServiceOwnerDialogsQueriesGet_Dialog in RefitterInterface.cs) that include "QueriesGet" rather than a doubled "Get". These appear consistent with the intended naming for query methods and do not exhibit the redundant pattern seen previously.

  • File Updated: src/Digdir.Library.Dialogporten.WebApiClient.WebApiSample/Program.cs, where the method call is now:
        => Results.Ok(serviceOwnerApi.V1ServiceOwnerDialogsGetDialog(dialogId, null!, cancellationToken)));
    
  • Additional Findings: Other instances (e.g., in src/Digdir.Library.Dialogporten.WebApiClient/Features/V1/RefitterInterface.cs) follow the convention for query methods correctly, with no redundant "Get".

All instances reviewed adhere to the updated naming conventions.

src/Digdir.Library.Dialogporten.WebApiClient/Features/V1/RefitterInterface.cs (17)

16-16: Improved class naming by removing redundant "Search" prefix.

The class has been renamed from V1ServiceOwnerDialogsSearchSearchDialogQueryParams to V1ServiceOwnerDialogsSearchDialogQueryParams, removing the redundant "Search" term.


207-207: Improved method naming by removing redundant "Search" term.

The method has been renamed from V1ServiceOwnerDialogTransmissionsSearchSearchDialogTransmission to V1ServiceOwnerDialogTransmissionsSearchDialogTransmission, which is cleaner and more consistent.


297-297: Improved method naming by removing redundant "Get" term.

The method has been renamed from V1ServiceOwnerDialogTransmissionsGetGetDialogTransmission to V1ServiceOwnerDialogTransmissionsGetDialogTransmission, which is cleaner and more consistent.


332-332: Improved method naming by removing redundant "Search" term.

The method has been renamed from V1ServiceOwnerDialogSeenLogsSearchSearchDialogSeenLog to V1ServiceOwnerDialogSeenLogsSearchDialogSeenLog, which is cleaner and more consistent.


367-367: Improved method naming by removing redundant "Get" term.

The method has been renamed from V1ServiceOwnerDialogSeenLogsGetGetDialogSeenLog to V1ServiceOwnerDialogSeenLogsGetDialogSeenLog, which is cleaner and more consistent.


454-454: Improved method naming by removing redundant "Get" term.

The method has been renamed from V1ServiceOwnerDialogsGetGetDialog to V1ServiceOwnerDialogsGetDialog, which is cleaner and more consistent.


586-586: Improved method naming by removing redundant "Search" term.

The method has been renamed from V1ServiceOwnerDialogsSearchSearchDialog to V1ServiceOwnerDialogsSearchDialog, which is cleaner and more consistent.


668-668: Improved method naming by reducing verbosity.

Method renamed to follow the established naming convention, making the interface more consistent.


707-707: Improved method naming by reducing verbosity.

Method renamed to follow the established naming convention, making the interface more consistent.


738-738: Improved method naming by removing redundant "Search" term.

The method has been renamed from V1ServiceOwnerDialogActivitiesSearchSearchDialogActivity to V1ServiceOwnerDialogActivitiesSearchDialogActivity, which is cleaner and more consistent.


856-856: Improved method naming by removing redundant "Get" term.

The method has been renamed from V1ServiceOwnerDialogActivitiesGetGetDialogActivity to V1ServiceOwnerDialogActivitiesGetDialogActivity, which is cleaner and more consistent.


1655-1655: Simplified class reference by removing "Search" prefix from the Tag type.

Renamed from V1ServiceOwnerDialogsCommandsUpdate_SearchTag to V1ServiceOwnerDialogsCommandsUpdate_Tag for better naming conventions. The property name "SearchTags" remains unchanged, which correctly describes the purpose.


1784-1784: Simplified class name by removing redundant "Search" prefix.

Renamed the class from V1ServiceOwnerDialogsCommandsUpdate_SearchTag to V1ServiceOwnerDialogsCommandsUpdate_Tag, which is more concise and follows the convention of not repeating concepts across class and property names.


2810-2810: Simplified class reference by removing "Search" prefix from the Tag type.

Renamed from V1ServiceOwnerDialogsQueriesGet_SearchTag to V1ServiceOwnerDialogsQueriesGet_Tag for better naming conventions. The property name "SearchTags" remains unchanged, which correctly describes the purpose.


2965-2965: Simplified class name by removing redundant "Search" prefix.

Renamed the class from V1ServiceOwnerDialogsQueriesGet_SearchTag to V1ServiceOwnerDialogsQueriesGet_Tag, which is more concise and follows the convention of not repeating concepts across class and property names.


3637-3637: Simplified class reference by removing "Search" prefix from the Tag type.

Renamed from V1ServiceOwnerDialogsCommandsCreate_SearchTag to V1ServiceOwnerDialogsCommandsCreate_Tag for better naming conventions. The property name "SearchTags" remains unchanged, which correctly describes the purpose.


3745-3745: Simplified class name by removing redundant "Search" prefix.

Renamed the class from V1ServiceOwnerDialogsCommandsCreate_SearchTag to V1ServiceOwnerDialogsCommandsCreate_Tag, which is more concise and follows the convention of not repeating concepts across class and property names.

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

2429-2429: Improved naming consistency by simplifying schema reference.

The schema reference has been updated from V1ServiceOwnerDialogsCommandsCreate_SearchTag to V1ServiceOwnerDialogsCommandsCreate_Tag, removing the redundant "Search" prefix. This change is part of a broader effort to standardize naming conventions across the API specification.


3078-3078: Improved naming consistency by simplifying schema reference.

Similar to the previous change, this schema reference has been updated from V1ServiceOwnerDialogsCommandsUpdate_SearchTag to V1ServiceOwnerDialogsCommandsUpdate_Tag, providing more consistent naming throughout the API.


4110-4119: Improved naming consistency by simplifying schema definition.

The schema definition has been updated from V1ServiceOwnerDialogsQueriesGet_SearchTag to V1ServiceOwnerDialogsQueriesGet_Tag, maintaining the same structure but with a more concise name by removing the redundant "Search" prefix.


4826-4838: Added structured schema definition for JWKS response.

A properly structured schema definition for V1WellKnownJwksQueriesGet_Jwks has been added, which includes properties for handling keys. This provides better OpenAPI documentation for the JWKS endpoint response.


4871-4871: Simplified operation ID for JWKS endpoint.

The operation ID has been updated from V1WellKnownJwksGet_GetJwks to V1WellKnownJwksGet_Jwks, removing the redundant "Get" prefix for better naming consistency.


4877-4877: Updated schema reference to match new naming convention.

The schema reference has been updated to use the newly defined V1WellKnownJwksQueriesGet_Jwks schema, ensuring consistency with the renamed operation.


4893-4893: Simplified operation ID for OAuth authorization server endpoint.

The operation ID has been updated to follow the same naming convention applied to other endpoints, removing redundant prefixes for cleaner API documentation.


4899-4899: Updated schema reference to match new naming convention.

The schema reference has been updated to maintain consistency with the renamed operation ID, ensuring that all related components use the same naming pattern.


4915-4915: Consistent renaming of operation IDs across all endpoints.

The operation IDs have been updated throughout the file to follow a more consistent naming convention, removing redundant prefixes (like "Get") from the names. This improves readability and maintains a standardized approach to naming.

Also applies to: 5164-5164, 5221-5221, 5404-5404, 5463-5463, 5621-5621, 5683-5683, 5751-5751, 5789-5789, 6235-6235, 6532-6532, 6600-6600, 6747-6747, 6928-6928, 6996-6996, 7058-7058, 7126-7126, 7310-7310

@oskogstad oskogstad force-pushed the fix/sdk-remove-get-prefix branch from 1fce871 to 2fa77a7 Compare March 3, 2025 11:21
@oskogstad oskogstad merged commit 88925c1 into main Mar 3, 2025
23 checks passed
@oskogstad oskogstad deleted the fix/sdk-remove-get-prefix branch March 3, 2025 11:29
oskogstad pushed a commit that referenced this pull request Mar 3, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.57.2](v1.57.1...v1.57.2)
(2025-03-03)


### Bug Fixes

* Add missing prefixes in Swagger TypeNameConverter exlude list
([#1992](#1992))
([88925c1](88925c1))
* **ci:** Wait for infra deployment before deploying apps in prod
pipeline ([#1989](#1989))
([224e837](224e837))


### Miscellaneous Chores

* **performance:** Make improved tests for search
([#1983](#1983))
([9412a85](9412a85))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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