additionalProperties.json 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. [
  2. {
  3. "description":
  4. "additionalProperties being false does not allow other properties",
  5. "schema": {
  6. "properties": {"foo": {}, "bar": {}},
  7. "patternProperties": { "^v": {} },
  8. "additionalProperties": false
  9. },
  10. "tests": [
  11. {
  12. "description": "no additional properties is valid",
  13. "data": {"foo": 1},
  14. "valid": true
  15. },
  16. {
  17. "description": "an additional property is invalid",
  18. "data": {"foo" : 1, "bar" : 2, "quux" : "boom"},
  19. "valid": false
  20. },
  21. {
  22. "description": "ignores non-objects",
  23. "data": [1, 2, 3],
  24. "valid": true
  25. },
  26. {
  27. "description": "patternProperties are not additional properties",
  28. "data": {"foo":1, "vroom": 2},
  29. "valid": true
  30. }
  31. ]
  32. },
  33. {
  34. "description":
  35. "additionalProperties allows a schema which should validate",
  36. "schema": {
  37. "properties": {"foo": {}, "bar": {}},
  38. "additionalProperties": {"type": "boolean"}
  39. },
  40. "tests": [
  41. {
  42. "description": "no additional properties is valid",
  43. "data": {"foo": 1},
  44. "valid": true
  45. },
  46. {
  47. "description": "an additional valid property is valid",
  48. "data": {"foo" : 1, "bar" : 2, "quux" : true},
  49. "valid": true
  50. },
  51. {
  52. "description": "an additional invalid property is invalid",
  53. "data": {"foo" : 1, "bar" : 2, "quux" : 12},
  54. "valid": false
  55. }
  56. ]
  57. },
  58. {
  59. "description":
  60. "additionalProperties can exist by itself",
  61. "schema": {
  62. "additionalProperties": {"type": "boolean"}
  63. },
  64. "tests": [
  65. {
  66. "description": "an additional valid property is valid",
  67. "data": {"foo" : true},
  68. "valid": true
  69. },
  70. {
  71. "description": "an additional invalid property is invalid",
  72. "data": {"foo" : 1},
  73. "valid": false
  74. }
  75. ]
  76. },
  77. {
  78. "description": "additionalProperties are allowed by default",
  79. "schema": {"properties": {"foo": {}, "bar": {}}},
  80. "tests": [
  81. {
  82. "description": "additional properties are allowed",
  83. "data": {"foo": 1, "bar": 2, "quux": true},
  84. "valid": true
  85. }
  86. ]
  87. }
  88. ]