[OPB-38] fixing json validation

This commit is contained in:
Sheldan
2021-08-22 18:39:41 +02:00
parent bf98d5db3a
commit d7f5fc21d6
2 changed files with 136 additions and 139 deletions

View File

@@ -66,6 +66,7 @@ public class ImportFAQ extends AbstractConditionableCommand {
AServer server = serverManagementService.loadServer(commandContext.getGuild());
List<FaqCommandConfig> commands = faqServiceBean.loadFAQCommandsFromJson(jsonContent);
faqServiceBean.createOrUpdateFAQCommands(commands, server);
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
} else {
List<String> errors = jsonValidationService.getDetailedException(result.getExceptions())
@@ -73,8 +74,8 @@ public class ImportFAQ extends AbstractConditionableCommand {
.map(ValidationException::getMessage)
.collect(Collectors.toList());
channelService.sendTextToChannel(String.join("\n", errors), commandContext.getChannel());
return CompletableFuture.completedFuture(CommandResult.fromError("Incorrect faq config."));
}
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
} catch (IOException e) {
log.error("IO Exception when loading input file.", e);
throw new AbstractoTemplatedException("Failed to load json config.", "failed_to_set_template_exception", e);

View File

@@ -3,8 +3,7 @@
"type": "array",
"minItems": 1,
"maxItems": 30,
"items": [
{
"items": {
"type": "object",
"properties": {
"faqCommandName": {
@@ -45,8 +44,7 @@
"type": "array",
"minItems": 1,
"maxItems": 3,
"items": [
{
"items": {
"type": "object",
"properties": {
"position": {
@@ -168,7 +166,6 @@
}
]
}
]
}
},
"additionalProperties": false,
@@ -185,5 +182,4 @@
"responses"
]
}
]
}