-
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
feat: Create Dialogporten Serviceowner client library #1513
base: main
Are you sure you want to change the base?
Changes from all commits
d33461f
afa5316
d4b96db
64db1f9
cbd3e76
3689808
7f17006
324cf3f
288175c
e538c94
7135268
2b9238b
a6e66b5
eb590e1
b499151
f8691de
ed42f73
2f613c0
71aefc8
1fb84e6
60571b6
2640a4b
1f3c8b3
76b5964
d3062a2
b09f6d4
fd8907e
41a2eb5
1bdca4d
1b7f5a7
c4f5daf
56a5ebe
af4f6a3
708b09e
4a15f4a
3849c42
0894c17
329e8eb
f46deb3
2a15b37
431cc85
4def26a
ff1d0f8
347d729
cdee031
d75e113
054c9ce
b85b008
457e9b7
81df398
020e538
bf88cdc
aac7bfa
21c9e87
4655774
40f54fe
0c663ee
5a3c578
a08e486
e71db25
b96fb3b
a82f91d
aba1aec
2d5dd74
075854b
b952394
9fd4304
8d6b5c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,62 @@ | ||||||||||||||||||
name: "Publish nuget package" | ||||||||||||||||||
|
||||||||||||||||||
on: | ||||||||||||||||||
workflow_call: | ||||||||||||||||||
inputs: | ||||||||||||||||||
version: | ||||||||||||||||||
description: "Version" | ||||||||||||||||||
required: true | ||||||||||||||||||
type: string | ||||||||||||||||||
Fargekritt marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
path: | ||||||||||||||||||
description: "Path to project" | ||||||||||||||||||
required: true | ||||||||||||||||||
type: string | ||||||||||||||||||
source: | ||||||||||||||||||
description: "Nuget Source" | ||||||||||||||||||
required: false | ||||||||||||||||||
type: string | ||||||||||||||||||
default: https://int.nugettest.org | ||||||||||||||||||
secrets: | ||||||||||||||||||
NUGET_API_KEY: | ||||||||||||||||||
required: true | ||||||||||||||||||
jobs: | ||||||||||||||||||
build: | ||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||
timeout-minutes: 15 | ||||||||||||||||||
steps: | ||||||||||||||||||
- name: Checkout | ||||||||||||||||||
uses: actions/checkout@v4 | ||||||||||||||||||
- name: set PROJECT variable to point to project | ||||||||||||||||||
run: | | ||||||||||||||||||
PROJECT=${{inputs.path}} | ||||||||||||||||||
echo "PROJECT ${PROJECT}" | ||||||||||||||||||
echo "PROJECT=${PROJECT}" >> $GITHUB_ENV | ||||||||||||||||||
|
||||||||||||||||||
Comment on lines
+30
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix shell script quoting The PROJECT variable assignment needs proper quoting to handle paths with spaces. - PROJECT=${{inputs.path}}
+ PROJECT="${{inputs.path}}"
echo "PROJECT ${PROJECT}"
- echo "PROJECT=${PROJECT}" >> $GITHUB_ENV
+ echo "PROJECT=${PROJECT}" >> "$GITHUB_ENV" 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)30-30: shellcheck reported issue in this script: SC2086:info:3:30: Double quote to prevent globbing and word splitting (shellcheck) |
||||||||||||||||||
- name: Set up .NET | ||||||||||||||||||
uses: actions/setup-dotnet@v4 | ||||||||||||||||||
with: | ||||||||||||||||||
global-json-file: ./global.json | ||||||||||||||||||
|
||||||||||||||||||
- name: Build | ||||||||||||||||||
run: dotnet build --configuration Release /p:Version=${{ inputs.version }} ${PROJECT} | ||||||||||||||||||
|
||||||||||||||||||
- name: Pack with debug symbols | ||||||||||||||||||
run: dotnet pack --configuration Release /p:Version=${{ inputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output . ${PROJECT} | ||||||||||||||||||
Comment on lines
+41
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix command argument quoting The project path needs proper quoting in dotnet commands. - run: dotnet build --configuration Release /p:Version=${{ inputs.version }} ${PROJECT}
+ run: dotnet build --configuration Release /p:Version="${{ inputs.version }}" "${PROJECT}"
- run: dotnet pack --configuration Release /p:Version=${{ inputs.version }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output . ${PROJECT}
+ run: dotnet pack --configuration Release /p:Version="${{ inputs.version }}" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --output . "${PROJECT}" 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)41-41: shellcheck reported issue in this script: SC2086:info:1:71: Double quote to prevent globbing and word splitting (shellcheck) 44-44: shellcheck reported issue in this script: SC2086:info:1:134: Double quote to prevent globbing and word splitting (shellcheck) |
||||||||||||||||||
|
||||||||||||||||||
- name: Upload artifact | ||||||||||||||||||
uses: actions/upload-artifact@v4 | ||||||||||||||||||
with: | ||||||||||||||||||
name: package | ||||||||||||||||||
path: '*.*nupkg' | ||||||||||||||||||
push: | ||||||||||||||||||
needs: build | ||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||
steps: | ||||||||||||||||||
- name: Download artifact | ||||||||||||||||||
uses: actions/download-artifact@v4 | ||||||||||||||||||
with: | ||||||||||||||||||
name: package | ||||||||||||||||||
|
||||||||||||||||||
- name: Push to NuGet | ||||||||||||||||||
run: dotnet nuget push *.nupkg --source ${{ inputs.source }} --api-key ${{secrets.NUGET_API_KEY}} | ||||||||||||||||||
|
||||||||||||||||||
Comment on lines
+60
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix NuGet push command and remove trailing whitespace The NuGet push command needs proper globbing and the file has trailing whitespace. - - name: Push to NuGet
- run: dotnet nuget push *.nupkg --source ${{ inputs.source }} --api-key ${{secrets.NUGET_API_KEY}}
-
+ - name: Push to NuGet
+ run: dotnet nuget push "./*.nupkg" --source "${{ inputs.source }}" --api-key "${{secrets.NUGET_API_KEY}}" 📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)61-61: shellcheck reported issue in this script: SC2035:info:1:19: Use ./glob or -- glob so names with dashes won't become options (shellcheck) 🪛 yamllint (1.35.1)[error] 62-62: trailing spaces (trailing-spaces) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kalle denne
|
||
"openApiPath": "docs/schema/V1/swagger.verified.json", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blir refitter bare kalt kun en gang? Eller gjør vi det hver gang API endrer seg? Isåfall burde vi kanskje ha det som en del av bygg-steget? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. akkurat nå blir den generert av en test lignene swaggerSnapshot testen. men holder på å prøver meg litt frem for å finne en løsning |
||
"namespace": "Digdir.Library.Dialogporten.WebApiClient.Features.V1", | ||
"outputFolder": "src/Digdir.Library.Dialogporten.WebApiClient/Features/V1/", | ||
"operationNameGenerator": "SingleClientFromOperationId", | ||
"multipleInterfaces": "ByTag", | ||
"includeTags": [ | ||
|
||
], | ||
"useCancellationTokens": true, | ||
"returnIApiResponse": true, | ||
"useDynamicQuerystringParameters": true, | ||
"outputFilename": "RefitterInterface.cs" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6970,4 +6970,4 @@ | |
"url": "https://altinn-dev-api.azure-api.net/dialogporten" | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
using Digdir.Library.Dialogporten.WebApiClient.Features.V1; | ||||||||||||||||||||||||||||||||||||||||||||||||
using Refit; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
namespace Digdir.Library.Dialogporten.WebApiClient.Sample; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
public sealed class Dialogs(IServiceownerApi client) | ||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||
public async Task<IApiResponse> Purge(Guid dialogId, Guid? ifMatch = null) | ||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||
var response = await client.V1ServiceOwnerDialogsPurgePurgeDialog(dialogId, ifMatch); | ||||||||||||||||||||||||||||||||||||||||||||||||
Console.WriteLine($"Purge response status code: {response.StatusCode}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
Console.WriteLine($"Purge Response: {response.StatusCode}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
return response; | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+8
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve error handling and logging in Purge method. The current implementation has several issues:
public async Task<IApiResponse> Purge(Guid dialogId, Guid? ifMatch = null)
{
+ try
+ {
var response = await client.V1ServiceOwnerDialogsPurgePurgeDialog(dialogId, ifMatch);
- Console.WriteLine($"Purge response status code: {response.StatusCode}");
- Console.WriteLine($"Purge Response: {response.StatusCode}");
+ if (!response.IsSuccessStatusCode)
+ {
+ throw new DialogportenApiException($"Failed to purge dialog {dialogId}. Status: {response.StatusCode}", response);
+ }
return response;
+ }
+ catch (ApiException ex)
+ {
+ throw new DialogportenApiException($"API error while purging dialog {dialogId}", ex);
+ }
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
public static void PrintGetDialog(V1ServiceOwnerDialogsQueriesGet_Dialog dialog) | ||||||||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||||||||
Console.WriteLine($"System Label: {dialog.SystemLabel}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
Console.WriteLine($"Dialog Status: {dialog.Status}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
Console.WriteLine($"Dialog Org: {dialog.Org}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
Console.WriteLine($"Dialog Progress: {dialog.Progress}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
Console.WriteLine($"Deleted at: {dialog.DeletedAt}"); | ||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Digdir.Library.Dialogporten.WebApiClient\Digdir.Library.Dialogporten.WebApiClient.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="appsettings.local.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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.
🛠️ Refactor suggestion
Improve robustness of project file path resolution
The current implementation has several potential issues:
$(find ...)
command is embedded in thepath
parameter and uses shell syntax that might not work consistently in GitHub ActionsConsider using a dedicated step to find the project file:
This approach:
-not -path "*/test/*"