Skip to content

Instantly share code, notes, and snippets.

@gyli
Created February 16, 2023 22:57
Show Gist options
  • Save gyli/8882cc62356b1c5d0c02e656f1a0927a to your computer and use it in GitHub Desktop.
Save gyli/8882cc62356b1c5d0c02e656f1a0927a to your computer and use it in GitHub Desktop.
Meta-schema of a jsonschema to disallow Python dictionary method names to be used as property names
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Meta-schema of a jsonschema to disallow Python dictionary method names to be used as property names",
"description": "Checks forbidden properties in json objects recursively. Jsonschema keywords need to be conditionally excluded.",
"type": "object",
"allOf": [
{
"$ref": "#/definitions/forbidden-properties"
}
],
"definitions": {
"forbidden-properties": {
"$coment": "Python dictionary method names are disallowed",
"properties": {
"clear": false,
"copy": false,
"fromkeys": false,
"get": false,
"keys": false,
"pop": false,
"popitem": false,
"setdefault": false,
"update": false,
"values": false
},
"anyOf": [
{
"$comment": "items is a jsonschema keyword when type == array",
"properties": {
"type": {
"const": "array"
}
}
},
{
"properties": {
"items": false
}
}
],
"additionalProperties": {
"$ref": "#/definitions/forbidden-properties"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment