Add JSON Schema for Trivia Lists #5565

Merged
Kreusada merged 31 commits from patch-86 into V3/develop 2023-03-02 15:43:55 +01:00
Kreusada commented 2022-02-03 21:30:09 +01:00 (Migrated from github.com)

Description of the changes

Closes #5301. May be altered pending comments on #5390, and #5897 if it gets merged.

Adds JSON schema for Trivia list author and configuration keys.

### Description of the changes Closes #5301. May be altered pending comments on #5390, and #5897 if it gets merged. Adds JSON schema for Trivia list author and configuration keys.
Jackenmen commented 2022-02-03 21:35:56 +01:00 (Migrated from github.com)

Once this is approved and merged, you or I should make a PR against https://github.com/SchemaStore/schemastore as well (see SchemaStore/schemastore#1226)

Once this is approved and merged, you or I should make a PR against https://github.com/SchemaStore/schemastore as well (see SchemaStore/schemastore#1226)
Kreusada commented 2022-02-03 21:45:29 +01:00 (Migrated from github.com)

Once this is approved and merged, you or I should make a PR against https://github.com/SchemaStore/schemastore as well (see SchemaStore/schemastore#1226)

I'd be happy doing this 👍
Draft (pending): https://github.com/SchemaStore/schemastore/pull/2068

> Once this is approved and merged, you or I should make a PR against https://github.com/SchemaStore/schemastore as well (see [SchemaStore/schemastore#1226](https://github.com/SchemaStore/schemastore/pull/1226)) I'd be happy doing this 👍 Draft (pending): https://github.com/SchemaStore/schemastore/pull/2068
Jackenmen (Migrated from github.com) requested changes 2022-12-29 05:24:24 +01:00
Jackenmen (Migrated from github.com) left a comment

In addition to the review comments:

  • the JSON file should be formatted with 2 space indentation to be consistent with existing schema files
  • it would be great if the trivia cog ignored $schema key instead of treating it as a question
  • schema should specify that all other keys should be lists of strings
In addition to the review comments: - the JSON file should be formatted with 2 space indentation to be consistent with existing schema files - it would be great if the trivia cog ignored `$schema` key instead of treating it as a question - schema should specify that all other keys should be lists of strings - this should be achievable with `additionalProperties`: https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.2.3
@ -0,0 +1,61 @@
{
Jackenmen (Migrated from github.com) commented 2022-12-29 05:05:48 +01:00
    "title": "Red-DiscordBot Trivia List file",
```suggestion "title": "Red-DiscordBot Trivia List file", ```
Jackenmen (Migrated from github.com) commented 2022-12-29 05:16:06 +01:00

This is the default value so it should not need to be specified:

This is the default value so it should not need to be specified: ```suggestion ```
Jackenmen (Migrated from github.com) commented 2022-12-29 05:19:36 +01:00

The only valid keys are specified in the schema so we can disallow names not listed here:

            },
            "additionalProperties": false
The only valid keys are specified in the schema so we can disallow names not listed here: ```suggestion }, "additionalProperties": false ```
Jackenmen (Migrated from github.com) requested changes 2022-12-29 05:49:36 +01:00
Jackenmen (Migrated from github.com) left a comment

I sent the first review a bit too soon - I forgot to review properties in CONFIG key...
Aside from review comments, you should probably also remove the default values from everything as they're not actually accurate since they depend on whatever the server set those values to. All of the keys simply have no default value, if they're not specified in the YAML file then they're simply not being overridden.

