Skip to content

Commit fb31544

Browse files
committed
Fixes based on CR
1 parent 42fce80 commit fb31544

File tree

9 files changed

+45
-46
lines changed

9 files changed

+45
-46
lines changed

src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public enum ReferenceResolutionSetting
2626
/// <summary>
2727
/// Convert all references to references of valid domain objects.
2828
/// </summary>
29-
ResolveRemoteReferences
29+
ResolveAllReferences
3030
}
3131

3232
/// <summary>

src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,14 @@ public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
6464
// Resolve References if requested
6565
switch (_settings.ReferenceResolution)
6666
{
67-
case ReferenceResolutionSetting.ResolveRemoteReferences:
67+
case ReferenceResolutionSetting.ResolveAllReferences:
6868
throw new ArgumentException(Properties.SRResource.CannotResolveRemoteReferencesSynchronously);
6969
case ReferenceResolutionSetting.ResolveLocalReferences:
7070
var resolver = new OpenApiReferenceResolver(document);
7171
var walker = new OpenApiWalker(resolver);
7272
walker.Walk(document);
7373
break;
74-
case
75-
ReferenceResolutionSetting.DoNotResolveReferences:
74+
case ReferenceResolutionSetting.DoNotResolveReferences:
7675
break;
7776
}
7877

src/Microsoft.OpenApi.Readers/ParsingContext.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ public void StartObject(string objectName)
160160
/// <summary>
161161
/// Maintain history of traversals to avoid stack overflows from cycles
162162
/// </summary>
163-
/// <param name="loopId">Any unique identifier for a stack</param>
164-
/// <param name="key">Identifier used to </param>
165-
/// <returns></returns>
163+
/// <param name="loopId">Any unique identifier for a stack.</param>
164+
/// <param name="key">Identifier used for current context.</param>
165+
/// <returns>If method returns false a loop was detected and the key is not added.</returns>
166166
public bool PushLoop(string loopId, string key)
167167
{
168168
Stack<string> stack;
@@ -185,7 +185,7 @@ public bool PushLoop(string loopId, string key)
185185
/// <summary>
186186
/// Reset loop tracking stack
187187
/// </summary>
188-
/// <param name="loopid"></param>
188+
/// <param name="loopid">Identifier of loop to clear</param>
189189
internal void ClearLoop(string loopid)
190190
{
191191
_loopStacks[loopid].Clear();
@@ -194,7 +194,7 @@ internal void ClearLoop(string loopid)
194194
/// <summary>
195195
/// Exit from the context in cycle detection
196196
/// </summary>
197-
/// <param name="loopid"></param>
197+
/// <param name="loopid">Identifier of loop</param>
198198
public void PopLoop(string loopid)
199199
{
200200
if (_loopStacks[loopid].Count > 0)

src/Microsoft.OpenApi.Readers/V3/OpenApiSchemaDeserializer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ internal static partial class OpenApiV3Deserializer
234234
{s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, n.CreateAny())}
235235
};
236236

237-
private const string schemaLoopId = "schema";
238-
239237
public static OpenApiSchema LoadSchema(ParseNode node)
240238
{
241239
var mapNode = node.CheckMapNode(OpenApiConstants.Schema);

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public class OpenApiSchema : IOpenApiSerializable, IOpenApiReferenceable, IOpenA
228228
/// <summary>
229229
/// Indicates object is a placeholder reference to an actual object and does not contain valid data.
230230
/// </summary>
231-
public bool UnresolvedReference { get; set; } = false;
231+
public bool UnresolvedReference { get; set; }
232232

233233
/// <summary>
234234
/// Reference object.

src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public virtual void Visit(IDictionary<string, OpenApiHeader> headers)
153153
}
154154

155155
/// <summary>
156-
/// Visits headers.
156+
/// Visits callbacks.
157157
/// </summary>
158158
public virtual void Visit(IDictionary<string, OpenApiCallback> callbacks)
159159
{

src/Microsoft.OpenApi/Services/OpenApiWalker.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ internal void Walk(OpenApiPaths paths)
210210
{
211211
foreach (var pathItem in paths)
212212
{
213-
Walk(pathItem.Key.Replace("/", "~1"), () => Walk(pathItem.Value));// JSON Pointer uses ~1 as an escape character for /
213+
Walk(pathItem.Key, () => Walk(pathItem.Value));// JSON Pointer uses ~1 as an escape character for /
214214
}
215215
}
216216
}
@@ -469,6 +469,7 @@ internal void Walk(OpenApiOperation operation)
469469
Walk(OpenApiConstants.RequestBody, () => Walk(operation.RequestBody));
470470
Walk(OpenApiConstants.Responses, () => Walk(operation.Responses));
471471
Walk(OpenApiConstants.Callbacks, () => Walk(operation.Callbacks));
472+
Walk(OpenApiConstants.Tags, () => Walk(operation.Tags));
472473

473474
Walk(operation as IOpenApiExtensible);
474475
}
@@ -588,7 +589,7 @@ internal void Walk(IDictionary<string, OpenApiHeader> headers)
588589
{
589590
foreach (var header in headers)
590591
{
591-
Walk(header.Key.Replace("/", "~1"), () => Walk(header.Value));
592+
Walk(header.Key, () => Walk(header.Value));
592593
}
593594
}
594595
}
@@ -608,7 +609,7 @@ internal void Walk(IDictionary<string, OpenApiCallback> callbacks)
608609
{
609610
foreach (var header in callbacks)
610611
{
611-
Walk(header.Key.Replace("/", "~1"), () => Walk(header.Value));
612+
Walk(header.Key, () => Walk(header.Value));
612613
}
613614
}
614615
}
@@ -628,7 +629,7 @@ internal void Walk(IDictionary<string, OpenApiMediaType> content)
628629
{
629630
foreach (var mediaType in content)
630631
{
631-
Walk(mediaType.Key.Replace("/", "~1"), () => Walk(mediaType.Value));
632+
Walk(mediaType.Key, () => Walk(mediaType.Value));
632633
}
633634
}
634635
}
@@ -988,7 +989,7 @@ internal void Walk(IOpenApiElement element)
988989
/// <param name="walk">An action that walks objects within the context.</param>
989990
private void Walk(string context, Action walk)
990991
{
991-
_visitor.Enter(context);
992+
_visitor.Enter(context.Replace("/", "~1"));
992993
walk();
993994
_visitor.Exit();
994995
}

