diff --git a/src/NJsonSchema.Annotations/JsonFormatStrings.cs b/src/NJsonSchema.Annotations/JsonFormatStrings.cs
index 0531c654b..02cf24d37 100644
--- a/src/NJsonSchema.Annotations/JsonFormatStrings.cs
+++ b/src/NJsonSchema.Annotations/JsonFormatStrings.cs
@@ -8,7 +8,7 @@
using System;
-namespace NJsonSchema.Annotations;
+namespace NJsonSchema;
/// Class containing the constants available as format string.
public static class JsonFormatStrings
diff --git a/src/NJsonSchema.Annotations/JsonObjectType.cs b/src/NJsonSchema.Annotations/JsonObjectType.cs
index 79ea33cc0..c0c4535bd 100644
--- a/src/NJsonSchema.Annotations/JsonObjectType.cs
+++ b/src/NJsonSchema.Annotations/JsonObjectType.cs
@@ -1,6 +1,6 @@
using System;
-namespace NJsonSchema.Annotations;
+namespace NJsonSchema;
///
/// Enumeration of the possible object types.
diff --git a/src/NJsonSchema.Annotations/NJsonSchema.Annotations.csproj b/src/NJsonSchema.Annotations/NJsonSchema.Annotations.csproj
index 3b266d9a0..88a4911ee 100644
--- a/src/NJsonSchema.Annotations/NJsonSchema.Annotations.csproj
+++ b/src/NJsonSchema.Annotations/NJsonSchema.Annotations.csproj
@@ -1,7 +1,7 @@
- netstandard2.0
+ netstandard2.0;net462
diff --git a/src/NJsonSchema.Tests/Generation/AnnotationsGenerationTests.cs b/src/NJsonSchema.Tests/Generation/AnnotationsGenerationTests.cs
index 50a228d7d..33012ea4d 100644
--- a/src/NJsonSchema.Tests/Generation/AnnotationsGenerationTests.cs
+++ b/src/NJsonSchema.Tests/Generation/AnnotationsGenerationTests.cs
@@ -15,10 +15,10 @@ public class AnnotationClass
{
public MyPoint Point { get; set; }
- [JsonSchema(Annotations.JsonObjectType.String, Format = "point")]
+ [JsonSchema(JsonObjectType.String, Format = "point")]
public AnnotationClass ClassAsString { get; set; }
- [JsonSchema(Annotations.JsonObjectType.String, Format = "point")]
+ [JsonSchema(JsonObjectType.String, Format = "point")]
public class MyPoint
{
public decimal X { get; set; }
@@ -145,7 +145,7 @@ public async Task When_multipleOf_is_fraction_then_it_is_validated_correctly()
Assert.Equal(0, errors.Count);
}
- [JsonSchema(Annotations.JsonObjectType.Array, ArrayItem = typeof(string))]
+ [JsonSchema(JsonObjectType.Array, ArrayItem = typeof(string))]
public class ArrayModel : IEnumerable
{
public IEnumerator GetEnumerator()
@@ -172,7 +172,7 @@ public async Task When_class_has_array_item_type_defined_then_schema_has_this_it
Assert.Equal(JsonObjectType.String, schema.Item.Type);
}
- [JsonSchema(Annotations.JsonObjectType.Array, ArrayItem = typeof(string))]
+ [JsonSchema(JsonObjectType.Array, ArrayItem = typeof(string))]
public class ArrayModel : List
{
}
@@ -197,7 +197,7 @@ public class MyStructContainer
public MyStruct? NullableStruct { get; set; }
}
- [JsonSchema(Annotations.JsonObjectType.String)]
+ [JsonSchema(JsonObjectType.String)]
public struct MyStruct
{
}
diff --git a/src/NJsonSchema.sln b/src/NJsonSchema.sln
index d1e1d59f0..ed5db6d13 100644
--- a/src/NJsonSchema.sln
+++ b/src/NJsonSchema.sln
@@ -32,8 +32,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "00 Build", "00 Build", "{863B2D88-A0BD-4466-8583-AAD0B8D3F182}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
- ..\README.md = ..\README.md
Directory.Packages.props = Directory.Packages.props
+ ..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "..\build\_build.csproj", "{8E4E5A64-B5B7-4718-A92F-CB6B08512264}"
@@ -244,6 +244,22 @@ Global
{990EF464-C967-4E08-8C3D-0568A47B6D2A}.Release|x64.Build.0 = Release|Any CPU
{990EF464-C967-4E08-8C3D-0568A47B6D2A}.Release|x86.ActiveCfg = Release|Any CPU
{990EF464-C967-4E08-8C3D-0568A47B6D2A}.Release|x86.Build.0 = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|ARM.Build.0 = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|x64.Build.0 = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Debug|x86.Build.0 = Debug|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|ARM.ActiveCfg = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|ARM.Build.0 = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|x64.ActiveCfg = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|x64.Build.0 = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|x86.ActiveCfg = Release|Any CPU
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264}.Release|x86.Build.0 = Release|Any CPU
{A9C2A9CD-44F6-4A21-9D72-00CF5BE0A36F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9C2A9CD-44F6-4A21-9D72-00CF5BE0A36F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9C2A9CD-44F6-4A21-9D72-00CF5BE0A36F}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -297,20 +313,20 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {8E4E5A64-B5B7-4718-A92F-CB6B08512264} = {863B2D88-A0BD-4466-8583-AAD0B8D3F182}
{7B7A2E32-E808-4A19-98B1-37E766580F8C} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
- {E59CE32B-181F-4AAE-BF62-772AEEFC3177} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
- {A9C2A9CD-44F6-4A21-9D72-00CF5BE0A36F} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
- {AFA1E1E7-37F9-4958-B0E3-ADB12F53E563} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
- {9EAB6FAB-10AC-4AB2-BA5B-103CE6A17E88} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
- {990EF464-C967-4E08-8C3D-0568A47B6D2A} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
+ {4F0A74F2-54BE-4747-8EDB-562ABB6E0B64} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
{8A463FA0-DAAF-483C-813E-AE9C6153CBF7} = {62F296F1-8CE9-493C-9022-35F4C687460B}
{546CF985-2029-4CBB-8F7D-303C037EB293} = {62F296F1-8CE9-493C-9022-35F4C687460B}
+ {3D8BA0A7-65AF-4328-82DC-8C131D9A9EA8} = {62F296F1-8CE9-493C-9022-35F4C687460B}
{0873FE5E-4A46-48B5-A171-AC629EC7C263} = {62F296F1-8CE9-493C-9022-35F4C687460B}
{974ED050-4A34-4513-8048-139B1AF1A95D} = {62F296F1-8CE9-493C-9022-35F4C687460B}
- {3D8BA0A7-65AF-4328-82DC-8C131D9A9EA8} = {62F296F1-8CE9-493C-9022-35F4C687460B}
{E767A007-6007-4898-B80A-FE4ACBF2C588} = {62F296F1-8CE9-493C-9022-35F4C687460B}
- {4F0A74F2-54BE-4747-8EDB-562ABB6E0B64} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
+ {9EAB6FAB-10AC-4AB2-BA5B-103CE6A17E88} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
+ {E59CE32B-181F-4AAE-BF62-772AEEFC3177} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
+ {990EF464-C967-4E08-8C3D-0568A47B6D2A} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
+ {8E4E5A64-B5B7-4718-A92F-CB6B08512264} = {863B2D88-A0BD-4466-8583-AAD0B8D3F182}
+ {A9C2A9CD-44F6-4A21-9D72-00CF5BE0A36F} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
+ {AFA1E1E7-37F9-4958-B0E3-ADB12F53E563} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
{526020E1-D3B5-49F6-BE11-5F4402A02E92} = {CDBC7AC4-9D3D-430D-86BF-CDAECBDD715A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
diff --git a/src/NJsonSchema/Generation/ReflectionServiceBase.cs b/src/NJsonSchema/Generation/ReflectionServiceBase.cs
index d7ff0c000..7800c1707 100644
--- a/src/NJsonSchema/Generation/ReflectionServiceBase.cs
+++ b/src/NJsonSchema/Generation/ReflectionServiceBase.cs
@@ -53,12 +53,7 @@ public JsonTypeDescription GetDescription(ContextualType contextualType, Referen
var jsonSchemaAttribute = contextualType.GetContextOrTypeAttribute(true); ;
if (jsonSchemaAttribute != null)
{
- var classType = ToJsonObjectType(jsonSchemaAttribute.Type);
- if (classType == JsonObjectType.None)
- {
- classType = JsonObjectType.Object;
- }
-
+ var classType = jsonSchemaAttribute.Type != JsonObjectType.None ? jsonSchemaAttribute.Type : JsonObjectType.Object;
var format = !string.IsNullOrEmpty(jsonSchemaAttribute.Format) ? jsonSchemaAttribute.Format : null;
return JsonTypeDescription.Create(contextualType, classType, isNullable, format);
}
@@ -66,13 +61,6 @@ public JsonTypeDescription GetDescription(ContextualType contextualType, Referen
return GetDescription(contextualType, settings, type, isNullable, defaultReferenceTypeNullHandling);
}
- ///
- /// Convert into
- ///
- ///
- ///
- protected JsonObjectType ToJsonObjectType(Annotations.JsonObjectType jsonObjectType) => (JsonObjectType) jsonObjectType;
-
/// Creates a from a .
/// The type.
/// The settings.
diff --git a/src/NJsonSchema/JsonObjectType.cs b/src/NJsonSchema/JsonObjectType.cs
deleted file mode 100644
index 17dc0cc4e..000000000
--- a/src/NJsonSchema/JsonObjectType.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (c) Rico Suter. All rights reserved.
-//
-// https://github.com/RicoSuter/NJsonSchema/blob/master/LICENSE.md
-// Rico Suter, mail@rsuter.com
-//-----------------------------------------------------------------------
-
-using System;
-using Newtonsoft.Json;
-
-namespace NJsonSchema
-{
- ///
- /// Enumeration of the possible object types.
- ///
- /// Keep in sync with
- ///
- [Flags]
- public enum JsonObjectType
- {
- /// No object type.
- [JsonProperty("none")]
- None = 0,
-
- /// An array.
- [JsonProperty("array")]
- Array = 1,
-
- /// A boolean value.
- [JsonProperty("boolean")]
- Boolean = 2,
-
- /// An integer value.
- [JsonProperty("integer")]
- Integer = 4,
-
- /// A null.
- [JsonProperty("null")]
- Null = 8,
-
- /// An number value.
- [JsonProperty("number")]
- Number = 16,
-
- /// An object.
- [JsonProperty("object")]
- Object = 32,
-
- /// A string.
- [JsonProperty("string")]
- String = 64,
-
- /// A file (used in Swagger specifications).
- [JsonProperty("file")]
- File = 128,
- }
-}
\ No newline at end of file