Skip to content

Commit

Permalink
Fixed swagger type trailling coma for linux and windows systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Teimuraz Nikolaishvili committed Jan 22, 2024
1 parent fcff446 commit 44efe3d
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using AltaSoft.DomainPrimitives.Generator.Extensions;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AltaSoft.DomainPrimitives.Generator.Extensions;
using AltaSoft.DomainPrimitives.Generator.Models;
using Microsoft.CodeAnalysis;
using System.Collections.Generic;
using System.Linq;

namespace AltaSoft.DomainPrimitives.Generator.Helpers;

Expand All @@ -11,6 +12,17 @@ namespace AltaSoft.DomainPrimitives.Generator.Helpers;
/// </summary>
internal static class MethodGeneratorHelper
{
/// <summary>
/// Represents the length of a new line character sequence.
/// </summary>
internal static readonly int s_newLineLength = GetNewLineLength();

/// <summary>
/// Retrieves the length of a new line character sequence.
/// </summary>
/// <returns>The length of a new line character sequence.</returns>
private static int GetNewLineLength() => new StringBuilder().AppendLine().Length;

/// <summary>
/// Adds Swagger mappings for specific custom types to ensure proper OpenAPI documentation generation.
/// </summary>
Expand Down Expand Up @@ -111,7 +123,7 @@ void AddMapping(bool isNullable)
}
}

sb.Length -= 3;
sb.Length -= s_newLineLength + 1;
sb.NewLine();
sb.AppendLine("});");
}
Expand Down Expand Up @@ -746,4 +758,4 @@ public static void GenerateIXmlSerializableMethods(GeneratorData data, SourceCod
sb.AppendLine($"public void WriteXml(XmlWriter writer) => writer.WriteString({data.FieldName}.ToString(\"{data.SerializationFormat}\"));");
sb.NewLine();
}
}
}

0 comments on commit 44efe3d

Please sign in to comment.