From 1afe195d1cc2d2b0be5167b0d18a056a521ecfde Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Tue, 21 Nov 2023 15:42:34 +0300 Subject: [PATCH] Update the schema registry reference URI and public API --- .../V2/OpenApiDocumentDeserializer.cs | 2 +- .../V3/OpenApiComponentsDeserializer.cs | 2 +- .../V31/OpenApiComponentsDeserializer.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiConstants.cs | 4 ++-- src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs | 2 +- src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs | 2 +- .../Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 5 +++-- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs index 2b02f5d3b..d90cf76a0 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiDocumentDeserializer.cs @@ -321,7 +321,7 @@ private static void RegisterComponentsSchemasInGlobalRegistry(IDictionary /// Field: V3 JsonSchema Reference Uri /// - public const string v3ReferenceUri = "https://everything.json/components/schemas/"; + public const string V3ReferenceUri = "https://registry/components/schemas/"; /// /// Field: V2 JsonSchema Reference Uri /// - public const string v2ReferenceUri = "https://everything.json/definitions/"; + public const string V2ReferenceUri = "https://registry/definitions/"; #region V2.0 diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs index 131c4e661..86bf11e00 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs @@ -249,7 +249,7 @@ private Dictionary ResolveJsonSchemas(IDictionary public JsonSchema ResolveJsonSchemaReference(Uri reference, string description = null, string summary = null) { - var refUri = $"https://everything.json{reference.OriginalString.Split('#').LastOrDefault()}"; + var refUri = $"https://registry{reference.OriginalString.Split('#').LastOrDefault()}"; var resolvedSchema = (JsonSchema)SchemaRegistry.Global.Get(new Uri(refUri)); if (resolvedSchema != null) diff --git a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs index b915c21d6..24924998e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs @@ -160,7 +160,7 @@ public JsonSchema ResolveJsonSchemaReference(Uri reference) { foreach (var jsonSchema in doc.Components.Schemas) { - var refUri = new Uri(OpenApiConstants.v3ReferenceUri + jsonSchema.Key); + var refUri = new Uri(OpenApiConstants.V3ReferenceUri + jsonSchema.Key); SchemaRegistry.Global.Register(refUri, jsonSchema.Value); } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 53d336b9f..a496589aa 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -453,6 +453,8 @@ namespace Microsoft.OpenApi.Models public const string Type = "type"; public const string UniqueItems = "uniqueItems"; public const string Url = "url"; + public const string V2ReferenceUri = "https://registry/definitions/"; + public const string V3ReferenceUri = "https://registry/components/schemas/"; public const string Value = "value"; public const string Variables = "variables"; public const string Version = "version"; @@ -460,8 +462,6 @@ namespace Microsoft.OpenApi.Models public const string Wrapped = "wrapped"; public const string WriteOnly = "writeOnly"; public const string Xml = "xml"; - public const string v2ReferenceUri = "https://everything.json/definitions/"; - public const string v3ReferenceUri = "https://everything.json/components/schemas/"; public static readonly System.Uri defaultUrl; public static readonly System.Version version2_0; public static readonly System.Version version3_0_0; @@ -1490,6 +1490,7 @@ namespace Microsoft.OpenApi.Writers } public static class OpenApiWriterExtensions { + public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable elements, System.Action action) { } public static void WriteOptionalCollection(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable elements, System.Action action) { } public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) { } public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary elements, System.Action action) { }