Skip to content

Commit ab55d38

Browse files
committed
Adjust to parse yaml lists
1 parent 9bb389d commit ab55d38

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/Elastic.Documentation.Configuration/Serialization/YamlStaticContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ namespace Elastic.Documentation.Configuration.Serialization;
2424
[YamlSerializable(typeof(ProductDto))]
2525
[YamlSerializable(typeof(LegacyUrlMappingDto))]
2626
[YamlSerializable(typeof(LegacyUrlMappingConfigDto))]
27-
[YamlSerializable(typeof(SynonymsConfigDto))] // Add this line
27+
[YamlSerializable(typeof(SynonymsConfigDto))]
2828
public partial class YamlStaticContext;

src/Elastic.Documentation.Configuration/Synonyms/SynonymsConfiguration.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5+
using System.Collections.Immutable;
6+
57
namespace Elastic.Documentation.Configuration.Synonyms;
68

79
public record SynonymsConfiguration
@@ -11,15 +13,20 @@ public record SynonymsConfiguration
1113

1214
internal sealed record SynonymsConfigDto
1315
{
14-
public List<string> Synonyms { get; set; } = [];
16+
public List<List<string>> Synonyms { get; set; } = [];
1517
}
1618

1719
public static class SynonymsConfigurationExtensions
1820
{
1921
public static SynonymsConfiguration CreateSynonymsConfiguration(this ConfigurationFileProvider provider)
2022
{
2123
var synonymsFile = provider.SynonymsFile;
24+
25+
if (!synonymsFile.Exists)
26+
return new SynonymsConfiguration { Synonyms = [] };
27+
2228
var synonymsDto = ConfigurationFileProvider.Deserializer.Deserialize<SynonymsConfigDto>(synonymsFile.OpenText());
23-
return new SynonymsConfiguration { Synonyms = synonymsDto.Synonyms };
29+
var flattenedSynonyms = synonymsDto.Synonyms.Select(sl => string.Join(',', sl)).ToImmutableArray();
30+
return new SynonymsConfiguration { Synonyms = flattenedSynonyms };
2431
}
2532
}

src/tooling/Elastic.Documentation.Tooling/DocumentationTooling.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static TBuilder AddDocumentationToolingDefaults<TBuilder>(this TBuilder b
7777
var versionsConfiguration = sp.GetRequiredService<VersionsConfiguration>();
7878
var products = sp.GetRequiredService<ProductsConfiguration>();
7979
var legacyUrlMappings = sp.GetRequiredService<LegacyUrlMappingConfiguration>();
80-
var synonyms = sp.GetRequiredService<SynonymsConfiguration>(); // Add this line
80+
var synonyms = sp.GetRequiredService<SynonymsConfiguration>();
8181
return new ConfigurationContext
8282
{
8383
ConfigurationFileProvider = configurationFileProvider,

0 commit comments

Comments
 (0)