diff --git a/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs b/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs
index 7479567c3..fdb3adfda 100644
--- a/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs
+++ b/src/NJsonSchema.CodeGeneration.CSharp/CSharpGeneratorSettings.cs
@@ -52,6 +52,8 @@ public CSharpGeneratorSettings()
InlineNamedArrays = false;
InlineNamedDictionaries = false;
InlineNamedTuples = true;
+
+ UseUriTypeForUriFormattedStrings = true;
}
/// Gets or sets the .NET namespace of the generated types (default: MyNamespace).
@@ -147,5 +149,8 @@ public CSharpGeneratorSettings()
/// Generate C# 9.0 record types instead of record-like classes.
public bool GenerateNativeRecords { get; set; }
+
+ /// Indicate if System.Uri should be used for strings with format uri (default: true)
+ public bool UseUriTypeForUriFormattedStrings { get; set; }
}
}
diff --git a/src/NJsonSchema.CodeGeneration.CSharp/CSharpTypeResolver.cs b/src/NJsonSchema.CodeGeneration.CSharp/CSharpTypeResolver.cs
index eced21708..d8755cb6d 100644
--- a/src/NJsonSchema.CodeGeneration.CSharp/CSharpTypeResolver.cs
+++ b/src/NJsonSchema.CodeGeneration.CSharp/CSharpTypeResolver.cs
@@ -182,7 +182,7 @@ private string ResolveString(JsonSchema schema, bool isNullable, string typeName
var nullableReferenceType = Settings.GenerateNullableReferenceTypes && isNullable ? "?" : string.Empty;
- if (schema.Format == JsonFormatStrings.Uri)
+ if (schema.Format == JsonFormatStrings.Uri && Settings.UseUriTypeForUriFormattedStrings)
{
return "System.Uri" + nullableReferenceType;
}