diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 2d80e6d7c..364fc09e4 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -20,7 +20,7 @@ steps:
displayName: 'Install .NET Core SDK'
inputs:
packageType: 'sdk'
- version: '2.2.203'
+ version: '5.0.102'
# Patch preview project versions (only when on master branch)
- task: CmdLine@2
diff --git a/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj b/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj
index b2ccfc4d1..ce26c502b 100644
--- a/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj
+++ b/src/NJsonSchema.Benchmark/NJsonSchema.Benchmark.csproj
@@ -1,6 +1,6 @@
- netcoreapp2.0
+ netcoreapp5.0
diff --git a/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj b/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj
index 98153f1db..36fd4994c 100644
--- a/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj
+++ b/src/NJsonSchema.CodeGeneration.CSharp.Tests/NJsonSchema.CodeGeneration.CSharp.Tests.csproj
@@ -1,6 +1,6 @@
- netcoreapp2.0;net461
+ netcoreapp5.0;net452
false
true
1998,1591
@@ -33,10 +33,13 @@
-
+
+
+
+
-
-
+
+
diff --git a/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj b/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj
index 2d762a185..0ffa1e2d1 100644
--- a/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj
+++ b/src/NJsonSchema.CodeGeneration.CSharp/NJsonSchema.CodeGeneration.CSharp.csproj
@@ -5,12 +5,12 @@
10.3.3
json schema validation generator .net
Copyright © Rico Suter, 2020
- https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md
http://NJsonSchema.org
True
../NJsonSchema.snk
Rico Suter
- https://raw.githubusercontent.com/RSuter/NJsonSchema/master/assets/NuGetIcon.png
+ NuGetIcon.png
+ MIT
True
@@ -95,4 +95,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/NJsonSchema.CodeGeneration.CSharp/NuGetIcon.png b/src/NJsonSchema.CodeGeneration.CSharp/NuGetIcon.png
new file mode 100644
index 000000000..bd2ae5416
Binary files /dev/null and b/src/NJsonSchema.CodeGeneration.CSharp/NuGetIcon.png differ
diff --git a/src/NJsonSchema.CodeGeneration.Tests/InheritanceSerializationTests.cs b/src/NJsonSchema.CodeGeneration.Tests/InheritanceSerializationTests.cs
index e300829d8..697391f90 100644
--- a/src/NJsonSchema.CodeGeneration.Tests/InheritanceSerializationTests.cs
+++ b/src/NJsonSchema.CodeGeneration.Tests/InheritanceSerializationTests.cs
@@ -11,7 +11,6 @@
using NJsonSchema.CodeGeneration.TypeScript;
using NJsonSchema.Converters;
using Xunit;
-
using System.IO;
using System.Reflection;
using System.CodeDom.Compiler;
@@ -310,10 +309,9 @@ public async Task Subtypes_are_serialized_with_correct_discriminator()
private Assembly Compile(string code)
{
-
CSharpCompilation compilation = CSharpCompilation.Create("assemblyName")
- .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
- .AddSyntaxTrees(CSharpSyntaxTree.ParseText(code));
+ .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
+ .AddSyntaxTrees(CSharpSyntaxTree.ParseText(code));
#if NET452
compilation = compilation.AddReferences(
@@ -321,9 +319,7 @@ private Assembly Compile(string code)
MetadataReference.CreateFromFile(typeof(JsonConvert).Assembly.Location),
MetadataReference.CreateFromFile(typeof(GeneratedCodeAttribute).Assembly.Location),
MetadataReference.CreateFromFile(typeof(System.Linq.Expressions.Expression).Assembly.Location));
-#endif
-
-#if NETCOREAPP2_0
+#else
var coreDir = Directory.GetParent(typeof(Enumerable).GetTypeInfo().Assembly.Location);
compilation = compilation.AddReferences(
MetadataReference.CreateFromFile(typeof(object).Assembly.Location),
diff --git a/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj b/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj
index 23a5f123f..e6ef4a9b6 100644
--- a/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj
+++ b/src/NJsonSchema.CodeGeneration.Tests/NJsonSchema.CodeGeneration.Tests.csproj
@@ -1,6 +1,6 @@
- netcoreapp2.0;net452
+ netcoreapp5.0;net452
True
../NJsonSchema.snk
false
@@ -10,12 +10,12 @@
-
+
-
+
diff --git a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj
index bbf36e39e..b5ea58f31 100644
--- a/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj
+++ b/src/NJsonSchema.CodeGeneration.TypeScript.Tests/NJsonSchema.CodeGeneration.TypeScript.Tests.csproj
@@ -1,6 +1,6 @@
- netcoreapp2.0;net452
+ netcoreapp5.0;net452
false
true
1998,1591
diff --git a/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj b/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj
index 06d707c59..0ea6f98e6 100644
--- a/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj
+++ b/src/NJsonSchema.CodeGeneration.TypeScript/NJsonSchema.CodeGeneration.TypeScript.csproj
@@ -5,13 +5,13 @@
10.3.3
json schema validation generator .net
Copyright © Rico Suter, 2020
- https://github.com/RicoSuter/NJsonSchema/blob/master/LICENSE.md
http://NJsonSchema.org
True
../NJsonSchema.snk
Rico Suter
- https://raw.githubusercontent.com/RSuter/NJsonSchema/master/assets/NuGetIcon.png
+ NuGetIcon.png
+ MIT
True
true
@@ -43,4 +43,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/NJsonSchema.CodeGeneration.TypeScript/NuGetIcon.png b/src/NJsonSchema.CodeGeneration.TypeScript/NuGetIcon.png
new file mode 100644
index 000000000..bd2ae5416
Binary files /dev/null and b/src/NJsonSchema.CodeGeneration.TypeScript/NuGetIcon.png differ
diff --git a/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj b/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj
index 703e17552..f4254cf20 100644
--- a/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj
+++ b/src/NJsonSchema.CodeGeneration/NJsonSchema.CodeGeneration.csproj
@@ -5,12 +5,12 @@
10.3.3
json schema validation generator .net
Copyright © Rico Suter, 2020
- https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md
http://NJsonSchema.org
True
../NJsonSchema.snk
Rico Suter
- https://raw.githubusercontent.com/RSuter/NJsonSchema/master/assets/NuGetIcon.png
+ NuGetIcon.png
+ MIT
True
@@ -33,4 +33,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/NJsonSchema.CodeGeneration/NuGetIcon.png b/src/NJsonSchema.CodeGeneration/NuGetIcon.png
new file mode 100644
index 000000000..bd2ae5416
Binary files /dev/null and b/src/NJsonSchema.CodeGeneration/NuGetIcon.png differ
diff --git a/src/NJsonSchema.Demo.Performance/NJsonSchema.Demo.Performance.csproj b/src/NJsonSchema.Demo.Performance/NJsonSchema.Demo.Performance.csproj
index 9736fd9bf..becc9f21f 100644
--- a/src/NJsonSchema.Demo.Performance/NJsonSchema.Demo.Performance.csproj
+++ b/src/NJsonSchema.Demo.Performance/NJsonSchema.Demo.Performance.csproj
@@ -2,7 +2,7 @@
Exe
- netcoreapp2.0
+ netcoreapp5.0
diff --git a/src/NJsonSchema.Demo/NJsonSchema.Demo.csproj b/src/NJsonSchema.Demo/NJsonSchema.Demo.csproj
index cae83be42..277de7636 100644
--- a/src/NJsonSchema.Demo/NJsonSchema.Demo.csproj
+++ b/src/NJsonSchema.Demo/NJsonSchema.Demo.csproj
@@ -1,6 +1,6 @@
- netcoreapp2.0
+ netcoreapp5.0
false
true
diff --git a/src/NJsonSchema.Tests/Generation/ArrayGenerationTests.cs b/src/NJsonSchema.Tests/Generation/ArrayGenerationTests.cs
index 30e0ef921..32cd856a6 100644
--- a/src/NJsonSchema.Tests/Generation/ArrayGenerationTests.cs
+++ b/src/NJsonSchema.Tests/Generation/ArrayGenerationTests.cs
@@ -29,6 +29,34 @@ public async Task When_property_is_JArray_then_schema_with_any_array_is_generate
Assert.True(arrayProperty.Item.ActualTypeSchema.IsAnyType);
}
+#nullable enable
+ public class ClassWithArrayOfNullable
+ {
+ public string?[] Array { get; set; } = new string?[0];
+
+ public List List { get; set; } = new List();
+ }
+#nullable restore
+
+ [Fact]
+ public async Task When_property_is_Array_of_nullable_then_schema_with_array_of_nullable_is_generated()
+ {
+ //// Act
+ var schema = JsonSchema.FromType(new JsonSchemaGeneratorSettings { SchemaType = SchemaType.OpenApi3 });
+ var json = schema.ToJson();
+
+ //// Assert
+ Assert.Equal(2, schema.ActualProperties.Count);
+
+ var arrayProperty = schema.ActualProperties["Array"].ActualTypeSchema;
+ Assert.Equal(JsonObjectType.Array, arrayProperty.Type);
+ Assert.True(arrayProperty.Item.IsNullableRaw);
+
+ var listProperty = schema.ActualProperties["List"].ActualTypeSchema;
+ Assert.Equal(JsonObjectType.Array, listProperty.Type);
+ Assert.True(listProperty.Item.IsNullableRaw);
+ }
+
public class ListContainer
{
public SomeModelCollectionResponse Response { get; set; }
diff --git a/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj b/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj
index 4d03e308e..651d79bdd 100644
--- a/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj
+++ b/src/NJsonSchema.Tests/NJsonSchema.Tests.csproj
@@ -1,9 +1,10 @@
- netcoreapp2.0;net46;net452
+ netcoreapp5.0;net46;net452
false
+ 8
diff --git a/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj b/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj
index e4867a4da..47145a6ab 100644
--- a/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj
+++ b/src/NJsonSchema.Yaml.Tests/NJsonSchema.Yaml.Tests.csproj
@@ -1,6 +1,6 @@
- netcoreapp2.0;net46;net452
+ netcoreapp5.0;net46;net452
false
diff --git a/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj b/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj
index 9a398640a..a2f3f8917 100644
--- a/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj
+++ b/src/NJsonSchema.Yaml/NJsonSchema.Yaml.csproj
@@ -5,12 +5,12 @@
10.3.3
json schema validation generator .net
Copyright © Rico Suter, 2020
- https://github.com/rsuter/NJsonSchema/blob/master/LICENSE.md
http://NJsonSchema.org
True
../NJsonSchema.snk
Rico Suter
- https://raw.githubusercontent.com/RSuter/NJsonSchema/master/assets/NuGetIcon.png
+ NuGetIcon.png
+ MIT
True
@@ -21,4 +21,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/NJsonSchema.Yaml/NuGetIcon.png b/src/NJsonSchema.Yaml/NuGetIcon.png
new file mode 100644
index 000000000..bd2ae5416
Binary files /dev/null and b/src/NJsonSchema.Yaml/NuGetIcon.png differ
diff --git a/src/NJsonSchema/Generation/JsonSchemaGenerator.cs b/src/NJsonSchema/Generation/JsonSchemaGenerator.cs
index 45fb0b65b..0d1c7fb40 100644
--- a/src/NJsonSchema/Generation/JsonSchemaGenerator.cs
+++ b/src/NJsonSchema/Generation/JsonSchemaGenerator.cs
@@ -577,19 +577,18 @@ protected virtual void GenerateArray(
typeDescription.ApplyType(schema);
var jsonSchemaAttribute = contextualType.GetTypeAttribute();
- var itemType = jsonSchemaAttribute?.ArrayItem ?? contextualType.OriginalType.GetEnumerableItemType();
+ var itemType = jsonSchemaAttribute?.ArrayItem.ToContextualType() ?? contextualType.EnumerableItemType;
if (itemType != null)
{
- var contextualItemType = itemType.ToContextualType();
var itemIsNullable = contextualType.GetContextAttribute() != null ||
- contextualItemType.Nullability == Nullability.Nullable;
+ itemType.Nullability == Nullability.Nullable;
schema.Item = GenerateWithReferenceAndNullability(
- contextualItemType, itemIsNullable, schemaResolver, (itemSchema, typeSchema) =>
+ itemType, itemIsNullable, schemaResolver, (itemSchema, typeSchema) =>
{
if (Settings.GenerateXmlObjects)
{
- itemSchema.GenerateXmlObjectForItemType(contextualItemType);
+ itemSchema.GenerateXmlObjectForItemType(itemType);
}
});
@@ -904,7 +903,7 @@ private void GenerateProperties(Type type, JsonSchema schema, JsonSchemaResolver
}
else
{
- // TODO: Remove this hacky code (used to support serialization of exceptions and restore the old behavior [pre 9.x])
+ // TODO: Remove this hacky code (used to support serialization of exceptions and restore the old behavior [pre 9.x])
foreach (var memberInfo in contextualMembers.Where(m => allowedProperties == null || allowedProperties.Contains(m.Name)))
{
var attribute = memberInfo.GetContextAttribute();
diff --git a/src/NJsonSchema/NJsonSchema.csproj b/src/NJsonSchema/NJsonSchema.csproj
index 3ac5ecda0..fb0813fd3 100644
--- a/src/NJsonSchema/NJsonSchema.csproj
+++ b/src/NJsonSchema/NJsonSchema.csproj
@@ -5,12 +5,12 @@
10.3.3
json schema validation generator .net
Copyright © Rico Suter, 2020
- https://github.com/RicoSuter/NJsonSchema/blob/master/LICENSE.md
http://NJsonSchema.org
True
../NJsonSchema.snk
Rico Suter
- https://raw.githubusercontent.com/RSuter/NJsonSchema/master/assets/NuGetIcon.png
+ NuGetIcon.png
+ MIT
True
@@ -28,7 +28,7 @@
-
+
@@ -44,4 +44,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/NJsonSchema/NuGetIcon.png b/src/NJsonSchema/NuGetIcon.png
new file mode 100644
index 000000000..bd2ae5416
Binary files /dev/null and b/src/NJsonSchema/NuGetIcon.png differ