test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -471,34 +471,34 @@ public void ParseSelfReferencingSchemaShouldNotStackOverflow()
471471
diagnostic.ShouldBeEquivalentTo(
472472
new OpenApiDiagnostic() { SpecificationVersion = OpenApiSpecVersion.OpenApi3_0 });
473473

474-
//var schemaExtension = new OpenApiSchema()
475-
//{
476-
// AllOf = { new OpenApiSchema()
477-
// {
478-
// Title = "schemaExtension",
479-
// Type = "object",
480-
// Properties = {
481-
// ["description"] = new OpenApiSchema() { Type = "string", Nullable = true},
482-
// ["targetTypes"] = new OpenApiSchema() {
483-
// Type = "array",
484-
// Items = new OpenApiSchema() {
485-
// Type = "string"
486-
// }
487-
// },
488-
// ["status"] = new OpenApiSchema() { Type = "string"},
489-
// ["owner"] = new OpenApiSchema() { Type = "string"},
490-
// ["child"] = null
491-
// }
492-
// }
493-
// },
494-
// Reference = new OpenApiReference()
495-
// {
496-
// Type = ReferenceType.Schema,
497-
// Id = "microsoft.graph.schemaExtension"
498-
// }
499-
//};
500-
501-
//schemaExtension.AllOf[0].Properties["child"] = schemaExtension;
474+
var schemaExtension = new OpenApiSchema()
475+
{
476+
AllOf = { new OpenApiSchema()
477+
{
478+
Title = "schemaExtension",
479+
Type = "object",
480+
Properties = {
481+
["description"] = new OpenApiSchema() { Type = "string", Nullable = true},
482+
["targetTypes"] = new OpenApiSchema() {
483+
Type = "array",
484+
Items = new OpenApiSchema() {
485+
Type = "string"
486+
}
487+
},
488+
["status"] = new OpenApiSchema() { Type = "string"},
489+
["owner"] = new OpenApiSchema() { Type = "string"},
490+
["child"] = null
491+
}
492+
}
493+
},
494+
Reference = new OpenApiReference()
495+
{
496+
Type = ReferenceType.Schema,
497+
Id = "microsoft.graph.schemaExtension"
498+
}
499+
};
500+
501+
schemaExtension.AllOf[0].Properties["child"] = schemaExtension;
502502

503503
components.Schemas["microsoft.graph.schemaExtension"].ShouldBeEquivalentTo(components.Schemas["microsoft.graph.schemaExtension"].AllOf[0].Properties["child"]);
504504
}

test/Microsoft.OpenApi.Tests/Walkers/WalkerLocationTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public void LocatePathOperationContentSchema()
9898
"#/paths",
9999
"#/paths/~1test",
100100
"#/paths/~1test/get",
101+
"#/paths/~1test/get/tags",
101102
"#/paths/~1test/get/responses",
102103
"#/paths/~1test/get/responses/200",
103104
"#/paths/~1test/get/responses/200/content",

0 commit comments

Comments
 (0)