From 5f516096292af73c5f2a720886c77289ed00a7b2 Mon Sep 17 00:00:00 2001 From: Oscar Perez Date: Tue, 26 May 2026 13:51:01 +0200 Subject: [PATCH] feat: include package version in default User-Agent The generated Configuration.cs hardcoded the User-Agent to "OpenAPI-Generator/1.0.0/csharp", giving us no visibility into which SDK version a client is running. Patch the generated file (in the regeneration workflow, since it's overwritten on every regen) to read the assembly version at runtime, so the default User-Agent becomes e.g. "Zernio/0.0.285" (or "Late/0.0.285" for the legacy package). Also applied to the currently-checked-in Configuration.cs so the change holds until the next regen. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/generate.yml | 5 +++++ src/Zernio/Client/Configuration.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index a72589c6..bffcd69c 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -57,6 +57,10 @@ jobs: --git-user-id=zernio-dev \ --git-repo-id=zernio-dotnet + - name: Patch User-Agent to use package version + run: | + sed -i 's|UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/1.0.0/csharp");|UserAgent = WebUtility.UrlEncode($"Zernio/{typeof(Configuration).Assembly.GetName().Version?.ToString(3) ?? "unknown"}");|' src/Zernio/Client/Configuration.cs + - name: Patch README install instructions run: | python3 -c " @@ -162,6 +166,7 @@ jobs: --additional-properties=packageName=Late,targetFramework=net8.0,library=httpclient \ --git-user-id=zernio-dev \ --git-repo-id=zernio-dotnet + sed -i 's|UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/1.0.0/csharp");|UserAgent = WebUtility.UrlEncode($"Late/{typeof(Configuration).Assembly.GetName().Version?.ToString(3) ?? "unknown"}");|' "$LATE_BUILD_DIR/src/Late/Client/Configuration.cs" find "$LATE_BUILD_DIR" -name "*.csproj" -exec sed -i "s/.*<\/Version>/${{ steps.version.outputs.nuget_version }}<\/Version>/" {} \; dotnet build "$LATE_BUILD_DIR" -c Release dotnet pack "$LATE_BUILD_DIR" -c Release --no-build -o "$LATE_BUILD_DIR/nupkg-late" diff --git a/src/Zernio/Client/Configuration.cs b/src/Zernio/Client/Configuration.cs index 2d47ad23..dcce27f2 100644 --- a/src/Zernio/Client/Configuration.cs +++ b/src/Zernio/Client/Configuration.cs @@ -118,7 +118,7 @@ public class Configuration : IReadableConfiguration public Configuration() { Proxy = null; - UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/1.0.0/csharp"); + UserAgent = WebUtility.UrlEncode($"Zernio/{typeof(Configuration).Assembly.GetName().Version?.ToString(3) ?? "unknown"}"); BasePath = "https://zernio.com/api"; DefaultHeaders = new ConcurrentDictionary(); ApiKey = new ConcurrentDictionary();