From b25e30a896cd7ed65d02db7d8639cd28a11981f0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 17 Apr 2022 01:07:18 -0400 Subject: fix model binding error --- src/SMAPI.Web/Controllers/JsonValidatorController.cs | 4 ++-- .../JsonValidator/JsonValidatorRequestModel.cs | 17 ++--------------- 2 files changed, 4 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/SMAPI.Web/Controllers/JsonValidatorController.cs b/src/SMAPI.Web/Controllers/JsonValidatorController.cs index e78aeeb6..c551a805 100644 --- a/src/SMAPI.Web/Controllers/JsonValidatorController.cs +++ b/src/SMAPI.Web/Controllers/JsonValidatorController.cs @@ -122,7 +122,7 @@ namespace StardewModdingAPI.Web.Controllers FileInfo? schemaFile = this.FindSchemaFile(schemaName); if (schemaFile == null) return this.View("Index", result.SetParseError($"Invalid schema '{schemaName}'.")); - schema = JSchema.Parse(System.IO.File.ReadAllText(schemaFile.FullName)); + schema = JSchema.Parse(await System.IO.File.ReadAllTextAsync(schemaFile.FullName)); } // get format doc URL @@ -151,7 +151,7 @@ namespace StardewModdingAPI.Web.Controllers string schemaName = this.NormalizeSchemaName(request.SchemaName); // get raw text - string input = request.Content; + string? input = request.Content; if (string.IsNullOrWhiteSpace(input)) return this.View("Index", this.GetModel(null, schemaName, isEditView: true).SetUploadError("The JSON file seems to be empty.")); diff --git a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs index 3edb58db..1313264f 100644 --- a/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs +++ b/src/SMAPI.Web/ViewModels/JsonValidator/JsonValidatorRequestModel.cs @@ -7,22 +7,9 @@ namespace StardewModdingAPI.Web.ViewModels.JsonValidator ** Accessors *********/ /// The schema name with which to validate the JSON. - public string SchemaName { get; } + public string? SchemaName { get; set; } /// The raw content to validate. - public string Content { get; } - - - /********* - ** Accessors - *********/ - /// Construct an instance. - /// The schema name with which to validate the JSON. - /// The raw content to validate. - public JsonValidatorRequestModel(string schemaName, string content) - { - this.SchemaName = schemaName; - this.Content = content; - } + public string? Content { get; set; } } } -- cgit