From c8875cc8dfb4f66e03395ba8df2591d6f0ad3255 Mon Sep 17 00:00:00 2001 From: lorenya Date: Thu, 14 Mar 2024 09:07:11 +0100 Subject: [PATCH] fix(): Remove illegal characters before returning to reserved list --- src/NJsonSchema/DefaultTypeNameGenerator.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NJsonSchema/DefaultTypeNameGenerator.cs b/src/NJsonSchema/DefaultTypeNameGenerator.cs index 417270ead..cd29eae0a 100644 --- a/src/NJsonSchema/DefaultTypeNameGenerator.cs +++ b/src/NJsonSchema/DefaultTypeNameGenerator.cs @@ -62,12 +62,14 @@ public virtual string Generate(JsonSchema schema, string? typeNameHint, IEnumera } var typeName = Generate(schema, typeNameHint); + typeName = RemoveIllegalCharacters(typeName); + if (string.IsNullOrEmpty(typeName) || reservedTypeNames.Contains(typeName)) { typeName = GenerateAnonymousTypeName(typeNameHint, reservedTypeNames); } - return RemoveIllegalCharacters(typeName); + return typeName; } /// Generates the type name for the given schema.