Skip to content

Commit 69e6d81

Browse files
committed
Fix code smells
1 parent d92509f commit 69e6d81

File tree

5 files changed

+6
-56
lines changed

5 files changed

+6
-56
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Microsoft.OpenApi.Readers.V3
1414
/// </summary>
1515
internal static partial class OpenApiV3Deserializer
1616
{
17-
public static FixedFieldMap<OpenApiInfo> InfoFixedFields = new FixedFieldMap<OpenApiInfo>
17+
public static readonly FixedFieldMap<OpenApiInfo> InfoFixedFields = new FixedFieldMap<OpenApiInfo>
1818
{
1919
{
2020
"title", (o, n) =>

src/Microsoft.OpenApi.Readers/V31/OpenApiInfoDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Readers.V31
1111
/// </summary>
1212
internal static partial class OpenApiV31Deserializer
1313
{
14-
public static FixedFieldMap<OpenApiInfo> InfoFixedFields = new FixedFieldMap<OpenApiInfo>
14+
public static readonly FixedFieldMap<OpenApiInfo> InfoFixedFields = new FixedFieldMap<OpenApiInfo>
1515
{
1616
{
1717
"title", (o, n) =>
@@ -57,7 +57,7 @@ internal static partial class OpenApiV31Deserializer
5757
}
5858
};
5959

60-
public static PatternFieldMap<OpenApiInfo> InfoPatternFields = new PatternFieldMap<OpenApiInfo>
60+
public static readonly PatternFieldMap<OpenApiInfo> InfoPatternFields = new PatternFieldMap<OpenApiInfo>
6161
{
6262
{s => s.StartsWith("x-"), (o, k, n) => o.AddExtension(k,LoadExtension(k, n))}
6363
};

src/Microsoft.OpenApi.Readers/V31/OpenApiResponsesDeserializer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ namespace Microsoft.OpenApi.Readers.V31
1313
/// </summary>
1414
internal static partial class OpenApiV31Deserializer
1515
{
16-
public static FixedFieldMap<OpenApiResponses> ResponsesFixedFields = new FixedFieldMap<OpenApiResponses>();
16+
public static readonly FixedFieldMap<OpenApiResponses> ResponsesFixedFields = new FixedFieldMap<OpenApiResponses>();
1717

18-
public static PatternFieldMap<OpenApiResponses> ResponsesPatternFields = new PatternFieldMap<OpenApiResponses>
18+
public static readonly PatternFieldMap<OpenApiResponses> ResponsesPatternFields = new PatternFieldMap<OpenApiResponses>
1919
{
2020
{s => !s.StartsWith("x-"), (o, p, n) => o.Add(p, LoadResponse(n))},
2121
{s => s.StartsWith("x-"), (o, p, n) => o.AddExtension(p, LoadExtension(p,n))}

src/Microsoft.OpenApi/Extensions/OpenApiReferencableExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ private static IOpenApiReferenceable ResolveReferenceOnHeaderElement(
5959
{
6060
switch (propertyName)
6161
{
62-
case OpenApiConstants.Schema:
63-
return (IOpenApiReferenceable)headerElement.Schema;
6462
case OpenApiConstants.Examples when mapKey != null:
6563
return headerElement.Examples[mapKey];
6664
default:
@@ -76,8 +74,6 @@ private static IOpenApiReferenceable ResolveReferenceOnParameterElement(
7674
{
7775
switch (propertyName)
7876
{
79-
case OpenApiConstants.Schema:
80-
return (IOpenApiReferenceable)parameterElement.Schema;
8177
case OpenApiConstants.Examples when mapKey != null:
8278
return parameterElement.Examples[mapKey];
8379
default:

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

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -50,53 +50,7 @@ public void ParsePrimitiveSchemaShouldSucceed()
5050
.Format("email")
5151
.Build());
5252
}
53-
}
54-
55-
[Fact]
56-
public void ParsePrimitiveSchemaFragmentShouldSucceed()
57-
{
58-
using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml")))
59-
{
60-
var reader = new OpenApiStreamReader();
61-
var diagnostic = new OpenApiDiagnostic();
62-
63-
// Act
64-
//var schema = reader.ReadFragment<JsonSchema>(stream, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
65-
66-
//// Assert
67-
//diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
68-
69-
//schema.Should().BeEquivalentTo(
70-
// new JsonSchemaBuilder()
71-
// .Type(SchemaValueType.String)
72-
// .Format("email"));
73-
}
74-
}
75-
76-
[Fact]
77-
public void ParsePrimitiveStringSchemaFragmentShouldSucceed()
78-
{
79-
var input = @"
80-
{ ""type"": ""integer"",
81-
""format"": ""int64"",
82-
""default"": 88
83-
}
84-
";
85-
var reader = new OpenApiStringReader();
86-
var diagnostic = new OpenApiDiagnostic();
87-
88-
// Act
89-
//var schema = reader.ReadFragment<JsonSchema>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);
90-
91-
//// Assert
92-
//diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());
93-
94-
//schema.Should().BeEquivalentTo(
95-
// new JsonSchemaBuilder()
96-
// .Type(SchemaValueType.Integer)
97-
// .Format("int64")
98-
// .Default(88), options => options.IgnoringCyclicReferences());
99-
}
53+
}
10054

10155
[Fact]
10256
public void ParseExampleStringFragmentShouldSucceed()

0 commit comments

Comments
 (0)