Skip to content

Commit c637cc4

Browse files
authored
Merge pull request #2108 from microsoft/chore/string-comparisons
chore/string comparisons
2 parents c1f6733 + 5a27a3e commit c637cc4

File tree

87 files changed

+181
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+181
-135
lines changed

src/Microsoft.OpenApi.Workbench/MainModel.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ internal async Task ParseDocumentAsync()
219219
{
220220
if (!string.IsNullOrWhiteSpace(_inputFile))
221221
{
222-
stream = _inputFile.StartsWith("http") ? await _httpClient.GetStreamAsync(_inputFile)
222+
stream = _inputFile.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? await _httpClient.GetStreamAsync(_inputFile)
223223
: new FileStream(_inputFile, FileMode.Open);
224224
}
225225
else
@@ -241,7 +241,7 @@ internal async Task ParseDocumentAsync()
241241
};
242242
if (ResolveExternal && !string.IsNullOrWhiteSpace(_inputFile))
243243
{
244-
settings.BaseUrl = _inputFile.StartsWith("http") ? new(_inputFile)
244+
settings.BaseUrl = _inputFile.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? new(_inputFile)
245245
: new("file://" + Path.GetDirectoryName(_inputFile) + "/");
246246
}
247247

src/Microsoft.OpenApi/Expressions/RuntimeExpression.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,39 @@ public static RuntimeExpression Build(string expression)
3131
{
3232
Utils.CheckArgumentNullOrEmpty(expression);
3333

34-
if (!expression.StartsWith(Prefix))
34+
if (!expression.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase))
3535
{
3636
return new CompositeExpression(expression);
3737
}
3838

3939
// $url
40-
if (expression == UrlExpression.Url)
40+
if (expression.Equals(UrlExpression.Url, StringComparison.Ordinal))
4141
{
4242
return new UrlExpression();
4343
}
4444

4545
// $method
46-
if (expression == MethodExpression.Method)
46+
if (expression.Equals(MethodExpression.Method, StringComparison.Ordinal))
4747
{
4848
return new MethodExpression();
4949
}
5050

5151
// $statusCode
52-
if (expression == StatusCodeExpression.StatusCode)
52+
if (expression.Equals(StatusCodeExpression.StatusCode, StringComparison.Ordinal))
5353
{
5454
return new StatusCodeExpression();
5555
}
5656

5757
// $request.
58-
if (expression.StartsWith(RequestExpression.Request))
58+
if (expression.StartsWith(RequestExpression.Request, StringComparison.Ordinal))
5959
{
6060
var subString = expression.Substring(RequestExpression.Request.Length);
6161
var source = SourceExpression.Build(subString);
6262
return new RequestExpression(source);
6363
}
6464

6565
// $response.
66-
if (expression.StartsWith(ResponseExpression.Response))
66+
if (expression.StartsWith(ResponseExpression.Response, StringComparison.Ordinal))
6767
{
6868
var subString = expression.Substring(ResponseExpression.Response.Length);
6969
var source = SourceExpression.Build(subString);

src/Microsoft.OpenApi/Expressions/SourceExpression.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using Microsoft.OpenApi.Exceptions;
56
using Microsoft.OpenApi.Properties;
67

@@ -37,27 +38,27 @@ protected SourceExpression(string value)
3738
var expressions = expression.Split('.');
3839
if (expressions.Length == 2)
3940
{
40-
if (expression.StartsWith(HeaderExpression.Header))
41+
if (expression.StartsWith(HeaderExpression.Header, StringComparison.Ordinal))
4142
{
4243
// header.
4344
return new HeaderExpression(expressions[1]);
4445
}
4546

46-
if (expression.StartsWith(QueryExpression.Query))
47+
if (expression.StartsWith(QueryExpression.Query, StringComparison.Ordinal))
4748
{
4849
// query.
4950
return new QueryExpression(expressions[1]);
5051
}
5152

52-
if (expression.StartsWith(PathExpression.Path))
53+
if (expression.StartsWith(PathExpression.Path, StringComparison.Ordinal))
5354
{
5455
// path.
5556
return new PathExpression(expressions[1]);
5657
}
5758
}
5859

5960
// body
60-
if (expression.StartsWith(BodyExpression.Body))
61+
if (expression.StartsWith(BodyExpression.Body, StringComparison.Ordinal))
6162
{
6263
var subString = expression.Substring(BodyExpression.Body.Length);
6364
if (string.IsNullOrEmpty(subString))

src/Microsoft.OpenApi/Extensions/OpenApiExtensibleExtensions.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using Microsoft.OpenApi.Exceptions;
56
using Microsoft.OpenApi.Interfaces;
67
using Microsoft.OpenApi.Models;
@@ -26,7 +27,7 @@ public static void AddExtension<T>(this T element, string name, IOpenApiExtensio
2627
Utils.CheckArgumentNull(element);
2728
Utils.CheckArgumentNullOrEmpty(name);
2829

29-
if (!name.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix))
30+
if (!name.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase))
3031
{
3132
throw new OpenApiException(string.Format(SRResource.ExtensionFieldNameMustBeginWithXDash, name));
3233
}

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList<OpenApiServer>?
389389
else
390390
{
391391
var relativeUrl = firstServerUrl.OriginalString;
392-
if (relativeUrl.StartsWith("//"))
392+
if (relativeUrl.StartsWith("//", StringComparison.OrdinalIgnoreCase))
393393
{
394394
var pathPosition = relativeUrl.IndexOf('/', 3);
395395
writer.WriteProperty(OpenApiConstants.Host, relativeUrl.Substring(0, pathPosition));

src/Microsoft.OpenApi/Models/OpenApiReference.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public string ReferenceV3
9595
{
9696
return Id;
9797
}
98-
if (Id.StartsWith("http"))
98+
if (Id.StartsWith("http", StringComparison.OrdinalIgnoreCase))
9999
{
100100
return Id;
101101
}
@@ -238,7 +238,7 @@ private string GetExternalReferenceV3()
238238
return ExternalResource + "#" + Id;
239239
}
240240

241-
if (Id.StartsWith("http"))
241+
if (Id.StartsWith("http", StringComparison.OrdinalIgnoreCase))
242242
{
243243
return Id;
244244
}

src/Microsoft.OpenApi/Reader/V2/OpenApiContactDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ internal static partial class OpenApiV2Deserializer
3232

3333
private static readonly PatternFieldMap<OpenApiContact> _contactPatternFields = new()
3434
{
35-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
35+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
3636
};
3737

3838
public static OpenApiContact LoadContact(ParseNode node, OpenApiDocument hostDocument)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ internal static partial class OpenApiV2Deserializer
111111
private static readonly PatternFieldMap<OpenApiDocument> _openApiPatternFields = new()
112112
{
113113
// We have no semantics to verify X- nodes, therefore treat them as just values.
114-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
114+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
115115
};
116116

117117
private static void MakeServers(IList<OpenApiServer> servers, ParsingContext context, RootNode rootNode)

src/Microsoft.OpenApi/Reader/V2/OpenApiExternalDocsDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal static partial class OpenApiV2Deserializer
3030
private static readonly PatternFieldMap<OpenApiExternalDocs> _externalDocsPatternFields =
3131
new()
3232
{
33-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
33+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
3434
};
3535

3636
public static OpenApiExternalDocs LoadExternalDocs(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiHeaderDeserializer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -95,7 +95,7 @@ internal static partial class OpenApiV2Deserializer
9595

9696
private static readonly PatternFieldMap<OpenApiHeader> _headerPatternFields = new()
9797
{
98-
{s => s.StartsWith("x-", StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
98+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
9999
};
100100

101101
private static OpenApiSchema GetOrCreateSchema(OpenApiHeader p)

src/Microsoft.OpenApi/Reader/V2/OpenApiInfoDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ internal static partial class OpenApiV2Deserializer
4444

4545
private static readonly PatternFieldMap<OpenApiInfo> _infoPatternFields = new()
4646
{
47-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
47+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
4848
};
4949

5050
public static OpenApiInfo LoadInfo(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiLicenseDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal static partial class OpenApiV2Deserializer
2828

2929
private static readonly PatternFieldMap<OpenApiLicense> _licensePatternFields = new()
3030
{
31-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
31+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
3232
};
3333

3434
public static OpenApiLicense LoadLicense(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiOperationDeserializer.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ internal static partial class OpenApiV2Deserializer
8181
private static readonly PatternFieldMap<OpenApiOperation> _operationPatternFields =
8282
new()
8383
{
84-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
84+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
8585
};
8686

8787
private static readonly FixedFieldMap<OpenApiResponses> _responsesFixedFields = new();
8888

8989
private static readonly PatternFieldMap<OpenApiResponses> _responsesPatternFields =
9090
new()
9191
{
92-
{s => !s.StartsWith("x-"), (o, p, n, t) => o.Add(p, LoadResponse(n, t))},
93-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
92+
{s => !s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, t) => o.Add(p, LoadResponse(n, t))},
93+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
9494
};
9595

9696
internal static OpenApiOperation LoadOperation(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiParameterDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ internal static partial class OpenApiV2Deserializer
106106
private static readonly PatternFieldMap<OpenApiParameter> _parameterPatternFields =
107107
new()
108108
{
109-
{s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase),
109+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase) && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase),
110110
(o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
111111
};
112112

src/Microsoft.OpenApi/Reader/V2/OpenApiPathItemDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal static partial class OpenApiV2Deserializer
3434
private static readonly PatternFieldMap<OpenApiPathItem> _pathItemPatternFields =
3535
new()
3636
{
37-
{s => s.StartsWith("x-", StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))},
37+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))},
3838
};
3939

4040
public static OpenApiPathItem LoadPathItem(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiPathsDeserializer.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using Microsoft.OpenApi.Extensions;
56
using Microsoft.OpenApi.Models;
67
using Microsoft.OpenApi.Reader.ParseNodes;
@@ -17,8 +18,8 @@ internal static partial class OpenApiV2Deserializer
1718

1819
private static readonly PatternFieldMap<OpenApiPaths> _pathsPatternFields = new()
1920
{
20-
{s => s.StartsWith("/"), (o, k, n, t) => o.Add(k, LoadPathItem(n, t))},
21-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
21+
{s => s.StartsWith("/", StringComparison.OrdinalIgnoreCase), (o, k, n, t) => o.Add(k, LoadPathItem(n, t))},
22+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
2223
};
2324

2425
public static OpenApiPaths LoadPaths(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiResponseDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal static partial class OpenApiV2Deserializer
4242
private static readonly PatternFieldMap<OpenApiResponse> _responsePatternFields =
4343
new()
4444
{
45-
{s => s.StartsWith("x-") && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase),
45+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase) && !s.Equals(OpenApiConstants.ExamplesExtension, StringComparison.OrdinalIgnoreCase),
4646
(o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
4747
};
4848

src/Microsoft.OpenApi/Reader/V2/OpenApiSchemaDeserializer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System.Collections.Generic;
@@ -155,7 +155,7 @@ internal static partial class OpenApiV2Deserializer
155155

156156
private static readonly PatternFieldMap<OpenApiSchema> _openApiSchemaPatternFields = new PatternFieldMap<OpenApiSchema>
157157
{
158-
{s => s.StartsWith("x-", StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
158+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
159159
};
160160

161161
public static IOpenApiSchema LoadSchema(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiSecuritySchemeDeserializer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -78,7 +78,7 @@ internal static partial class OpenApiV2Deserializer
7878
private static readonly PatternFieldMap<OpenApiSecurityScheme> _securitySchemePatternFields =
7979
new()
8080
{
81-
{s => s.StartsWith("x-", StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
81+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
8282
};
8383

8484
public static IOpenApiSecurityScheme LoadSecurityScheme(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiTagDeserializer.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using Microsoft.OpenApi.Extensions;
56
using Microsoft.OpenApi.Models;
67
using Microsoft.OpenApi.Reader.ParseNodes;
@@ -31,7 +32,7 @@ internal static partial class OpenApiV2Deserializer
3132

3233
private static readonly PatternFieldMap<OpenApiTag> _tagPatternFields = new()
3334
{
34-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
35+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p, n))}
3536
};
3637

3738
public static OpenApiTag LoadTag(ParseNode n, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V2/OpenApiV2Deserializer.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using System.Collections.Generic;
56
using System.Linq;
67
using System.Text.Json.Nodes;
@@ -98,7 +99,7 @@ private static (string, string) GetReferenceIdAndExternalResource(string pointer
9899
{
99100
var refSegments = pointer.Split('/');
100101
var refId = refSegments.Last();
101-
var isExternalResource = !refSegments.First().StartsWith("#");
102+
var isExternalResource = !refSegments.First().StartsWith("#", StringComparison.OrdinalIgnoreCase);
102103

103104
string externalResource = isExternalResource ? $"{refSegments.First()}/{refSegments[1].TrimEnd('#')}" : null;
104105

src/Microsoft.OpenApi/Reader/V2/OpenApiV2VersionService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public OpenApiReference ConvertToOpenApiReference(string reference, ReferenceTyp
161161
}
162162
else if (segments.Length == 2)
163163
{
164-
if (reference.StartsWith("#"))
164+
if (reference.StartsWith("#", StringComparison.OrdinalIgnoreCase))
165165
{
166166
// "$ref": "#/definitions/Pet"
167167
try
@@ -178,7 +178,7 @@ public OpenApiReference ConvertToOpenApiReference(string reference, ReferenceTyp
178178
// Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier
179179
var id = segments[1];
180180
// $ref: externalSource.yaml#/Pet
181-
if (id.StartsWith("/definitions/"))
181+
if (id.StartsWith("/definitions/", StringComparison.Ordinal))
182182
{
183183
var localSegments = id.Split('/');
184184
var referencedType = GetReferenceTypeV2FromName(localSegments[1]);

src/Microsoft.OpenApi/Reader/V2/OpenApiXmlDeserializer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal static partial class OpenApiV2Deserializer
5151
private static readonly PatternFieldMap<OpenApiXml> _xmlPatternFields =
5252
new()
5353
{
54-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))}
54+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))}
5555
};
5656

5757
public static OpenApiXml LoadXml(ParseNode node, OpenApiDocument hostDocument)

src/Microsoft.OpenApi/Reader/V3/OpenApiCallbackDeserializer.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

4+
using System;
45
using Microsoft.OpenApi.Expressions;
56
using Microsoft.OpenApi.Extensions;
67
using Microsoft.OpenApi.Models;
@@ -21,8 +22,8 @@ internal static partial class OpenApiV3Deserializer
2122
private static readonly PatternFieldMap<OpenApiCallback> _callbackPatternFields =
2223
new()
2324
{
24-
{s => !s.StartsWith("x-"), (o, p, n, t) => o.AddPathItem(RuntimeExpression.Build(p), LoadPathItem(n, t))},
25-
{s => s.StartsWith("x-"), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))},
25+
{s => !s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, t) => o.AddPathItem(RuntimeExpression.Build(p), LoadPathItem(n, t))},
26+
{s => s.StartsWith(OpenApiConstants.ExtensionFieldNamePrefix, StringComparison.OrdinalIgnoreCase), (o, p, n, _) => o.AddExtension(p, LoadExtension(p,n))},
2627
};
2728

2829
public static IOpenApiCallback LoadCallback(ParseNode node, OpenApiDocument hostDocument)

0 commit comments

Comments
 (0)