mirror of
https://github.com/Sheldan/OnePlusBot.git
synced 2026-01-01 23:35:23 +00:00
[OPB-38] fixing json validation
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user