Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace NJsonSchema.CodeGeneration.TypeScript
public sealed class TypeScriptPropertyNameGenerator : IPropertyNameGenerator
{
private static readonly char[] _reservedFirstPassChars = ['"', '@', '?', '.', '=', '+'];
private static readonly char[] _reservedSecondPassChars = ['*', ':', '-'];
private static readonly char[] _reservedSecondPassChars = ['*', '#', ':', '-'];

/// <summary>Gets or sets the reserved names.</summary>
public HashSet<string> ReservedPropertyNames { get; set; } = new(StringComparer.Ordinal) { "constructor", "init", "fromJS", "toJSON" };
Expand All @@ -37,6 +37,7 @@ public string Generate(JsonSchemaProperty property)
if (name.IndexOfAny(_reservedSecondPassChars) != -1)
{
name = name.Replace("*", "Star")
.Replace("#", "_")
.Replace(":", "_")
.Replace("-", "_");
}
Expand All @@ -49,4 +50,4 @@ public string Generate(JsonSchemaProperty property)
return name;
}
}
}
}
Loading