Skip to content

Commit e65e32b

Browse files
committed
- code review feedback implementation
Signed-off-by: Vincent Biret <[email protected]>
1 parent e13db15 commit e65e32b

File tree

4 files changed

+35
-37
lines changed

4 files changed

+35
-37
lines changed

src/Microsoft.OpenApi.OData.Reader/Common/StringExtensions.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/Microsoft.OpenApi.OData.Reader/Common/Utils.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System;
77
using System.Collections.Generic;
8+
using System.Linq;
89
using Microsoft.OpenApi.OData.Vocabulary;
910

1011
namespace Microsoft.OpenApi.OData.Common
@@ -106,5 +107,13 @@ internal static string CheckArgumentNullOrEmpty(string value, string parameterNa
106107

107108
return value;
108109
}
110+
111+
/// <summary>
112+
/// Lowers the first character of the string.
113+
/// </summary>
114+
/// <param name="input">The input string.</param>
115+
/// <returns>The changed string.</returns>
116+
internal static string ToFirstCharacterLowerCase(this string input)
117+
=> string.IsNullOrEmpty(input) ? input : $"{char.ToLowerInvariant(input.FirstOrDefault())}{input.Substring(1)}";
109118
}
110119
}

src/Microsoft.OpenApi.OData.Reader/OpenApiExtensions/OpenApiEnumValuesDescriptionExtension.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ internal class OpenApiEnumValuesDescriptionExtension : IOpenApiExtension
2222
/// Name of the extension as used in the description.
2323
/// </summary>
2424
public string Name => "x-ms-enum";
25+
2526
/// <summary>
2627
/// The of the enum.
2728
/// </summary>
2829
public string EnumName { get; set; }
30+
2931
/// <summary>
3032
/// Descriptions for the enum symbols, where the value MUST match the enum symbols in the main description
3133
/// </summary>
3234
public List<EnumDescription> ValuesDescriptions { get; set; } = new();
35+
3336
/// <inheritdoc />
3437
public void Write(IOpenApiWriter writer, OpenApiSpecVersion specVersion)
3538
{

test/Microsoft.OpenAPI.OData.Reader.Tests/OpenApiExtensions/OpenApiEnumValuesDescriptionExtensionTexts.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.OData.OpenApiExtensions.Tests;
1212

1313
public class OpenApiEnumValuesDescriptionExtensionTexts
1414
{
15-
[Fact]
15+
[Fact]
1616
public void ExtensionNameMatchesExpected()
1717
{
1818
// Arrange
@@ -26,7 +26,7 @@ public void ExtensionNameMatchesExpected()
2626
Assert.Equal(expectedName, name);
2727
}
2828

29-
[Fact]
29+
[Fact]
3030
public void WritesNothingWhenNoValues()
3131
{
3232
// Arrange
@@ -40,23 +40,23 @@ public void WritesNothingWhenNoValues()
4040

4141
// Assert
4242
Assert.Null(extension.EnumName);
43-
Assert.Empty(extension.ValuesDescriptions);
43+
Assert.Empty(extension.ValuesDescriptions);
4444
Assert.Empty(result);
4545
}
46-
[Fact]
47-
public void WritesEnumDescription()
48-
{
49-
// Arrange
46+
[Fact]
47+
public void WritesEnumDescription()
48+
{
49+
// Arrange
5050
OpenApiEnumValuesDescriptionExtension extension = new();
51-
extension.EnumName = "TestEnum";
52-
extension.ValuesDescriptions = new()
53-
{
54-
new() {
55-
Description = "TestDescription",
56-
Value = "TestValue",
57-
Name = "TestName"
58-
}
59-
};
51+
extension.EnumName = "TestEnum";
52+
extension.ValuesDescriptions = new()
53+
{
54+
new() {
55+
Description = "TestDescription",
56+
Value = "TestValue",
57+
Name = "TestName"
58+
}
59+
};
6060
using TextWriter sWriter = new StringWriter();
6161
OpenApiJsonWriter writer = new(sWriter);
6262

@@ -65,11 +65,11 @@ public void WritesEnumDescription()
6565
string result = sWriter.ToString();
6666

6767
// Assert
68-
Assert.Contains("values", result);
69-
Assert.Contains("modelAsString\": false", result);
70-
Assert.Contains("name\": \"TestEnum", result);
71-
Assert.Contains("description\": \"TestDescription", result);
72-
Assert.Contains("value\": \"TestValue", result);
73-
Assert.Contains("name\": \"TestName", result);
74-
}
68+
Assert.Contains("values", result);
69+
Assert.Contains("modelAsString\": false", result);
70+
Assert.Contains("name\": \"TestEnum", result);
71+
Assert.Contains("description\": \"TestDescription", result);
72+
Assert.Contains("value\": \"TestValue", result);
73+
Assert.Contains("name\": \"TestName", result);
74+
}
7575
}

0 commit comments

Comments
 (0)