Skip to content

Commit

Permalink
Update the schema registry reference URI and public API
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Nov 21, 2023
1 parent e8ecc1a commit 1afe195
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ private static void RegisterComponentsSchemasInGlobalRegistry(IDictionary<string

foreach (var schema in schemas)
{
var refUri = new Uri(OpenApiConstants.v2ReferenceUri + schema.Key);
var refUri = new Uri(OpenApiConstants.V2ReferenceUri + schema.Key);
SchemaRegistry.Global.Register(refUri, schema.Value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static OpenApiComponents LoadComponents(ParseNode node)

foreach (var schema in components.Schemas)
{
var refUri = new Uri(OpenApiConstants.v3ReferenceUri + schema.Key);
var refUri = new Uri(OpenApiConstants.V3ReferenceUri + schema.Key);
SchemaRegistry.Global.Register(refUri, schema.Value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static OpenApiComponents LoadComponents(ParseNode node)

foreach (var schema in components.Schemas)
{
var refUri = new Uri(OpenApiConstants.v3ReferenceUri + schema.Key);
var refUri = new Uri(OpenApiConstants.V3ReferenceUri + schema.Key);
SchemaRegistry.Global.Register(refUri, schema.Value);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OpenApi/Models/OpenApiConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,12 @@ public static class OpenApiConstants
/// <summary>
/// Field: V3 JsonSchema Reference Uri
/// </summary>
public const string v3ReferenceUri = "https://everything.json/components/schemas/";
public const string V3ReferenceUri = "https://registry/components/schemas/";

/// <summary>
/// Field: V2 JsonSchema Reference Uri
/// </summary>
public const string v2ReferenceUri = "https://everything.json/definitions/";
public const string V2ReferenceUri = "https://registry/definitions/";

#region V2.0

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private Dictionary<string, JsonSchema> ResolveJsonSchemas(IDictionary<string, Js
/// <returns></returns>
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)
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.OpenApi/Services/OpenApiWorkspace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
5 changes: 3 additions & 2 deletions test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,15 @@ 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";
public const string Webhooks = "webhooks";
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;
Expand Down Expand Up @@ -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<string> elements, System.Action<Microsoft.OpenApi.Writers.IOpenApiWriter, string> action) { }
public static void WriteOptionalCollection<T>(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IEnumerable<T> elements, System.Action<Microsoft.OpenApi.Writers.IOpenApiWriter, T> action) { }
public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary<string, Json.Schema.JsonSchema> elements, System.Action<Microsoft.OpenApi.Writers.IOpenApiWriter, string, Json.Schema.JsonSchema> action) { }
public static void WriteOptionalMap(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, string name, System.Collections.Generic.IDictionary<string, string> elements, System.Action<Microsoft.OpenApi.Writers.IOpenApiWriter, string> action) { }
Expand Down

0 comments on commit 1afe195

Please sign in to comment.