Repository navigation
fix: handle relative schema references without fragment and prevent UriFormatException (#3148) #3153
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
base: main
Are you sure you want to change the base?
fix: handle relative schema references without fragment and prevent UriFormatException (#3148) #3153
Changes from all commits
a13fbc2
8003bbf
d0eeafa
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 |
|---|---|---|
|
|
@@ -165,7 +165,7 @@ private static (string, string?) GetReferenceIdAndExternalResource(string pointe | |
|
|
||
| var isExternalResource = !refSegments[0].StartsWith("#", StringComparison.OrdinalIgnoreCase); | ||
| string? externalResource = null; | ||
| if (isExternalResource && pointer.Contains('#')) | ||
| if (isExternalResource) | ||
|
Contributor
Author
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. Addressed in commit d0eeafa. In both OpenApiDiscriminatorDeserializer (V31 and V32), LoadMapping now detects bare schema names (via IsBareSchemaName, checking that the value is not a URI reference or file path) and constructs a local OpenApiSchemaReference(pointer, hostDocument) with ExternalResource = null. This resolves the local schema in hostDocument.Components.Schemas properly for both mapping and defaultMapping (and x-oas-default-mapping). Added regression tests in V31Tests/OpenApiDiscriminatorTests.cs and V32Tests/OpenApiDiscriminatorTests.cs. |
||
| { | ||
| externalResource = pointer.Split('#')[0].TrimEnd('#'); | ||
| } | ||
|
|
||
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.
Addressed in commit d0eeafa. In BaseOpenApiReference.SetJsonPointerPath, authored pointers are now preserved directly without requiring # or http, correctly maintaining fragmentless relative references such as schemas/uuid.schema.json. In GetExternalReferenceV3(), standalone external references where ExternalResource == Id && !Id.Contains(#) return ExternalResource directly. Added round-trip serialization assertions in RelativeReferenceTests.cs and OpenApiSchemaReferenceDeserializerTests.cs.