diff --git a/Dan.Common/Dan.Common.csproj b/Dan.Common/Dan.Common.csproj index c60d98f..f628e7c 100644 --- a/Dan.Common/Dan.Common.csproj +++ b/Dan.Common/Dan.Common.csproj @@ -40,6 +40,8 @@ + + diff --git a/Dan.Common/Models/EvidenceValue.cs b/Dan.Common/Models/EvidenceValue.cs index a22843a..499635a 100644 --- a/Dan.Common/Models/EvidenceValue.cs +++ b/Dan.Common/Models/EvidenceValue.cs @@ -1,3 +1,5 @@ +using NJsonSchema.NewtonsoftJson.Generation; + namespace Dan.Common.Models; /// @@ -68,4 +70,14 @@ public object Clone() { return MemberwiseClone(); } + + // Default implementation of getting a json schema valid for JsonSchemaDefinition property + // Opted to not made a forced built in property to make it easier to custom set the property if needed + /// + /// Get JsonSchema + /// + public static string SchemaFromObject(Formatting formatting = Formatting.None) + { + return NewtonsoftJsonSchemaGenerator.FromType().ToJson(formatting); + } } \ No newline at end of file diff --git a/Dan.PluginTest/Dan.PluginTest.csproj b/Dan.PluginTest/Dan.PluginTest.csproj index e4094f4..ef931f0 100644 --- a/Dan.PluginTest/Dan.PluginTest.csproj +++ b/Dan.PluginTest/Dan.PluginTest.csproj @@ -10,7 +10,6 @@ - diff --git a/Dan.PluginTest/Metadata.cs b/Dan.PluginTest/Metadata.cs index 44ed965..d1b918f 100644 --- a/Dan.PluginTest/Metadata.cs +++ b/Dan.PluginTest/Metadata.cs @@ -7,7 +7,7 @@ using Dan.PluginTest.Models; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; -using NJsonSchema; +using Newtonsoft.Json; namespace Dan.PluginTest; @@ -47,9 +47,7 @@ public List GetEvidenceCodes() { EvidenceValueName = "default", ValueType = EvidenceValueType.JsonSchema, - JsonSchemaDefintion = JsonSchema - .FromType() - .ToJson(Newtonsoft.Json.Formatting.Indented) + JsonSchemaDefintion = EvidenceValue.SchemaFromObject() } ] }, @@ -64,9 +62,7 @@ public List GetEvidenceCodes() { EvidenceValueName = "default", ValueType = EvidenceValueType.JsonSchema, - JsonSchemaDefintion = JsonSchema - .FromType() - .ToJson(Newtonsoft.Json.Formatting.Indented) + JsonSchemaDefintion = EvidenceValue.SchemaFromObject(Formatting.Indented) } ] },