Skip to content

Commit 45977b5

Browse files
committed
fix: OpenAPIDocument JsonSchemaDialect property is now a URI
Signed-off-by: Vincent Biret <[email protected]>
1 parent 4ee1d8b commit 45977b5

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void RegisterComponents()
4646
/// <summary>
4747
/// The default value for the $schema keyword within Schema Objects contained within this OAS document. This MUST be in the form of a URI.
4848
/// </summary>
49-
public string? JsonSchemaDialect { get; set; }
49+
public Uri? JsonSchemaDialect { get; set; }
5050

5151
/// <summary>
5252
/// An array of Server Objects, which provide connectivity information to a target server.
@@ -161,7 +161,7 @@ public void SerializeAsV31(IOpenApiWriter writer)
161161
writer.WriteProperty(OpenApiConstants.OpenApi, "3.1.1");
162162

163163
// jsonSchemaDialect
164-
writer.WriteProperty(OpenApiConstants.JsonSchemaDialect, JsonSchemaDialect);
164+
writer.WriteProperty(OpenApiConstants.JsonSchemaDialect, JsonSchemaDialect?.ToString());
165165

166166
SerializeInternal(writer, OpenApiSpecVersion.OpenApi3_1, (w, element) => element.SerializeAsV31(w));
167167

src/Microsoft.OpenApi/Reader/V31/OpenApiDocumentDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal static partial class OpenApiV31Deserializer
2020
} /* Version is valid field but we already parsed it */
2121
},
2222
{"info", (o, n, _) => o.Info = LoadInfo(n, o)},
23-
{"jsonSchemaDialect", (o, n, _) => o.JsonSchemaDialect = n.GetScalarValue() },
23+
{"jsonSchemaDialect", (o, n, _) => { if (n.GetScalarValue() is string {} sjsd && Uri.TryCreate(sjsd, UriKind.Absolute, out var jsd)) {o.JsonSchemaDialect = jsd;}} },
2424
{"servers", (o, n, _) => o.Servers = n.CreateList(LoadServer, o)},
2525
{"paths", (o, n, _) => o.Paths = LoadPaths(n, o)},
2626
{"webhooks", (o, n, _) => o.Webhooks = n.CreateMap(LoadPathItem, o)},

test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds()
405405
Title = "Webhook Example",
406406
Version = "1.0.0"
407407
},
408-
JsonSchemaDialect = "http://json-schema.org/draft-07/schema#",
408+
JsonSchemaDialect = new Uri("http://json-schema.org/draft-07/schema#"),
409409
Webhooks = new Dictionary<string, IOpenApiPathItem>
410410
{
411411
["pets"] = components.PathItems["pets"]

test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ public async Task SerializeDocumentWithRootJsonSchemaDialectPropertyWorks()
19531953
Title = "JsonSchemaDialectTest",
19541954
Version = "1.0.0"
19551955
},
1956-
JsonSchemaDialect = "http://json-schema.org/draft-07/schema#"
1956+
JsonSchemaDialect = new Uri("http://json-schema.org/draft-07/schema#")
19571957
};
19581958

19591959
var expected = @"openapi: '3.1.1'

test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ namespace Microsoft.OpenApi.Models
718718
public System.Collections.Generic.IDictionary<string, Microsoft.OpenApi.Interfaces.IOpenApiExtension>? Extensions { get; set; }
719719
public Microsoft.OpenApi.Models.OpenApiExternalDocs? ExternalDocs { get; set; }
720720
public Microsoft.OpenApi.Models.OpenApiInfo Info { get; set; }
721-
public string? JsonSchemaDialect { get; set; }
721+
public System.Uri? JsonSchemaDialect { get; set; }
722722
public Microsoft.OpenApi.Models.OpenApiPaths Paths { get; set; }
723723
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiSecurityRequirement>? SecurityRequirements { get; set; }
724724
public System.Collections.Generic.IList<Microsoft.OpenApi.Models.OpenApiServer>? Servers { get; set; }

0 commit comments

Comments
 (0)