summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/ViewModels/JsonValidator
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/ViewModels/JsonValidator')
-rw-r--r--src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorErrorModel.cs15
-rw-r--r--src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs29
-rw-r--r--src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs19
3 files changed, 32 insertions, 31 deletions
diff --git a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorErrorModel.cs b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorErrorModel.cs
index 3c63b730..4d37d449 100644
--- a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorErrorModel.cs
+++ b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorErrorModel.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using Newtonsoft.Json.Schema;
namespace StardewModdingAPI.Web.ViewModels.JsonValidator
@@ -11,30 +9,27 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator
** Accessors
*********/
/// <summary>The line number on which the error occurred.</summary>
- public int Line { get; set; }
+ public int Line { get; }
/// <summary>The field path in the JSON file where the error occurred.</summary>
- public string Path { get; set; }
+ public string? Path { get; }
/// <summary>A human-readable description of the error.</summary>
- public string Message { get; set; }
+ public string Message { get; }
/// <summary>The schema error type.</summary>
- public ErrorType SchemaErrorType { get; set; }
+ public ErrorType SchemaErrorType { get; }
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
- public JsonValidatorErrorModel() { }
-
- /// <summary>Construct an instance.</summary>
/// <param name="line">The line number on which the error occurred.</param>
/// <param name="path">The field path in the JSON file where the error occurred.</param>
/// <param name="message">A human-readable description of the error.</param>
/// <param name="schemaErrorType">The schema error type.</param>
- public JsonValidatorErrorModel(int line, string path, string message, ErrorType schemaErrorType)
+ public JsonValidatorErrorModel(int line, string? path, string message, ErrorType schemaErrorType)
{
this.Line = line;
this.Path = path;
diff --git a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs
index 2543807f..85c2f44d 100644
--- a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs
+++ b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorModel.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,51 +11,48 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator
** Accessors
*********/
/// <summary>Whether to show the edit view.</summary>
- public bool IsEditView { get; set; }
+ public bool IsEditView { get; }
/// <summary>The paste ID.</summary>
- public string PasteID { get; set; }
+ public string? PasteID { get; }
/// <summary>The schema name with which the JSON was validated.</summary>
- public string SchemaName { get; set; }
+ public string? SchemaName { get; }
/// <summary>The supported JSON schemas (names indexed by ID).</summary>
- public readonly IDictionary<string, string> SchemaFormats;
+ public IDictionary<string, string> SchemaFormats { get; }
/// <summary>The validated content.</summary>
- public string Content { get; set; }
+ public string? Content { get; set; }
/// <summary>The schema validation errors, if any.</summary>
public JsonValidatorErrorModel[] Errors { get; set; } = Array.Empty<JsonValidatorErrorModel>();
/// <summary>A non-blocking warning while uploading the file.</summary>
- public string UploadWarning { get; set; }
+ public string? UploadWarning { get; set; }
/// <summary>When the uploaded file will no longer be available.</summary>
- public DateTime? Expiry { get; set; }
+ public DateTimeOffset? Expiry { get; set; }
/// <summary>An error which occurred while uploading the JSON.</summary>
- public string UploadError { get; set; }
+ public string? UploadError { get; set; }
/// <summary>An error which occurred while parsing the JSON.</summary>
- public string ParseError { get; set; }
+ public string? ParseError { get; set; }
/// <summary>A web URL to the user-facing format documentation.</summary>
- public string FormatUrl { get; set; }
+ public string? FormatUrl { get; set; }
/*********
** Public methods
*********/
/// <summary>Construct an instance.</summary>
- public JsonValidatorModel() { }
-
- /// <summary>Construct an instance.</summary>
/// <param name="pasteID">The stored file ID.</param>
/// <param name="schemaName">The schema name with which the JSON was validated.</param>
/// <param name="schemaFormats">The supported JSON schemas (names indexed by ID).</param>
/// <param name="isEditView">Whether to show the edit view.</param>
- public JsonValidatorModel(string pasteID, string schemaName, IDictionary<string, string> schemaFormats, bool isEditView)
+ public JsonValidatorModel(string? pasteID, string? schemaName, IDictionary<string, string> schemaFormats, bool isEditView)
{
this.PasteID = pasteID;
this.SchemaName = schemaName;
@@ -69,7 +64,7 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator
/// <param name="content">The validated content.</param>
/// <param name="expiry">When the uploaded file will no longer be available.</param>
/// <param name="uploadWarning">A non-blocking warning while uploading the log.</param>
- public JsonValidatorModel SetContent(string content, DateTime? expiry, string uploadWarning = null)
+ public JsonValidatorModel SetContent(string content, DateTimeOffset? expiry, string? uploadWarning = null)
{
this.Content = content;
this.Expiry = expiry;
diff --git a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs
index 43114d94..3edb58db 100644
--- a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs
+++ b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs
@@ -1,5 +1,3 @@
-#nullable disable
-
namespace StardewModdingAPI.Web.ViewModels.JsonValidator
{
/// <summary>The view model for a JSON validation request.</summary>
@@ -9,9 +7,22 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator
** Accessors
*********/
/// <summary>The schema name with which to validate the JSON.</summary>
- public string SchemaName { get; set; }
+ public string SchemaName { get; }
/// <summary>The raw content to validate.</summary>
- public string Content { get; set; }
+ public string Content { get; }
+
+
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="schemaName">The schema name with which to validate the JSON.</param>
+ /// <param name="content">The raw content to validate.</param>
+ public JsonValidatorRequestModel(string schemaName, string content)
+ {
+ this.SchemaName = schemaName;
+ this.Content = content;
+ }
}
}