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

feat: Add Name to ApiAction as optional field #2034

Merged
merged 1 commit into from
Mar 11, 2025

Conversation

knuhau
Copy link
Collaborator

@knuhau knuhau commented Mar 11, 2025

Description

Added an optional name field to ApiActions, to allow for easier identification of the purpose of the action.

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)

@knuhau knuhau requested a review from a team as a code owner March 11, 2025 10:06
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

📝 Walkthrough

Walkthrough

This pull request adds a new name field to API actions across the project. The changes update the GraphQL and Swagger schemas, various DTO classes and their validation rules, domain entities, and client models. A new database migration is introduced to add a corresponding column, and the fake data generator and test data have been updated to include the new property. The modifications are implemented consistently across EndUser and ServiceOwner components without altering existing functionality.

Changes

File(s) Change Summary
docs/schema/V1/schema.verified.graphql
docs/schema/V1/swagger.verified.json
Added a new name field/property with description, example, and nullable attributes to API action definitions in both GraphQL and Swagger schemas.
src/Digdir.Domain.Dialogporten.Application/.../Dialogs/Queries/Get/DialogDto.cs
src/Digdir.Domain.Dialogporten.Application/.../Commands/Create/CreateDialogDto.cs
src/Digdir.Domain.Dialogporten.Application/.../Commands/Update/UpdateDialogDto.cs
src/Digdir.Domain.Dialogporten.Application/.../Dialogs/Queries/Get/DialogDto.cs
Added a new Name property (nullable string with XML documentation) to API action DTO classes for both EndUser and ServiceOwner features.
src/Digdir.Domain.Dialogporten.Application/.../Commands/Create/CreateDialogCommandValidator.cs
src/Digdir.Domain.Dialogporten.Application/.../Commands/Update/UpdateDialogCommandValidator.cs
Introduced validation rules enforcing a maximum length (using Constants.DefaultMaxStringLength) for the new Name property.
src/Digdir.Domain.Dialogporten.Domain/.../DialogApiAction.cs
src/Digdir.Domain.Dialogporten.GraphQL/.../ObjectTypes.cs
Added a nullable Name property to the API action domain entity and its corresponding GraphQL object type.
src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250311092108_AddApiActionName.cs Created a migration to add a new nullable Name column (max length 255) to the DialogApiAction table.
src/Digdir.Library.Dialogporten.WebApiClient/Features/V1/RefitterInterface.cs Added a Name property (with [JsonPropertyName("name")] annotation) to multiple API action classes in the web API client.
src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs Updated the fake data generator to include a random alphanumeric Name value for API action DTOs.
tests/k6/tests/serviceowner/testdata/01-create-dialog.js Inserted a "name": "confirm" property into the API actions array in the test data.

Suggested reviewers

  • oskogstad
  • elsand

📜 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 3688892 and 13a62d7.

⛔ Files ignored due to path filters (2)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250311092108_AddApiActionName.Designer.cs is excluded by !**/Migrations/**/*Designer.cs
  • src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/DialogDbContextModelSnapshot.cs is excluded by !**/Migrations/DialogDbContextModelSnapshot.cs
