feat(schema): resolve bare $dynamicRef via $dynamicAnchor index#2913
Conversation
e4c3bd2 to
96e2bcc
Compare
96e2bcc to
573f8bf
Compare
|
@baywet sorry for the mega PR. Most of the changes are tests and mechanical changes. However, if you want, I can split it into multiple PRs if that will make it easier for you to review. |
|
Thanks for the contribution! No worries, I'll take the time to review during the week. Looking back at the reference mechanisms that are implemented throughout the library, I realized we had a specification/documentation page that never got published on release. Took the time to clean it up a little and it's now available here. https://learn.microsoft.com/en-us/openapi/openapi.net/references-openapi Let us know what you think! |
There was a problem hiding this comment.
Pull request overview
This PR adds document-scoped $dynamicRef resolution for OpenAPI 3.1/3.2 JSON Schema 2020-12 by indexing $dynamicAnchor/$anchor declarations per OpenApiDocument in OpenApiWorkspace, and by deserializing bare $dynamicRef schemas as OpenApiSchemaReference so they participate in the existing reference-resolution pipeline.
Changes:
- Index
$dynamicAnchorand$anchordeclarations per document inOpenApiWorkspaceand expose APIs for candidate lookup + context-aware resolution. - Update V31/V32 schema deserializers to create an
OpenApiSchemaReferencefor bare$dynamicRef(no$ref) and preserve siblings viaApplySchemaMetadata. - Add extensive V31/V32 unit tests covering registration, resolution precedence, ambiguity behavior, serialization round-trips, and tricky schema-bearing locations (responses/headers/callback cycles/etc.).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiDynamicRefTests.cs | Adds OpenAPI 3.2 test coverage for bare $dynamicRef deserialization, resolution, anchor registration across OAS locations, and serialization behavior. |
| test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDynamicRefTests.cs | Adds OpenAPI 3.1 test coverage for anchor indexing across subschema locations, ambiguity behavior, context-aware resolution, and $ref regression scenarios. |
| src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs | Implements per-document $dynamicAnchor/$anchor registries and recursive anchor discovery across components + inline paths/webhooks/callback graphs. |
| src/Microsoft.OpenApi/Reader/V32/OpenApiSchemaDeserializer.cs | Deserializes bare $dynamicRef schemas into OpenApiSchemaReference and applies schema metadata so siblings are preserved. |
| src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs | Same as V32, for OpenAPI 3.1 schema deserialization. |
| src/Microsoft.OpenApi/Reader/JsonNodeHelper.cs | Adds $dynamicRef pointer detection and helper methods for extracting anchor names + determining fragment-only refs. |
| src/Microsoft.OpenApi/PublicAPI.Unshipped.txt | Records new/changed public API surface for serialization overrides, Target override, and new workspace APIs. |
| src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs | Overrides Target to resolve bare $dynamicRef via workspace $dynamicAnchor index with $anchor fallback when appropriate. |
| src/Microsoft.OpenApi/Models/JsonSchemaReference.cs | Adds IsDynamicRefOnly and custom serialization behavior to emit $dynamicRef (without $ref) for dynamic-ref-only references, plus interface updates for anchor walking. |
baywet
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
In addition to the comments I've left, I think we have good coverage of the deserialization scenarios, and some coverage of the serialization scenarios (at least for basic properties).
In think that one key aspect that is missing from the tests is: people using the object model to build documents. For "regular refs" components registration is required. I'd like to see more tests demonstrating that a document built from OM can resolve dynamic refs without requiring a re-parsing.
573f8bf to
06d3b50
Compare
|
@baywet CodeQL is suggesting we convert the |
Let's convert for consistency (we have patterns like those throughout the codebase). Allocation wise, the costliest part is the DOM itself and associated strings, the iterators are short lived and negligeable in comparison. And we've made significant performance improvements over the past year or so to have a better margin here. |
06d3b50 to
2ab57de
Compare
|
Done. Converted all All review comments should be addressed now. Do you think this can be merged today? |
|
@copilot fix failing test and address the other review items |
@aqueelat, I believe this doesn't work on forks. (I had the same problem with aspnetcore recently) |
2ab57de to
7a595ff
Compare
Updated [Google.Protobuf](https://github.com/protocolbuffers/protobuf) from 3.33.1 to 3.35.1. <details> <summary>Release notes</summary> _Sourced from [Google.Protobuf's releases](https://github.com/protocolbuffers/protobuf/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/protocolbuffers/protobuf/commits). </details> Updated [Grpc.Tools](https://github.com/grpc/grpc) from 2.76.0 to 2.82.0. <details> <summary>Release notes</summary> _Sourced from [Grpc.Tools's releases](https://github.com/grpc/grpc/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/grpc/grpc/commits). </details> Updated [JsonSchema.Net](https://github.com/json-everything/json-everything) from 9.2.2 to 9.3.0. <details> <summary>Release notes</summary> _Sourced from [JsonSchema.Net's releases](https://github.com/json-everything/json-everything/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/json-everything/json-everything/commits). </details> Updated [Microsoft.AspNetCore.Mvc.Testing](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.Mvc.Testing's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.AspNetCore.OpenApi](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.OpenApi's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Configuration.Abstractions](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Configuration.Abstractions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.DependencyInjection](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.DependencyInjection's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.DependencyInjection.Abstractions](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.DependencyInjection.Abstractions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Hosting](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Hosting's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Hosting.Abstractions](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Hosting.Abstractions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Http](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Http's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Logging](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Logging's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Logging.Abstractions](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Logging.Abstractions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.Extensions.Options.ConfigurationExtensions](https://github.com/dotnet/dotnet) from 10.0.9 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Options.ConfigurationExtensions's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 18.7.0 to 18.8.1. <details> <summary>Release notes</summary> _Sourced from [Microsoft.NET.Test.Sdk's releases](https://github.com/microsoft/vstest/releases)._ ## 18.8.1 ## What's Changed * Fix protocol negotiation timeout when STJ reflection is disabled (18.8.1) by @nohwnd in microsoft/vstest#16281 **Full Changelog**: microsoft/vstest@v18.8.0...v18.8.1 ## 18.8.0 ## What's Changed * Migrate from Newtonsoft.Json to System.Text.Json / Jsonite (merge to main) by @nohwnd in microsoft/vstest#15687 - For more detail refer to https://devblogs.microsoft.com/dotnet/vs-test-is-removing-its-newtonsoft-json-dependency/ * Create source-only filter package by @Youssef1313 in microsoft/vstest#15638 * Add ARM64 msdia140.dll support to test platform packages by @nohwnd in microsoft/vstest#15692 * Fix mutex cleanup crash on macOS/Linux by @nohwnd in microsoft/vstest#15684 * Restrict artifact temp directory permissions on Unix by @nohwnd in microsoft/vstest#15729 * Add support for filtering uncategorized tests with TestCategory=None by @Evangelink in microsoft/vstest#15727 * Fix SCI binding failure in DTA hosts (main) by @nohwnd in microsoft/vstest#15724 * Fix HTML logger parallel file collision by @nohwnd in microsoft/vstest#15435 * Improve error message when testhost cannot be found by @nohwnd in microsoft/vstest#16053 * Fix HTML logger exception on invalid XML chars in test display names by @nohwnd in microsoft/vstest#16051 **Full Changelog**: microsoft/vstest@v18.7.0...v18.8.0 Commits viewable in [compare view](microsoft/vstest@v18.7.0...v18.8.1). </details> Updated [Microsoft.OpenApi](https://github.com/Microsoft/OpenAPI.NET) from 2.10.0 to 2.11.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.OpenApi's releases](https://github.com/Microsoft/OpenAPI.NET/releases)._ ## 2.11.0 ## [2.11.0](microsoft/OpenAPI.NET@v2.10.0...v2.11.0) (2026-07-15) ### Features * adds support for anchor and id external resolution ([557bd6a](microsoft/OpenAPI.NET@557bd6a)) * adds support for anchor and id external resolution ([4138e47](microsoft/OpenAPI.NET@4138e47)) * **schema:** resolve bare $dynamicRef via $dynamicAnchor index ([#2913](microsoft/OpenAPI.NET#2913)) ([baf8428](microsoft/OpenAPI.NET@baf8428)) * **schema:** resolve bare $dynamicRef via $dynamicAnchor index ([#2913](microsoft/OpenAPI.NET#2913)) ([a139f83](microsoft/OpenAPI.NET@a139f83)) * support relative URI resolution in $dynamicRef ([#2928](microsoft/OpenAPI.NET#2928)) ([#2945](microsoft/OpenAPI.NET#2945)) ([6091f5a](microsoft/OpenAPI.NET@6091f5a)) * support relative URI resolution in $dynamicRef ([#2928](microsoft/OpenAPI.NET#2928)) ([#2945](microsoft/OpenAPI.NET#2945)) ([a8688dc](microsoft/OpenAPI.NET@a8688dc)) ### Bug Fixes * adds explicit error message for invalid json pointers ([#2955](microsoft/OpenAPI.NET#2955)) ([a304e56](microsoft/OpenAPI.NET@a304e56)) * differentiate unset value from null value in OpenApiSchema.Const ([#2936](microsoft/OpenAPI.NET#2936)) ([a8787af](microsoft/OpenAPI.NET@a8787af)) * differentiate unset value from null value in OpenApiSchema.Const ([#2936](microsoft/OpenAPI.NET#2936)) ([e08570f](microsoft/OpenAPI.NET@e08570f)) * handle nullability more accurately during serialization for 3.0/2.0 ([#2933](microsoft/OpenAPI.NET#2933)) ([bc11356](microsoft/OpenAPI.NET@bc11356)) * handle nullability more accurately during serialization for 3.0/2.0 ([#2933](microsoft/OpenAPI.NET#2933)) ([310b6e2](microsoft/OpenAPI.NET@310b6e2)) Commits viewable in [compare view](microsoft/OpenAPI.NET@v2.10.0...v2.11.0). </details> Updated [OpenTelemetry](https://github.com/open-telemetry/opentelemetry-dotnet) from 1.16.0 to 1.17.0. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry's releases](https://github.com/open-telemetry/opentelemetry-dotnet/releases)._ ## 1.17.0 For highlights and announcements pertaining to this release see: [Release Notes > 1.17.0](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/RELEASENOTES.md#1170). The following changes are from the previous release [1.17.0-rc.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.17.0-rc.1). * NuGet: [OpenTelemetry v1.17.0](https://www.nuget.org/packages/OpenTelemetry/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Api/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Api/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api.ProviderBuilderExtensions v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Api.ProviderBuilderExtensions/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Console v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Console/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.Console/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.InMemory v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.InMemory/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.OpenTelemetryProtocol v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.OpenTelemetryProtocol/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Zipkin v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Zipkin/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Extensions.Hosting v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Extensions.Hosting/1.17.0) No notable changes. ... (truncated) ## 1.17.0-rc.1 The following changes are from the previous release [1.16.0](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.16.0). * NuGet: [OpenTelemetry v1.17.0-rc.1](https://www.nuget.org/packages/OpenTelemetry/1.17.0-rc.1) * Fixed a metric point reclaim data race on CPU ARM architectures. ([#7401](open-telemetry/opentelemetry-dotnet#7401)) * The library is now marked as trim and AOT compatible. ([#7441](open-telemetry/opentelemetry-dotnet#7441)) * Replaced the vendored copy of `EnvironmentVariablesConfigurationProvider` with a direct `Microsoft.Extensions.Configuration.EnvironmentVariables` package dependency. Consumers gain automatic pickup of upstream bug fixes and security patches; no public API or behavioural change. ([#7146](open-telemetry/opentelemetry-dotnet#7146)) * Added a verbose `OpenTelemetry-Sdk` self-diagnostics event that is emitted when an activity is dropped because its local (in-process) parent is not recorded. ([#7427](open-telemetry/opentelemetry-dotnet#7427)) * Added support for a Schema URL on `Resource` instances. ([#7472](open-telemetry/opentelemetry-dotnet#7472)) * Fixed a metric storage leak that occurred when meters and instruments were repeatedly created and disposed. ([#7466](open-telemetry/opentelemetry-dotnet#7466)) * Added `ExcludedTagKeys` property to `MetricStreamConfiguration` to support excluding specific tag keys from metric streams. ([#7373](open-telemetry/opentelemetry-dotnet#7373)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0-rc.1/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.17.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Api/1.17.0-rc.1) * Fixed `TraceContextPropagator` to normalize empty `tracestate` header values to `null` when extracting trace context. ([#7407](open-telemetry/opentelemetry-dotnet#7407), [#7433](open-telemetry/opentelemetry-dotnet#7433)) * The library is now marked as trim and AOT compatible. ([#7441](open-telemetry/opentelemetry-dotnet#7441)) * **Experimental (pre-release builds only):** Updated `EnvironmentVariableCarrier.Get` to read only the normalized environment variable name, following the updated [environment variable carrier specification](open-telemetry/opentelemetry-specification#5144). Non-normalized carrier keys are no longer matched, even when they would normalize to the requested key. ... (truncated) ## 1.17.0-beta.1 The following changes are from the previous release [1.16.0-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/coreunstable-1.16.0-beta.1). * NuGet: [OpenTelemetry.Exporter.Prometheus.AspNetCore v1.17.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.AspNetCore/1.17.0-beta.1) * Added a verbose-level diagnostic event for ignored metrics. ([#7429](open-telemetry/opentelemetry-dotnet#7429)) * The library is now marked as trim and AOT compatible. ([#7441](open-telemetry/opentelemetry-dotnet#7441)) * Fix double unit suffixes in metric names when using OpenMetrics. ([#7454](open-telemetry/opentelemetry-dotnet#7454)) * Fix incorrect handling of leading digits in metric names for OpenMetrics. ([#7454](open-telemetry/opentelemetry-dotnet#7454)) * Add `PrometheusAspNetCoreOptions.ScopeInfoEnabled` property to enable or disable scope labels in Prometheus metrics. Defaults to `true`. ([#7436](open-telemetry/opentelemetry-dotnet#7436)) * Added support for the `dots` and `values` Prometheus UTF-8 name escaping schemes when negotiated via the `Accept` header. ([#7439](open-telemetry/opentelemetry-dotnet#7439)) * Add `PrometheusAspNetCoreOptions.TargetInfoEnabled` property to enable or disable the `target_info` metric in Prometheus metrics. Defaults to `true`. ([#7438](open-telemetry/opentelemetry-dotnet#7438)) * Added support for the `allow-utf-8` Prometheus UTF-8 name escaping scheme when negotiated via the `Accept` header. ([#7440](open-telemetry/opentelemetry-dotnet#7440)) * Add `PrometheusAspNetCoreOptions.ResourceConstantLabels` property to select resource attributes to add to each metric as constant labels. Defaults to `null` (no resource attributes are added as metric labels). ([#7471](open-telemetry/opentelemetry-dotnet#7471)) * Add `PrometheusAspNetCoreOptions.MaxScrapeResponseSizeBytes` to configure the maximum size of a scrape response. The default is now ~166 MiB. ([#7487](open-telemetry/opentelemetry-dotnet#7487)) * A scrape whose serialized output exceeds the maximum scrape response size limit now responds with HTTP 500. ([#7487](open-telemetry/opentelemetry-dotnet#7487)) * Fixed the Prometheus text exposition format emitting redundant comments. ([#7491](open-telemetry/opentelemetry-dotnet#7491)) * Made `Accept` header content negotiation consistent with the `PrometheusHttpListener` endpoint. ... (truncated) Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet@core-1.16.0...core-1.17.0). </details> Updated [OpenTelemetry.Exporter.OpenTelemetryProtocol](https://github.com/open-telemetry/opentelemetry-dotnet) from 1.16.0 to 1.17.0. <details> <summary>Release notes</summary> _Sourced from [OpenTelemetry.Exporter.OpenTelemetryProtocol's releases](https://github.com/open-telemetry/opentelemetry-dotnet/releases)._ ## 1.17.0 For highlights and announcements pertaining to this release see: [Release Notes > 1.17.0](https://github.com/open-telemetry/opentelemetry-dotnet/blob/main/RELEASENOTES.md#1170). The following changes are from the previous release [1.17.0-rc.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.17.0-rc.1). * NuGet: [OpenTelemetry v1.17.0](https://www.nuget.org/packages/OpenTelemetry/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Api/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Api/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api.ProviderBuilderExtensions v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Api.ProviderBuilderExtensions/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Api.ProviderBuilderExtensions/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Console v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Console/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.Console/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.InMemory v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.InMemory/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.OpenTelemetryProtocol v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.OpenTelemetryProtocol/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Exporter.Zipkin v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Exporter.Zipkin/1.17.0) No notable changes. See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0/src/OpenTelemetry.Exporter.Zipkin/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Extensions.Hosting v1.17.0](https://www.nuget.org/packages/OpenTelemetry.Extensions.Hosting/1.17.0) No notable changes. ... (truncated) ## 1.17.0-rc.1 The following changes are from the previous release [1.16.0](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/core-1.16.0). * NuGet: [OpenTelemetry v1.17.0-rc.1](https://www.nuget.org/packages/OpenTelemetry/1.17.0-rc.1) * Fixed a metric point reclaim data race on CPU ARM architectures. ([#7401](open-telemetry/opentelemetry-dotnet#7401)) * The library is now marked as trim and AOT compatible. ([#7441](open-telemetry/opentelemetry-dotnet#7441)) * Replaced the vendored copy of `EnvironmentVariablesConfigurationProvider` with a direct `Microsoft.Extensions.Configuration.EnvironmentVariables` package dependency. Consumers gain automatic pickup of upstream bug fixes and security patches; no public API or behavioural change. ([#7146](open-telemetry/opentelemetry-dotnet#7146)) * Added a verbose `OpenTelemetry-Sdk` self-diagnostics event that is emitted when an activity is dropped because its local (in-process) parent is not recorded. ([#7427](open-telemetry/opentelemetry-dotnet#7427)) * Added support for a Schema URL on `Resource` instances. ([#7472](open-telemetry/opentelemetry-dotnet#7472)) * Fixed a metric storage leak that occurred when meters and instruments were repeatedly created and disposed. ([#7466](open-telemetry/opentelemetry-dotnet#7466)) * Added `ExcludedTagKeys` property to `MetricStreamConfiguration` to support excluding specific tag keys from metric streams. ([#7373](open-telemetry/opentelemetry-dotnet#7373)) See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet/blob/core-1.17.0-rc.1/src/OpenTelemetry/CHANGELOG.md) for details. * NuGet: [OpenTelemetry.Api v1.17.0-rc.1](https://www.nuget.org/packages/OpenTelemetry.Api/1.17.0-rc.1) * Fixed `TraceContextPropagator` to normalize empty `tracestate` header values to `null` when extracting trace context. ([#7407](open-telemetry/opentelemetry-dotnet#7407), [#7433](open-telemetry/opentelemetry-dotnet#7433)) * The library is now marked as trim and AOT compatible. ([#7441](open-telemetry/opentelemetry-dotnet#7441)) * **Experimental (pre-release builds only):** Updated `EnvironmentVariableCarrier.Get` to read only the normalized environment variable name, following the updated [environment variable carrier specification](open-telemetry/opentelemetry-specification#5144). Non-normalized carrier keys are no longer matched, even when they would normalize to the requested key. ... (truncated) ## 1.17.0-beta.1 The following changes are from the previous release [1.16.0-beta.1](https://github.com/open-telemetry/opentelemetry-dotnet/releases/tag/coreunstable-1.16.0-beta.1). * NuGet: [OpenTelemetry.Exporter.Prometheus.AspNetCore v1.17.0-beta.1](https://www.nuget.org/packages/OpenTelemetry.Exporter.Prometheus.AspNetCore/1.17.0-beta.1) * Added a verbose-level diagnostic event for ignored metrics. ([#7429](open-telemetry/opentelemetry-dotnet#7429)) * The library is now marked as trim and AOT compatible. ([#7441](open-telemetry/opentelemetry-dotnet#7441)) * Fix double unit suffixes in metric names when using OpenMetrics. ([#7454](open-telemetry/opentelemetry-dotnet#7454)) * Fix incorrect handling of leading digits in metric names for OpenMetrics. ([#7454](open-telemetry/opentelemetry-dotnet#7454)) * Add `PrometheusAspNetCoreOptions.ScopeInfoEnabled` property to enable or disable scope labels in Prometheus metrics. Defaults to `true`. ([#7436](open-telemetry/opentelemetry-dotnet#7436)) * Added support for the `dots` and `values` Prometheus UTF-8 name escaping schemes when negotiated via the `Accept` header. ([#7439](open-telemetry/opentelemetry-dotnet#7439)) * Add `PrometheusAspNetCoreOptions.TargetInfoEnabled` property to enable or disable the `target_info` metric in Prometheus metrics. Defaults to `true`. ([#7438](open-telemetry/opentelemetry-dotnet#7438)) * Added support for the `allow-utf-8` Prometheus UTF-8 name escaping scheme when negotiated via the `Accept` header. ([#7440](open-telemetry/opentelemetry-dotnet#7440)) * Add `PrometheusAspNetCoreOptions.ResourceConstantLabels` property to select resource attributes to add to each metric as constant labels. Defaults to `null` (no resource attributes are added as metric labels). ([#7471](open-telemetry/opentelemetry-dotnet#7471)) * Add `PrometheusAspNetCoreOptions.MaxScrapeResponseSizeBytes` to configure the maximum size of a scrape response. The default is now ~166 MiB. ([#7487](open-telemetry/opentelemetry-dotnet#7487)) * A scrape whose serialized output exceeds the maximum scrape response size limit now responds with HTTP 500. ([#7487](open-telemetry/opentelemetry-dotnet#7487)) * Fixed the Prometheus text exposition format emitting redundant comments. ([#7491](open-telemetry/opentelemetry-dotnet#7491)) * Made `Accept` header content negotiation consistent with the `PrometheusHttpListener` endpoint. ... (truncated) Commits viewable in [compare view](open-telemetry/opentelemetry-dotnet@core-1.16.0...core-1.17.0). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: MelfusX <MelfusX@gmail.com>
Pull Request
Description
Implements document-scoped
$dynamicRefresolution per JSON Schema 2020-12 §8.2.3.2. Bare$dynamicRefschemas (no$ref) now deserialize asOpenApiSchemaReferencewhoseTargetresolves via per-document$dynamicAnchorand$anchorregistries inOpenApiWorkspace.Resolution order in
Target$dynamicAnchorindex — single candidate resolves automatically$anchorfallback — when zero$dynamicAnchorcandidates exist (per §8.2.3.2)null— when ambiguous (multiple candidates need dynamic-scope tracking)Type of Change
Public APIs for consumers tracking dynamic scope
GetDynamicAnchorCandidates(doc, anchorName)— returns all candidate schemasResolveDynamicAnchorInContext(contextSchema, anchorName)— resolves against a specific schema's$defs$refsibling behaviorThis PR relies on the existing OpenAPI.NET 3.1/3.2 behavior where
$refschema siblings are preserved onJsonSchemaReferenceand surfaced throughOpenApiSchemaReference's existing reference-first property getters.This PR does not introduce that behavior. It extends the same storage model to bare
$dynamicRefschemas so sibling keywords are preserved while the schema participates in reference resolution.See #2919 for a broader discussion on whether the reference-first getter model should be revised for assertion keywords.
Anchor index coverage
Registries are populated by recursively walking the entire document tree: component schemas, reusable component definitions (parameters, responses, request bodies, headers, callbacks, path items, media types), inline schemas (paths, operations, webhooks), and all nested subschema locations (
$defs,properties,items,allOf,if/then/else, etc.).Open question
When multiple schemas declare the same
$dynamicAnchor,Targetreturnsnull(ambiguous). The spec requires the outermost candidate in the dynamic evaluation scope. Automatic resolution would require threading evaluation context throughTarget(e.g.,AsyncLocal<Stack>). Currently consumers handle this viaGetDynamicAnchorCandidates+ResolveDynamicAnchorInContext. Feedback welcome on whether the library should handle this automatically or leave it to consumers.Testing
Serialize_DoesNotMutateDomfailures on clean main)46 dynamic-ref tests across V31 and V32 covering: bare
$dynamicRefdeserialization, resolution to anchors in all schema locations, ambiguity handling,$anchorfallback,$dynamicAnchorprecedence, round-trip serialization, sibling preservation, context-aware resolution, OM-built document, and$refregression.Microsoft.OpenApi.Tests: 1149 passed.Microsoft.OpenApi.Readers.Tests: 535 passed, 7 pre-existing failures.Checklist
Versions applicability
Related
$refschemas)