Skip to content

Commit ddf17fe

Browse files
committed
chore: linting
Signed-off-by: Vincent Biret <[email protected]>
1 parent b328774 commit ddf17fe

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

src/Microsoft.OpenApi/Models/OpenApiReference.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT license.
33

44
using System;
5-
using System.Collections.Generic;
65
using System.Linq;
76
using System.Text.Json.Nodes;
87
using Microsoft.OpenApi.Reader;
@@ -165,7 +164,7 @@ public OpenApiReference(OpenApiReference reference)
165164
/// <summary>
166165
/// Serialize <see cref="OpenApiReference"/> to Open Api v3.1.
167166
/// </summary>
168-
public void SerializeAsV31(IOpenApiWriter writer)
167+
public virtual void SerializeAsV31(IOpenApiWriter writer)
169168
{
170169
SerializeInternal(writer, w =>
171170
{
@@ -178,7 +177,7 @@ public void SerializeAsV31(IOpenApiWriter writer)
178177
/// <summary>
179178
/// Serialize <see cref="OpenApiReference"/> to Open Api v3.0.
180179
/// </summary>
181-
public void SerializeAsV3(IOpenApiWriter writer)
180+
public virtual void SerializeAsV3(IOpenApiWriter writer)
182181
{
183182
SerializeInternal(writer);
184183
}
@@ -212,7 +211,7 @@ private void SerializeInternal(IOpenApiWriter writer, Action<IOpenApiWriter>? ca
212211
/// <summary>
213212
/// Serialize <see cref="OpenApiReference"/> to Open Api v2.0.
214213
/// </summary>
215-
public void SerializeAsV2(IOpenApiWriter writer)
214+
public virtual void SerializeAsV2(IOpenApiWriter writer)
216215
{
217216
Utils.CheckArgumentNull(writer);
218217

@@ -296,7 +295,7 @@ internal void EnsureHostDocumentIsSet(OpenApiDocument currentDocument)
296295
}
297296
private static string? GetPropertyValueFromNode(JsonObject jsonObject, string key) =>
298297
jsonObject.TryGetPropertyValue(key, out var valueNode) && valueNode is JsonValue valueCast && valueCast.TryGetValue<string>(out var strValue) ? strValue : null;
299-
internal void SetMetadataFromMapNode(MapNode mapNode)
298+
internal virtual void SetMetadataFromMapNode(MapNode mapNode)
300299
{
301300
if (mapNode.JsonNode is not JsonObject jsonObject) return;
302301

src/Microsoft.OpenApi/Models/OpenApiSchemaReferenceInformation.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public OpenApiSchemaReferenceInformation(OpenApiSchemaReferenceInformation refer
7272
/// <summary>
7373
/// Serialize <see cref="OpenApiSchemaReferenceInformation"/> to Open Api v3.1.
7474
/// </summary>
75-
public new void SerializeAsV31(IOpenApiWriter writer)
75+
public override void SerializeAsV31(IOpenApiWriter writer)
7676
{
7777
Utils.CheckArgumentNull(writer);
7878

@@ -118,7 +118,7 @@ public OpenApiSchemaReferenceInformation(OpenApiSchemaReferenceInformation refer
118118
/// <summary>
119119
/// Sets metadata fields from a JSON node during parsing
120120
/// </summary>
121-
internal new void SetMetadataFromMapNode(MapNode mapNode)
121+
internal override void SetMetadataFromMapNode(MapNode mapNode)
122122
{
123123
base.SetMetadataFromMapNode(mapNode);
124124

@@ -131,28 +131,19 @@ public OpenApiSchemaReferenceInformation(OpenApiSchemaReferenceInformation refer
131131
}
132132

133133
// Boolean properties
134-
if (jsonObject.TryGetPropertyValue(OpenApiConstants.Deprecated, out var deprecatedNode) && deprecatedNode is JsonValue deprecatedValue)
134+
if (jsonObject.TryGetPropertyValue(OpenApiConstants.Deprecated, out var deprecatedNode) && deprecatedNode is JsonValue deprecatedValue && deprecatedValue.TryGetValue<bool>(out var deprecated))
135135
{
136-
if (deprecatedValue.TryGetValue<bool>(out var deprecated))
137-
{
138-
Deprecated = deprecated;
139-
}
136+
Deprecated = deprecated;
140137
}
141138

142-
if (jsonObject.TryGetPropertyValue(OpenApiConstants.ReadOnly, out var readOnlyNode) && readOnlyNode is JsonValue readOnlyValue)
139+
if (jsonObject.TryGetPropertyValue(OpenApiConstants.ReadOnly, out var readOnlyNode) && readOnlyNode is JsonValue readOnlyValue && readOnlyValue.TryGetValue<bool>(out var readOnly))
143140
{
144-
if (readOnlyValue.TryGetValue<bool>(out var readOnly))
145-
{
146-
ReadOnly = readOnly;
147-
}
141+
ReadOnly = readOnly;
148142
}
149143

150-
if (jsonObject.TryGetPropertyValue(OpenApiConstants.WriteOnly, out var writeOnlyNode) && writeOnlyNode is JsonValue writeOnlyValue)
144+
if (jsonObject.TryGetPropertyValue(OpenApiConstants.WriteOnly, out var writeOnlyNode) && writeOnlyNode is JsonValue writeOnlyValue && writeOnlyValue.TryGetValue<bool>(out var writeOnly))
151145
{
152-
if (writeOnlyValue.TryGetValue<bool>(out var writeOnly))
153-
{
154-
WriteOnly = writeOnly;
155-
}
146+
WriteOnly = writeOnly;
156147
}
157148

158149
// Default value
@@ -178,4 +169,4 @@ public OpenApiSchemaReferenceInformation(OpenApiSchemaReferenceInformation refer
178169
private static string? GetPropertyValueFromNode(JsonObject jsonObject, string key) =>
179170
jsonObject.TryGetPropertyValue(key, out var valueNode) && valueNode is JsonValue valueCast && valueCast.TryGetValue<string>(out var strValue) ? strValue : null;
180171
}
181-
}
172+
}

0 commit comments

Comments
 (0)