Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand All @@ -17,13 +19,13 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/api-dental-pro-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3.4.2
with:
dotnet-version: '8.0.x'

Expand All @@ -36,13 +38,13 @@ jobs:
timeout-minutes: 10
name: build
runs-on: ${{ github.repository == 'stainless-sdks/api-dental-pro-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3.4.2
with:
dotnet-version: '8.0.x'

Expand All @@ -55,10 +57,10 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/api-dental-pro-csharp' && 'depot-windows-2022' || 'windows-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: '8.0.x'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up .NET
uses: actions/setup-dotnet@v5
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: '8.0.x'

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
bin/
obj/
.vs/
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.6.0"
".": "0.7.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 3
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/velocitys3%2Fapi-dental-pro-d7d63efc6c52d056de2c33d52c5e447da05558069adee45c65b01edd0bd1788c.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/velocitys3/api-dental-pro-331b628a571f60efd1e47614a49095ad5abefac2d83c958464f5f24132a31082.yml
openapi_spec_hash: 5660fa0723e9da2c6d2dc12e893ce3dc
config_hash: b371739ff56067c75874a694203404de
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 0.7.0 (2026-05-13)

Full Changelog: [v0.6.0...v0.7.0](https://github.com/api-dental/api-dental-pro-csharp/compare/v0.6.0...v0.7.0)

### Features

* **client:** enable gzip decompression ([28a0428](https://github.com/api-dental/api-dental-pro-csharp/commit/28a042808c79875fafb7b5962bc65395b1f178f6))
* support setting headers via env ([d9a086c](https://github.com/api-dental/api-dental-pro-csharp/commit/d9a086cec7ca67bcf0bebc7079c07b9c6c0e8884))


### Bug Fixes

* **client:** allow cancelling when enumerating over an http response ([64c8d16](https://github.com/api-dental/api-dental-pro-csharp/commit/64c8d16ae1585b38f24f06d23de377a6f7ce6959))
* **client:** handle root bodies in requests properly ([6e7339b](https://github.com/api-dental/api-dental-pro-csharp/commit/6e7339bb0bbcedcc534a1567a32ed4d64b7edd33))
* **docs:** make xml syntactically correct ([dfe612c](https://github.com/api-dental/api-dental-pro-csharp/commit/dfe612c869be928316e00bbc3d500dfce79823bd))
* **internal:** disable default HttpClient timeout as we have our own ([fa2eb23](https://github.com/api-dental/api-dental-pro-csharp/commit/fa2eb2348f1f1e9ccddef6c2d49b05f99c644a0e))
* **tests:** round-trip urls correctly ([06fb914](https://github.com/api-dental/api-dental-pro-csharp/commit/06fb914acf21a2dd230cb32ead201db856792dad))


### Chores

* **ci:** skip lint on metadata-only changes ([b7b69d4](https://github.com/api-dental/api-dental-pro-csharp/commit/b7b69d483b2c767749617e0af05880b4eb227891))
* **internal:** tweak CI branches ([aff0c12](https://github.com/api-dental/api-dental-pro-csharp/commit/aff0c128246e68eebd71a1fc4dc3388d74a7a62d))
* **internal:** update gitignore ([3d69bda](https://github.com/api-dental/api-dental-pro-csharp/commit/3d69bda70b5295832c20fde7af1edf84c3618e50))

## 0.6.0 (2026-03-15)

Full Changelog: [v0.5.0...v0.6.0](https://github.com/api-dental/api-dental-pro-csharp/compare/v0.5.0...v0.6.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void Url_Works()

var url = parameters.Url(new() { ApiKey = "My API Key" });

Assert.Equal(new Uri("https://wg.api.dental/rest/ClearCoverage"), url);
Assert.True(TestBase.UrisEqual(new Uri("https://wg.api.dental/rest/ClearCoverage"), url));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void Url_Works()

var url = parameters.Url(new() { ApiKey = "My API Key" });

Assert.Equal(new Uri("https://wg.api.dental/rest/Eligibility"), url);
Assert.True(TestBase.UrisEqual(new Uri("https://wg.api.dental/rest/Eligibility"), url));
}

[Fact]
Expand Down
40 changes: 40 additions & 0 deletions src/ApiDentalPro.Tests/TestBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ApiDentalPro;

namespace ApiDentalPro.Tests;
Expand All @@ -16,4 +18,42 @@ public TestBase()
ApiKey = "My API Key",
};
}

internal static bool UrisEqual(Uri uri1, Uri uri2)
{
if (
uri1.Scheme != uri2.Scheme
|| uri1.Host != uri2.Host
|| uri1.Port != uri2.Port
|| uri1.AbsolutePath != uri2.AbsolutePath
)
{
return false;
}

var query1 = ParseQueryString(uri1.Query);
var query2 = ParseQueryString(uri2.Query);

return Enumerable.SequenceEqual(query1, query2);
}

static SortedDictionary<string, string> ParseQueryString(string query)
{
var ret = new SortedDictionary<string, string>(StringComparer.Ordinal);

if (string.IsNullOrEmpty(query))
return ret;

var pairs = query.TrimStart('?').Split(['&'], StringSplitOptions.RemoveEmptyEntries);

foreach (var pair in pairs)
{
var parts = pair.Split(['&'], 2);
var key = Uri.UnescapeDataString(parts[0]);
var value = parts.Length > 1 ? Uri.UnescapeDataString(parts[1]) : string.Empty;
ret[key] = value;
}

return ret;
}
}
2 changes: 1 addition & 1 deletion src/ApiDentalPro/ApiDentalPro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Metadata -->
<AssemblyTitle>API Dental Pro C#</AssemblyTitle>
<AssemblyName>ApiDentalPro</AssemblyName>
<VersionPrefix>0.6.0</VersionPrefix>
<VersionPrefix>0.7.0</VersionPrefix>
<Description>The official .NET library for the API Dental Pro API.</Description>
<OutputType>Library</OutputType>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down
10 changes: 9 additions & 1 deletion src/ApiDentalPro/Core/ClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ public record struct ClientOptions()

/// <summary>
/// The HTTP client to use for making requests in the SDK.
///
/// <para>Note: The HttpClient has a built-in timeout, which defaults to 100 seconds.
/// When passing a custom HttpClient, this timeout may conflict with the SDK's
/// own timeout handler and cause premature cancellation.</para>
/// </summary>
public HttpClient HttpClient { get; set; } = new();
public HttpClient HttpClient { get; set; } =
new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.Available })
{
Timeout = global::System.Threading.Timeout.InfiniteTimeSpan,
};

Lazy<string> _baseUrl = new(() =>
Environment.GetEnvironmentVariable("API_DENTAL_PRO_BASE_URL") ?? EnvironmentUrl.Production
Expand Down
49 changes: 49 additions & 0 deletions src/ApiDentalPro/Core/DecompressionMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.IO;
using System.IO.Compression;
using Net = System.Net;

namespace ApiDentalPro.Core;

static class DecompressionMethods
{
internal static readonly Net::DecompressionMethods Available;

static DecompressionMethods()
{
try
{
// Minimal valid GZip payload (empty body).
var gzipPayload = new byte[]
{
0x1f,
0x8b,
0x08,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x03,
0x03,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
};
using var memoryStream = new MemoryStream(gzipPayload);
using var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress);
gzipStream.CopyTo(Stream.Null);
Available = Net::DecompressionMethods.GZip;
}
catch
{
Available = Net::DecompressionMethods.None;
}
}
}
10 changes: 8 additions & 2 deletions src/ApiDentalPro/Core/HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Net;
using System.Net.Http;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Threading.Tasks;
using ApiDentalPro.Exceptions;
Expand Down Expand Up @@ -161,12 +162,17 @@ internal StreamingHttpResponse(
this.CancellationToken = response.CancellationToken;
}

public IAsyncEnumerable<T> Enumerate(Threading::CancellationToken cancellationToken = default)
public async IAsyncEnumerable<T> Enumerate(
[EnumeratorCancellationAttribute] Threading::CancellationToken cancellationToken = default
)
{
using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource(
this.CancellationToken,
cancellationToken
);
return this._enumerate(cts.Token);
await foreach (var item in this._enumerate(cts.Token))
{
yield return item;
}
}
}
62 changes: 7 additions & 55 deletions src/ApiDentalPro/Core/JsonDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace ApiDentalPro.Core;
/// <summary>
/// A dictionary that holds JSON data.
///
/// <para>It can be mutated and then frozen once no more mutations are expected. This
/// is useful for allowing the dictionary to be modified by a class's <c>init</c>
/// properties, but then preventing it from being modified afterwards.</para>
/// <para>It can be mutated and then frozen once no more mutations are expected.
/// This is useful for allowing the dictionary to be modified by a class's
/// <c>init</c> properties, but then preventing it from being modified afterwards.</para>
///
/// <para>It also caches data deserialization for performance.</para>
/// </summary>
Expand Down Expand Up @@ -94,20 +94,7 @@ public T GetNotNullClass<T>(string key)
{
throw new ApiDentalProInvalidDataException($"'{key}' cannot be absent");
}
T deserialized;
try
{
deserialized =
JsonSerializer.Deserialize<T>(element, ModelBase.SerializerOptions)
?? throw new ApiDentalProInvalidDataException($"'{key}' cannot be null");
}
catch (JsonException e)
{
throw new ApiDentalProInvalidDataException(
$"'{key}' must be of type {typeof(T).FullName}",
e
);
}
T deserialized = WrappedJsonSerializer.GetNotNullClass<T>(element, key);
_deserializedData[key] = deserialized;
return deserialized;
}
Expand All @@ -123,20 +110,7 @@ public T GetNotNullStruct<T>(string key)
{
throw new ApiDentalProInvalidDataException($"'{key}' cannot be absent");
}
T deserialized;
try
{
deserialized =
JsonSerializer.Deserialize<T?>(element, ModelBase.SerializerOptions)
?? throw new ApiDentalProInvalidDataException($"'{key}' cannot be null");
}
catch (JsonException e)
{
throw new ApiDentalProInvalidDataException(
$"'{key}' must be of type {typeof(T).FullName}",
e
);
}
T deserialized = WrappedJsonSerializer.GetNotNullStruct<T>(element, key);
_deserializedData[key] = deserialized;
return deserialized;
}
Expand All @@ -153,18 +127,7 @@ public T GetNotNullStruct<T>(string key)
_deserializedData[key] = null;
return null;
}
T? deserialized;
try
{
deserialized = JsonSerializer.Deserialize<T?>(element, ModelBase.SerializerOptions);
}
catch (JsonException e)
{
throw new ApiDentalProInvalidDataException(
$"'{key}' must be of type {typeof(T).FullName}",
e
);
}
T? deserialized = WrappedJsonSerializer.GetNullableClass<T>(element, key);
_deserializedData[key] = deserialized;
return deserialized;
}
Expand All @@ -181,18 +144,7 @@ public T GetNotNullStruct<T>(string key)
_deserializedData[key] = null;
return null;
}
T? deserialized;
try
{
deserialized = JsonSerializer.Deserialize<T?>(element, ModelBase.SerializerOptions);
}
catch (JsonException e)
{
throw new ApiDentalProInvalidDataException(
$"'{key}' must be of type {typeof(T).FullName}",
e
);
}
T? deserialized = WrappedJsonSerializer.GetNullableStruct<T>(element, key);
_deserializedData[key] = deserialized;
return deserialized;
}
Expand Down
Loading
Loading