-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Json Schema Validation for publishednodes.json file (#1305)
* Added Json schema validation of publishednodes.json, with backward compatibility and jobs deserialization bug fix. * Updated with latest json schema version and removed any additional properties added previously in tests to conform to previous schema versions. * Initial implementation of json-everything as replacement for Newtonsoft Json Schema (#2). Replace Newtonsoft Schema validation with JsonSchemaDotNet. * Remove lingering references to Newtonsoft.Json.Schema library. * Remove duplicate schema file and convert to linked asset with copy always for tests. * Delete modules/src/Microsoft.Azure.IIoT.Modules.OpcUa.Publisher/src/schemas directory. GitHub seems to think this folder still exists though it is not in the repository anymore. Removing in an attempt to clean up the PR. * Revert version change to sln file, address LGTM automated review feedback. * Removed trailing whitespaces from solution by temporarily using SA1028 rule locally + added missing copyright notice. * Second Item Array Failure Schema Fix. * Add schema spec documentation. * Update schema with additional comments from code review. * Add endpoint url regex design notes to design doc. * Addressed PR review comments. * Correct typos across docs, schema and tests. * Update command line doc to include post 2.8.0 additional args. * Update Publisher* to Published* in Legacy CLI files. * Changed casing from this -> This in schema. * Revert heading changes in publisher cmd line docs. This change reverts the heading for the heading for the publisher cmd line args doc back to the original version per code upstream review comment. Co-authored-by: Suneet Nangia <suneetnangia@gmail.com>
- Loading branch information
1 parent
40f6280
commit cefab77
Showing
78 changed files
with
1,267 additions
and
205 deletions.
There are no files selected for viewing
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
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
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
22 changes: 22 additions & 0 deletions
22
common/src/Microsoft.Azure.IIoT.Abstractions/src/Validators/IJsonSchemaValidator.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,22 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information. | ||
// ------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.IIoT.Validators { | ||
using System.Collections.Generic; | ||
using System.IO; | ||
|
||
/// <summary> | ||
/// Json schema validator | ||
/// </summary> | ||
public interface IJsonSchemaValidator { | ||
/// <summary> | ||
/// Validates Json against the provided Json schema. | ||
/// </summary> | ||
/// <param name="jsonBuffer"></param> | ||
/// <param name="schemaReader"></param> | ||
/// <returns></returns> | ||
public IList<JsonSchemaValidationResult> Validate(byte[] jsonBuffer, TextReader schemaReader); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
common/src/Microsoft.Azure.IIoT.Abstractions/src/Validators/JsonSchemaValidationResult.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,50 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information. | ||
// ------------------------------------------------------------ | ||
|
||
namespace Microsoft.Azure.IIoT.Validators { | ||
/// <summary> | ||
/// Json schema validation result. | ||
/// </summary> | ||
public class JsonSchemaValidationResult { | ||
|
||
/// <summary> | ||
/// Instantiates json schema validation result. | ||
/// </summary> | ||
/// <param name="isValid"></param> | ||
/// <param name="message"></param> | ||
/// <param name="schemaLocation"></param> | ||
/// <param name="instanceLocation"></param> | ||
public JsonSchemaValidationResult( | ||
bool isValid, | ||
string message = null, | ||
string schemaLocation = null, | ||
string instanceLocation = null) { | ||
IsValid = isValid; | ||
Message = message; | ||
SchemaLocation = schemaLocation; | ||
InstanceLocation = instanceLocation; | ||
} | ||
|
||
/// <summary> | ||
/// Indicates whether the validation passed or failed. | ||
/// </summary> | ||
public bool IsValid { get; } | ||
|
||
/// <summary> | ||
/// The error message, if any. | ||
/// </summary> | ||
public string Message { get; } | ||
|
||
/// <summary> | ||
/// The schema location that generated this node. | ||
/// </summary> | ||
public string SchemaLocation { get; } | ||
|
||
/// <summary> | ||
/// The instance location that was processed. | ||
/// </summary> | ||
public string InstanceLocation { get; } | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.