📒 Files selected for processing (14)
  • docs/schema/V1/schema.verified.graphql (1 hunks)
  • docs/schema/V1/swagger.verified.json (4 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/DialogDto.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommandValidator.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/DialogDto.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Entities/Actions/DialogApiAction.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/ObjectTypes.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250311092108_AddApiActionName.cs (1 hunks)
  • src/Digdir.Library.Dialogporten.WebApiClient/Features/V1/RefitterInterface.cs (3 hunks)
  • src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs (1 hunks)
  • tests/k6/tests/serviceowner/testdata/01-create-dialog.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Dry run deploy apps / Deploy service to test
  • GitHub Check: Dry run deploy apps / Deploy graphql to test
  • GitHub Check: Dry run deploy apps / Deploy web-api-so to test
  • GitHub Check: Dry run deploy apps / Deploy web-api-eu to test
  • GitHub Check: build / build-and-test
🔇 Additional comments (21)
docs/schema/V1/schema.verified.graphql (1)

40-40: LGTM - Added name field to ApiAction type

The new optional name field has been correctly added to the ApiAction type in the GraphQL schema, aligning perfectly with the PR objective of improving action identification.

src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/ObjectTypes.cs (1)

137-137: LGTM - Added nullable Name property to ApiAction class

The addition of the nullable Name property to the ApiAction class is consistent with the GraphQL schema change and maintains backward compatibility.

src/Digdir.Domain.Dialogporten.Domain/Dialogs/Entities/Actions/DialogApiAction.cs (1)

14-14: LGTM - Added Name property to domain entity

The addition of the Name property to the DialogApiAction domain entity correctly implements the feature at the domain level.

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/DialogDto.cs (1)

424-428: LGTM - Well-documented Name property added to DTO

The addition of the Name property with proper XML documentation clearly explains its purpose and includes a helpful example.

tests/k6/tests/serviceowner/testdata/01-create-dialog.js (1)

227-227: Implementation looks good

The new name property has been correctly added to the API action in the test data, using "confirm" as its value. This matches the PR description and provides a clear identifier for the purpose of this action.

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs (1)

363-367: Implementation is correct and well-documented

The Name property has been properly implemented as a nullable string with appropriate XML documentation that clearly describes its purpose and provides an example value. The optional nature of the field aligns with the PR objectives.

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

392-396: Implementation is correct and well-documented

The Name property has been properly implemented as a nullable string with appropriate XML documentation that clearly describes its purpose and provides an example value. This is consistent with the implementation in other DTOs.

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs (1)

315-319: Implementation is correct and well-documented

The Name property has been properly implemented as a nullable string with appropriate XML documentation that clearly describes its purpose and provides an example value. This maintains consistency with the other API action DTOs.

Consider adding automated tests

While the test data has been updated to include the new field, the PR description mentions that automated tests haven't been added. Consider adding formal tests to verify the behavior of this new property throughout the system.

src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250311092108_AddApiActionName.cs (2)

13-19: Database migration looks good

Migration correctly adds a nullable Name column to the DialogApiAction table with proper type and length constraints.


24-26: Down migration is properly implemented

The rollback method correctly drops the Name column from the DialogApiAction table.

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommandValidator.cs (1)

352-353: Validation rule properly implemented

The validation rule for the new Name property follows the established pattern and applies the appropriate maximum length constraint.

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs (1)

395-396: Validation rule properly implemented

The validation rule for the new Name property follows the established pattern and applies the appropriate maximum length constraint, consistent with the update validator.

src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs (1)

346-346: Fake data generation properly implemented

The rule for generating a random name for the new Name property follows the established pattern and is consistent with how other similar properties are generated.

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

2082-2088: Addition of the Name property to ApiAction models looks good.

The new Name property has been added to the V1ServiceOwnerDialogsCommandsUpdate_ApiAction class with proper documentation and JSON serialization attribute. This aligns with the PR objective to enhance ApiAction identification by adding an optional name field.


3320-3326: The Name property implementation is consistent across models.

The Name property has been consistently added to the V1ServiceOwnerDialogsQueriesGet_DialogApiAction class with the same documentation and serialization attributes, maintaining consistency across the codebase.


4080-4086: Name property implementation in Create model is correctly aligned with other models.

The Name property has been properly added to the V1ServiceOwnerDialogsCommandsCreate_ApiAction class, ensuring that the feature is available throughout the create-read-update flow of the API. The consistent implementation across all ApiAction models ensures a unified experience for API consumers.

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

844-849: LGTM: Name field added correctly to EndUserDialogsQueriesGet_DialogApiAction

The new name field has been properly implemented with appropriate description, example, nullable property, and type definition. This aligns with the PR objective to add an optional name field for easier identification of API actions.


2141-2146: LGTM: Name field added correctly to ServiceOwnerDialogsCommandsCreate_ApiAction

The name field has been consistently implemented in the create model with the same description, example, and nullable properties as in other places. This will allow service owners to specify meaningful names when creating new API actions.


2804-2809: LGTM: Name field added correctly to ServiceOwnerDialogsCommandsUpdate_ApiAction

The name field has been properly added to the update model, ensuring consistency across the API. This change maintains API consistency and makes it possible to update the name field on existing actions.


754-759: LGTM: Name field added correctly to ServiceOwnerDialogsQueriesGet_DialogApiAction

The name field has been properly implemented in the service owner get model with the same properties as in other schemas. This ensures that the name field is accessible when retrieving dialog information.


1-7405:

❓ Verification inconclusive

Verify API schema changes are reflected in client implementations

The swagger schema has been updated correctly to include the new optional name field across all relevant API action models. This change enhances the usability of ApiActions by allowing for clearer identification of their purpose. Since this is an optional field, it maintains backward compatibility.


🏁 Script executed:

#!/bin/bash
# Verify that client models and API handlers have been updated to support the new name field

# Check for client model changes
echo "Checking client models for name field support:"
rg "class.*ApiAction" --type cs | xargs rg "Name\s*{\s*get;" --type cs

# Check for controller/handler implementations
echo "Checking API controllers/handlers for name field handling:"
rg "DialogApiAction|ApiAction" --type cs | xargs rg "\.Name" --type cs

Length of output: 45720


Action Required: Manual Verification of API Schema Changes

The automated check for client model and API handler updates did not yield clear results due to errors in the output. This makes it difficult to confidently confirm that the new optional name field is correctly supported across all relevant API action models.

Please manually verify the following:

• Ensure that the client models (e.g. classes representing ApiAction and ApiActionEndpoint) now include a public getter (and setter, if applicable) for the name field.
• Confirm that API controllers and handlers correctly reference and process the name property for API actions.
• Check that the associated database migration (e.g. in src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations/20250311092108_AddApiActionName.cs) properly adds the name field without breaking existing functionality.

Once manual inspection confirms that these changes are correctly integrated and that the new optional field maintains backward compatibility, this review comment may be marked as resolved.

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

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.

@knuhau knuhau merged commit 95ba41e into main Mar 11, 2025
23 checks passed
@knuhau knuhau deleted the feat/add-name-to-apiaction branch March 11, 2025 11:56
oskogstad pushed a commit that referenced this pull request Mar 11, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.58.0](v1.57.7...v1.58.0)
(2025-03-11)


### Features

* Add Name to ApiAction as optional field
([#2034](#2034))
([95ba41e](95ba41e))


### Bug Fixes

* **webapi:** Move swagger server override to correct post processing
step ([#2037](#2037))
([e2ba5d5](e2ba5d5))


### Miscellaneous Chores

* **performance:** Make improved tests for graphql search
([#2030](#2030))
([3688892](3688892))

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