yaklang / yakit

Cyber Security ALL-IN-ONE Platform
GNU Affero General Public License v3.0
6.68k stars 833 forks source link

support json-schema in yakparameter #2123

Open wlingze opened 4 days ago

wlingze commented 4 days ago

需要支持json-schema:

需要支持的代码

yakit.AutoInitYakit()

# Input your code!

cli.Json("a", cli.setJsonSchema(<<<JSON
{
  "type": "object",
  "properties": {
    "animal": {
      "enum": [
        "Cat",
        "Fish"
      ]
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "animal": {
            "const": "Cat"
          }
        }
      },
      "then": {
        "properties": {
          "food": {
            "type": "string",
            "enum": [
              "meat",
              "grass",
              "fish"
            ]
          }
        },
        "required": [
          "food"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "animal": {
            "const": "Fish"
          }
        }
      },
      "then": {
        "properties": {
          "food": {
            "type": "string",
            "enum": [
              "insect",
              "worms"
            ]
          },
          "water": {
            "type": "string",
            "enum": [
              "lake",
              "sea"
            ]
          }
        },
        "required": [
          "food",
          "water"
        ]
      }
    },
    {
      "required": [
        "animal"
      ]
    }
  ]
}
JSON))
cli.check()