Skip to content

Commit

Permalink
feat: Improve EnsureFormatForDocumentationTag and fix seneario-test v…
Browse files Browse the repository at this point in the history
…erify files
  • Loading branch information
davidkallesen committed Jul 1, 2024
1 parent a26a951 commit 034cbbb
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 21 deletions.
15 changes: 11 additions & 4 deletions src/Atc.Rest.ApiGenerator.OpenApi/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Numerics;

namespace Atc.Rest.ApiGenerator.OpenApi.Extensions;

public static class StringExtensions
Expand Down Expand Up @@ -42,13 +40,17 @@ public static string EnsureFormatForDocumentationTag(
value = value[..^1];
}

if (value.Contains("\n", StringComparison.Ordinal))
if (value.Contains('\n', StringComparison.Ordinal))
{
var lines = value.ToLines();
var sb = new StringBuilder();
foreach (var line in lines)
{
sb.AppendLine(line.Trim());
var trimmedLine = line.Trim();
if (trimmedLine.Length > 0)
{
sb.AppendLine(trimmedLine);
}
}

value = sb.ToString();
Expand All @@ -58,6 +60,11 @@ public static string EnsureFormatForDocumentationTag(
value = value.Trim();
}

if (value.EndsWith(Environment.NewLine, StringComparison.Ordinal))
{
value = value[..^Environment.NewLine.Length];
}

return value.EnsureEndsWithDot();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public class ChargeAuthToken
/// <summary>
/// If the charge auth token is blocked, it will not be able to charge.
/// * `null` = not blocked
/// * date-time = blocked since date-time
/// .
/// * date-time = blocked since date-time.
/// </summary>
public DateTimeOffset? BlockedAt { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public class CreateChargeAuthToken
/// <summary>
/// If the charge auth token is blocked, it will not be able to charge.
/// * `null` = not blocked
/// * date-time = blocked since date-time
/// .
/// * date-time = blocked since date-time.
/// </summary>
public DateTimeOffset? BlockedAt { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class PatchChargeAuthToken
/// <summary>
/// Indicates until when this charge auth token is active, null means indefinitely.
/// Note: Use `../block` and `../unblock` endpoints to (un)block a charge auth token.
/// .
/// </summary>
public DateTimeOffset? ActiveUntil { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ public class CreateChargePoint
/// Indicates the charge point should be displayed on map.
/// By setting this to false, the charge point will not be shown on the app's map,
/// but will still be fully functional for users of the charge point.
/// .
/// </summary>
public bool? ShowOnMap { get; set; } = true;

/// <summary>
/// Ids of the connectors this charge point support,
/// When not present the provide charge point model connectors will be used instead.
/// .
/// </summary>
public List<long>? ConnectorIds { get; set; } = new List<long>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class PatchChargePoint
/// Indicates the charge point should be displayed on map.
/// By setting this to false, the charge point will not be shown on the app's map,
/// but will still be fully functional for users of the charge point.
/// .
/// </summary>
public bool? ShowOnMap { get; set; } = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class Charge

/// <summary>
/// Id of the price group related to this charge. Note: The underlying price/costGroup models can change and you have
/// to use other fields to get the historic data (costBreakdown, priceBreakdown, price)
/// .
/// to use other fields to get the historic data (costBreakdown, priceBreakdown, price).
/// </summary>
public long PriceGroupId { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class StartChargeRequest
/// <summary>
/// If true, a charge point will be reserved and a charge object with state reserved will be returned.
/// Use `restart` endpoint to start the charge.
/// .
/// </summary>
public bool ReserveCharge { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class ChargesInsightDriverReportDtoConsumption
/// * `team-operator` - Charges that belong to Charge Points of the same operator as paying team operator.
/// * `public` - Any charge that was paid for by this team that does not match the other cases.
/// Note that more chargeTypes might be added in the future. Make sure to handle this gracefully.
/// .
/// </summary>
[Required]
public string ChargeType { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public class GetSitesParameters

/// <summary>
/// lat,long coordinates. If supplied, the Charge Points will be sorted in nearest first order relative
/// to this point. (Format: 55.7096,12.5856)
/// .
/// to this point. (Format: 55.7096,12.5856).
/// </summary>
public string SortByLocation { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ public class CreateSubscription
/// Allows to modify the absolute discount on a subscription if provided.
/// If not provided, the discount of the plan is used.
/// Note: If you want to set it on an existing subscription, you have to cancel the subscription first.
/// .
/// </summary>
public double? DiscountAbsolute { get; set; }

/// <summary>
/// Allows to modify the percentage discount on a subscription if provided.
/// If not provided, the discount of the plan is used.
/// Note: If you want to set it on an existing subscription, you have to cancel the subscription first.
/// .
/// </summary>
public double? DiscountPercentage { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public class WalletTransaction
/// Kind of this transaction, ie 'charge-sponsored'.
/// &lt;br/&gt;
/// **Note:** This is an open field and therefore more kinds will be added moving forward.
/// .
/// </summary>
[Required]
public string Kind { get; set; }
Expand Down

0 comments on commit 034cbbb

Please sign in to comment.