I sent the first review a bit too soon - I forgot to review properties in `CONFIG` key... Aside from review comments, you should probably also remove the default values from everything as they're not actually accurate since they depend on whatever the server set those values to. All of the keys simply have no default value, if they're not specified in the YAML file then they're simply not being overridden.
@ -0,0 +1,61 @@
{
Jackenmen (Migrated from github.com) commented 2022-12-29 05:35:26 +01:00
                    "description": "The maximum number of seconds permitted to answer a question, must be a positive number greater than or equal to 4.0. Defaults to 15.0.",
                    "minimum": 4.0,
```suggestion "description": "The maximum number of seconds permitted to answer a question, must be a positive number greater than or equal to 4.0. Defaults to 15.0.", "minimum": 4.0, ```
Jackenmen (Migrated from github.com) commented 2022-12-29 05:36:28 +01:00
                    "description": "Number of points required in order to win the trivia, must be a positive integer. Defaults to 10.",
                    "exclusiveMinimum": 0,
```suggestion "description": "Number of points required in order to win the trivia, must be a positive integer. Defaults to 10.", "exclusiveMinimum": 0, ```
Jackenmen (Migrated from github.com) commented 2022-12-29 05:37:10 +01:00
                    "description": "Number of seconds that need to pass until trivia stops due to no response, must be a positive number greater than 0.0. Defaults to 120.0.",
                    "exclusiveMinimum": 0
```suggestion "description": "Number of seconds that need to pass until trivia stops due to no response, must be a positive number greater than 0.0. Defaults to 120.0.", "exclusiveMinimum": 0 ```
Jackenmen (Migrated from github.com) commented 2022-12-29 05:39:54 +01:00
                    "description": "The payout multiplier, must be a positive number or zero. Defaults to 0.0.",
                    "minimum": 0
```suggestion "description": "The payout multiplier, must be a positive number or zero. Defaults to 0.0.", "minimum": 0 ```
Jackenmen (Migrated from github.com) commented 2022-12-29 05:46:55 +01:00
                    "description": "Whether to hide the answers in spoilers when revealing the question's answers. Defaults to false.",
```suggestion "description": "Whether to hide the answers in spoilers when revealing the question's answers. Defaults to false.", ```
Kreusada commented 2022-12-29 11:55:28 +01:00 (Migrated from github.com)

it would be great if the trivia cog ignored $schema key instead of treating it as a question

What do you mean by this?

> it would be great if the trivia cog ignored `$schema` key instead of treating it as a question What do you mean by this?
Jackenmen commented 2022-12-29 16:06:12 +01:00 (Migrated from github.com)

JSON schema url can be specified with a top-level $schema key (to be explicit rather than rely on editor's auto-detection). However, Trivia cog will currently reject this as it expects all keys except AUTHOR and CONFIG to be questions.

JSON schema url can be specified with a top-level `$schema` key (to be explicit rather than rely on editor's auto-detection). However, Trivia cog will currently reject this as it expects all keys except AUTHOR and CONFIG to be questions.
Jackenmen commented 2023-01-02 05:46:17 +01:00 (Migrated from github.com)

This should probably just require adding this line to the TRIVIA_LIST_SCHEMA dictionary:

Optional("$schema"): And(str, error=_("{key} key must be a text value.")),
This should probably just require adding this line to the `TRIVIA_LIST_SCHEMA` dictionary: ``` Optional("$schema"): And(str, error=_("{key} key must be a text value.")), ```
Jackenmen (Migrated from github.com) requested changes 2023-01-03 22:58:36 +01:00
Jackenmen (Migrated from github.com) left a comment

In addition to the review comments, it seems that the default values are still in the property descriptions, they should be removed from there as well.

In addition to the review comments, it seems that the default values are still in the property descriptions, they should be removed from there as well.
@ -0,0 +1,61 @@
{
Jackenmen (Migrated from github.com) commented 2023-01-03 22:36:27 +01:00
      "description": "Author of the Trivia list."
```suggestion "description": "Author of the Trivia list." ```
Jackenmen (Migrated from github.com) commented 2023-01-03 22:38:47 +01:00

Missed the removal of default in this one:

          "description": "Whether or not to reveal the answer when the question times out. Defaults to true."
Missed the removal of default in this one: ```suggestion "description": "Whether or not to reveal the answer when the question times out. Defaults to true." ```
Jackenmen (Migrated from github.com) commented 2023-01-03 22:47:34 +01:00

number already supports integers:

          "type": "number",
`number` already supports integers: ```suggestion "type": "number", ```
Jackenmen (Migrated from github.com) commented 2023-01-03 22:47:42 +01:00

number already supports integers:

          "type": "number",
`number` already supports integers: ```suggestion "type": "number", ```
Jackenmen (Migrated from github.com) commented 2023-01-03 22:47:48 +01:00

number already supports integers:

          "type": "number",
`number` already supports integers: ```suggestion "type": "number", ```
@ -0,0 +3,4 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Red-DiscordBot Trivia List file",
"type": "object",
"properties": {
Jackenmen (Migrated from github.com) commented 2023-01-03 22:36:01 +01:00

I'm unsure this is required but some schema validators seem to reject $schema field as having an invalid type when additionalProperties is set to an array of strings so it's probably better to define it:

  "properties": {
    "$schema": {
      "type": "string",
      "format": "uri"
    },
I'm unsure this is required but some schema validators seem to reject `$schema` field as having an invalid type when `additionalProperties` is set to an array of strings so it's probably better to define it: ```suggestion "properties": { "$schema": { "type": "string", "format": "uri" }, ```
@ -0,0 +57,4 @@
"items": {
"type": "string"
}
}
Jackenmen (Migrated from github.com) commented 2023-01-03 22:17:01 +01:00

This remains to be unaddressed:

This should work:

  },
  "additionalProperties": {
    "type": "array",
    "items": {
      "type": "string"
    }
  }
This remains to be unaddressed: > - schema should specify that all other keys should be lists of strings > - this should be achievable with `additionalProperties`: https://json-schema.org/draft/2020-12/json-schema-core.html#section-10.3.2.3 This should work: ```suggestion }, "additionalProperties": { "type": "array", "items": { "type": "string" } } ```
Jackenmen commented 2023-02-23 15:59:22 +01:00 (Migrated from github.com)

In addition to the review comments, it seems that the default values are still in the property descriptions, they should be removed from there as well.

Unsure if you know but above remains unaddressed.

It also seems that this PR isn't really blocked by the PR mentioned in the description, it would just need changes if the other one gets merged first. Am I missing something?

> In addition to the review comments, it seems that the default values are still in the property descriptions, they should be removed from there as well. Unsure if you know but above remains unaddressed. It also seems that this PR isn't really blocked by the PR mentioned in the description, it would just need changes *if* the other one gets merged first. Am I missing something?
Kreusada commented 2023-02-23 17:16:51 +01:00 (Migrated from github.com)

In addition to the review comments, it seems that the default values are still in the property descriptions, they should be removed from there as well. Unsure if you know but above remains unaddressed.

Ah I had missed this, I had addressed these changes now.

> In addition to the review comments, it seems that the default values are still in the property descriptions, they should be removed from there as well. Unsure if you know but above remains unaddressed. Ah I had missed this, I had addressed these changes now.
Jackenmen (Migrated from github.com) approved these changes 2023-03-02 15:43:43 +01:00
Jackenmen (Migrated from github.com) left a comment

LGTM, sorry for the delay. As mentioned before, this should now be added to schemastore repository.

LGTM, sorry for the delay. As mentioned before, this should now be added to schemastore repository. ![](https://i.fluffy.cc/4HrdmGw7MHL3rcH3J0lCBBG7xhlxnWs7.gif)
Kreusada commented 2023-03-02 21:55:41 +01:00 (Migrated from github.com)
https://github.com/SchemaStore/schemastore/pull/2810
red-githubbot[bot] commented 2023-04-19 23:57:41 +02:00 (Migrated from github.com)

#6070 is a backport of this pull request to Red 3.4.

#6070 is a backport of this pull request to [Red 3.4](https://github.com/Cog-Creators/Red-DiscordBot/tree/3.4).
Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!5565
No description provided.