-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rico Suter
committed
Sep 26, 2023
1 parent
e1b561f
commit 83950bb
Showing
4 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/NJsonSchema.NewtonsoftJson.Tests/Generation/StructTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Newtonsoft.Json; | ||
using NJsonSchema.Annotations; | ||
using NJsonSchema.NewtonsoftJson.Generation; | ||
using Xunit; | ||
|
||
namespace NJsonSchema.NewtonsoftJson.Tests.Generation | ||
{ | ||
public class StructTests | ||
{ | ||
[JsonSchema("UserDefinedStruct")] | ||
public struct UserDefinedStruct | ||
{ | ||
} | ||
|
||
public class UserDefinedClass | ||
{ | ||
[JsonProperty] | ||
public readonly UserDefinedStruct NonNullableField; | ||
|
||
[JsonProperty] | ||
public readonly UserDefinedStruct? NullableField; | ||
} | ||
|
||
[Fact] | ||
public void Should_have_a_shared_struct_schema() | ||
{ | ||
//// Arrange | ||
|
||
//// Act | ||
var schema = NewtonsoftJsonSchemaGenerator.FromType<UserDefinedClass>(); | ||
var data = schema.ToJson(); | ||
|
||
//// Assert | ||
Assert.Equal(1, schema.Definitions.Count); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/NJsonSchema.NewtonsoftJson.Tests/NJsonSchema.NewtonsoftJson.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;net462</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<DocumentationFile>bin\Debug\$(TargetFramework)\NJsonSchema.Tests.xml</DocumentationFile> | ||
<NoWarn>$(NoWarn),618,1587,1998,1591</NoWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="References\**\*.json" CopyToOutputDirectory="Always" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> | ||
<PackageReference Include="xunit" Version="2.4.1" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="all" /> | ||
<PackageReference Include="NodaTime" Version="3.1.9" /> | ||
<Reference Condition="'$(TargetFramework)' == 'net462'" Include="System.ComponentModel.DataAnnotations"></Reference> | ||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\NJsonSchema.NewtonsoftJson\NJsonSchema.NewtonsoftJson.csproj" /> | ||
<ProjectReference Include="..\NJsonSchema\NJsonSchema.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters