-
Notifications
You must be signed in to change notification settings - Fork 3
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(webapi): Move swagger server override to correct post processing step #2037
Conversation
📝 WalkthroughWalkthroughThe pull request involves changes to the Swagger generation configuration in the Changes
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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 (1)
src/Digdir.Domain.Dialogporten.WebApi/Program.cs (1)
207-224
: Good improvement moving the Swagger server override to the correct post-processing step.Moving the Swagger server override logic into the
config.PostProcess
lambda inUseSwaggerGen
is a good architectural change that ensures the server configuration happens at the proper point in the Swagger document generation pipeline. This matches the PR objective perfectly.However, I notice the code uses the non-null assertion operator (
!
) on line 213 when retrieving the application settings. Consider adding some error handling to make this more robust in case the configuration is missing.config.PostProcess = (d, c) => { - var dialogportenBaseUri = builder.Configuration - .GetSection(ApplicationSettings.ConfigurationSectionName) - .Get<ApplicationSettings>()! - .Dialogporten - .BaseUri - .ToString(); + var appSettings = builder.Configuration + .GetSection(ApplicationSettings.ConfigurationSectionName) + .Get<ApplicationSettings>(); + + if (appSettings?.Dialogporten?.BaseUri != null) + { + var dialogportenBaseUri = appSettings.Dialogporten.BaseUri.ToString(); + + d.Servers.Clear(); + d.Servers.Add(new OpenApiServer + { + Url = dialogportenBaseUri + }); + } + else + { + Log.Warning("Dialogporten BaseUri not configured. Swagger server configuration not updated."); + } - - d.Servers.Clear(); - d.Servers.Add(new OpenApiServer - { - Url = dialogportenBaseUri - }); };
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Digdir.Domain.Dialogporten.WebApi/Program.cs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Dry run deploy apps / Deploy graphql to test
- GitHub Check: build / build-and-test
🤖 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).
Description
Related Issue(s)
Verification
Documentation
docs
-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)