Skip to content

Commit

Permalink
prefix any property name not starting with valid initial character wi…
Browse files Browse the repository at this point in the history
…th _
  • Loading branch information
Tyler-IN committed May 27, 2024
1 parent d6239c3 commit 0ba43a9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libs/OpenApiGenerator.Core/Models/PropertyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public static PropertyData FromSchema(
.UseWordSeparator('_', '+', '-', '/')
.Replace("[", string.Empty)
.Replace("]", string.Empty);

if (name[0] is not ('_' or >= 'A' and <= 'Z' or >= 'a' and <= 'z'))
{
name = $"_{name}";
}

if (parents.Length != 0)
{
name = name.FixPropertyName(parents.Last().ClassName);
Expand Down

0 comments on commit 0ba43a9

Please sign in to comment.