mirror of
https://github.com/Sheldan/OnePlusBot.git
synced 2026-01-03 16:27:46 +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());
|
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||||
List<FaqCommandConfig> commands = faqServiceBean.loadFAQCommandsFromJson(jsonContent);
|
List<FaqCommandConfig> commands = faqServiceBean.loadFAQCommandsFromJson(jsonContent);
|
||||||
faqServiceBean.createOrUpdateFAQCommands(commands, server);
|
faqServiceBean.createOrUpdateFAQCommands(commands, server);
|
||||||
|
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
List<String> errors = jsonValidationService.getDetailedException(result.getExceptions())
|
List<String> errors = jsonValidationService.getDetailedException(result.getExceptions())
|
||||||
@@ -73,8 +74,8 @@ public class ImportFAQ extends AbstractConditionableCommand {
|
|||||||
.map(ValidationException::getMessage)
|
.map(ValidationException::getMessage)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
channelService.sendTextToChannel(String.join("\n", errors), commandContext.getChannel());
|
channelService.sendTextToChannel(String.join("\n", errors), commandContext.getChannel());
|
||||||
|
return CompletableFuture.completedFuture(CommandResult.fromError("Incorrect faq config."));
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(CommandResult.fromSuccess());
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("IO Exception when loading input file.", e);
|
log.error("IO Exception when loading input file.", e);
|
||||||
throw new AbstractoTemplatedException("Failed to load json config.", "failed_to_set_template_exception", e);
|
throw new AbstractoTemplatedException("Failed to load json config.", "failed_to_set_template_exception", e);
|
||||||
|
|||||||
@@ -3,8 +3,7 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1,
|
"minItems": 1,
|
||||||
"maxItems": 30,
|
"maxItems": 30,
|
||||||
"items": [
|
"items": {
|
||||||
{
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"faqCommandName": {
|
"faqCommandName": {
|
||||||
@@ -45,8 +44,7 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1,
|
"minItems": 1,
|
||||||
"maxItems": 3,
|
"maxItems": 3,
|
||||||
"items": [
|
"items": {
|
||||||
{
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"position": {
|
"position": {
|
||||||
@@ -168,7 +166,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
@@ -185,5 +182,4 @@
|
|||||||
"responses"
|
"responses"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user