@vcollab/yaml-language-server-tag-validation 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (865) hide show
  1. package/CHANGELOG.md +712 -0
  2. package/CONTRIBUTING.md +8 -0
  3. package/DCO +37 -0
  4. package/Dockerfile +11 -0
  5. package/LICENSE +21 -0
  6. package/README.md +475 -0
  7. package/bin/yaml-language-server +27 -0
  8. package/docs/scalaruri-custom-tags.md +269 -0
  9. package/l10n/bundle.l10n.de.json +62 -0
  10. package/l10n/bundle.l10n.fr.json +62 -0
  11. package/l10n/bundle.l10n.ja.json +62 -0
  12. package/l10n/bundle.l10n.json +61 -0
  13. package/l10n/bundle.l10n.ko.json +62 -0
  14. package/l10n/bundle.l10n.zh-cn.json +62 -0
  15. package/l10n/bundle.l10n.zh-tw.json +62 -0
  16. package/lib/esm/commands.d.ts +3 -0
  17. package/lib/esm/commands.js +9 -0
  18. package/lib/esm/commands.js.map +1 -0
  19. package/lib/esm/index.d.ts +3 -0
  20. package/lib/esm/index.js +4 -0
  21. package/lib/esm/index.js.map +1 -0
  22. package/lib/esm/languageserver/commandExecutor.d.ts +10 -0
  23. package/lib/esm/languageserver/commandExecutor.js +21 -0
  24. package/lib/esm/languageserver/commandExecutor.js.map +1 -0
  25. package/lib/esm/languageserver/handlers/languageHandlers.d.ts +61 -0
  26. package/lib/esm/languageserver/handlers/languageHandlers.js +236 -0
  27. package/lib/esm/languageserver/handlers/languageHandlers.js.map +1 -0
  28. package/lib/esm/languageserver/handlers/notificationHandlers.d.ts +29 -0
  29. package/lib/esm/languageserver/handlers/notificationHandlers.js +46 -0
  30. package/lib/esm/languageserver/handlers/notificationHandlers.js.map +1 -0
  31. package/lib/esm/languageserver/handlers/requestHandlers.d.ts +9 -0
  32. package/lib/esm/languageserver/handlers/requestHandlers.js +23 -0
  33. package/lib/esm/languageserver/handlers/requestHandlers.js.map +1 -0
  34. package/lib/esm/languageserver/handlers/schemaSelectionHandlers.d.ts +13 -0
  35. package/lib/esm/languageserver/handlers/schemaSelectionHandlers.js +72 -0
  36. package/lib/esm/languageserver/handlers/schemaSelectionHandlers.js.map +1 -0
  37. package/lib/esm/languageserver/handlers/settingsHandlers.d.ts +42 -0
  38. package/lib/esm/languageserver/handlers/settingsHandlers.js +316 -0
  39. package/lib/esm/languageserver/handlers/settingsHandlers.js.map +1 -0
  40. package/lib/esm/languageserver/handlers/validationHandlers.d.ts +15 -0
  41. package/lib/esm/languageserver/handlers/validationHandlers.js +108 -0
  42. package/lib/esm/languageserver/handlers/validationHandlers.js.map +1 -0
  43. package/lib/esm/languageserver/handlers/workspaceHandlers.d.ts +9 -0
  44. package/lib/esm/languageserver/handlers/workspaceHandlers.js +17 -0
  45. package/lib/esm/languageserver/handlers/workspaceHandlers.js.map +1 -0
  46. package/lib/esm/languageserver/telemetry.d.ts +9 -0
  47. package/lib/esm/languageserver/telemetry.js +20 -0
  48. package/lib/esm/languageserver/telemetry.js.map +1 -0
  49. package/lib/esm/languageservice/jsonASTTypes.d.ts +49 -0
  50. package/lib/esm/languageservice/jsonASTTypes.js +6 -0
  51. package/lib/esm/languageservice/jsonASTTypes.js.map +1 -0
  52. package/lib/esm/languageservice/jsonSchema.d.ts +103 -0
  53. package/lib/esm/languageservice/jsonSchema.js +12 -0
  54. package/lib/esm/languageservice/jsonSchema.js.map +1 -0
  55. package/lib/esm/languageservice/parser/ast-converter.d.ts +11 -0
  56. package/lib/esm/languageservice/parser/ast-converter.js +176 -0
  57. package/lib/esm/languageservice/parser/ast-converter.js.map +1 -0
  58. package/lib/esm/languageservice/parser/astNodeUtils.d.ts +4 -0
  59. package/lib/esm/languageservice/parser/astNodeUtils.js +48 -0
  60. package/lib/esm/languageservice/parser/astNodeUtils.js.map +1 -0
  61. package/lib/esm/languageservice/parser/custom-tag-provider.d.ts +7 -0
  62. package/lib/esm/languageservice/parser/custom-tag-provider.js +58 -0
  63. package/lib/esm/languageservice/parser/custom-tag-provider.js.map +1 -0
  64. package/lib/esm/languageservice/parser/isKubernetes.d.ts +4 -0
  65. package/lib/esm/languageservice/parser/isKubernetes.js +17 -0
  66. package/lib/esm/languageservice/parser/isKubernetes.js.map +1 -0
  67. package/lib/esm/languageservice/parser/jsonDocument.d.ts +83 -0
  68. package/lib/esm/languageservice/parser/jsonDocument.js +171 -0
  69. package/lib/esm/languageservice/parser/jsonDocument.js.map +1 -0
  70. package/lib/esm/languageservice/parser/scalar-type.d.ts +8 -0
  71. package/lib/esm/languageservice/parser/scalar-type.js +17 -0
  72. package/lib/esm/languageservice/parser/scalar-type.js.map +1 -0
  73. package/lib/esm/languageservice/parser/schemaValidation/baseValidator.d.ts +124 -0
  74. package/lib/esm/languageservice/parser/schemaValidation/baseValidator.js +1254 -0
  75. package/lib/esm/languageservice/parser/schemaValidation/baseValidator.js.map +1 -0
  76. package/lib/esm/languageservice/parser/schemaValidation/draft04Validator.d.ts +17 -0
  77. package/lib/esm/languageservice/parser/schemaValidation/draft04Validator.js +30 -0
  78. package/lib/esm/languageservice/parser/schemaValidation/draft04Validator.js.map +1 -0
  79. package/lib/esm/languageservice/parser/schemaValidation/draft07Validator.d.ts +15 -0
  80. package/lib/esm/languageservice/parser/schemaValidation/draft07Validator.js +28 -0
  81. package/lib/esm/languageservice/parser/schemaValidation/draft07Validator.js.map +1 -0
  82. package/lib/esm/languageservice/parser/schemaValidation/draft2019Validator.d.ts +28 -0
  83. package/lib/esm/languageservice/parser/schemaValidation/draft2019Validator.js +224 -0
  84. package/lib/esm/languageservice/parser/schemaValidation/draft2019Validator.js.map +1 -0
  85. package/lib/esm/languageservice/parser/schemaValidation/draft2020Validator.d.ts +17 -0
  86. package/lib/esm/languageservice/parser/schemaValidation/draft2020Validator.js +126 -0
  87. package/lib/esm/languageservice/parser/schemaValidation/draft2020Validator.js.map +1 -0
  88. package/lib/esm/languageservice/parser/schemaValidation/validatorFactory.d.ts +3 -0
  89. package/lib/esm/languageservice/parser/schemaValidation/validatorFactory.js +24 -0
  90. package/lib/esm/languageservice/parser/schemaValidation/validatorFactory.js.map +1 -0
  91. package/lib/esm/languageservice/parser/yaml-documents.d.ts +71 -0
  92. package/lib/esm/languageservice/parser/yaml-documents.js +258 -0
  93. package/lib/esm/languageservice/parser/yaml-documents.js.map +1 -0
  94. package/lib/esm/languageservice/parser/yamlParser07.d.ts +15 -0
  95. package/lib/esm/languageservice/parser/yamlParser07.js +50 -0
  96. package/lib/esm/languageservice/parser/yamlParser07.js.map +1 -0
  97. package/lib/esm/languageservice/services/crdUtil.d.ts +23 -0
  98. package/lib/esm/languageservice/services/crdUtil.js +74 -0
  99. package/lib/esm/languageservice/services/crdUtil.js.map +1 -0
  100. package/lib/esm/languageservice/services/documentSymbols.d.ts +12 -0
  101. package/lib/esm/languageservice/services/documentSymbols.js +67 -0
  102. package/lib/esm/languageservice/services/documentSymbols.js.map +1 -0
  103. package/lib/esm/languageservice/services/modelineUtil.d.ts +9 -0
  104. package/lib/esm/languageservice/services/modelineUtil.js +29 -0
  105. package/lib/esm/languageservice/services/modelineUtil.js.map +1 -0
  106. package/lib/esm/languageservice/services/schemaRequestHandler.d.ts +12 -0
  107. package/lib/esm/languageservice/services/schemaRequestHandler.js +84 -0
  108. package/lib/esm/languageservice/services/schemaRequestHandler.js.map +1 -0
  109. package/lib/esm/languageservice/services/validation/map-key-order.d.ts +7 -0
  110. package/lib/esm/languageservice/services/validation/map-key-order.js +35 -0
  111. package/lib/esm/languageservice/services/validation/map-key-order.js.map +1 -0
  112. package/lib/esm/languageservice/services/validation/types.d.ts +6 -0
  113. package/lib/esm/languageservice/services/validation/types.js +6 -0
  114. package/lib/esm/languageservice/services/validation/types.js.map +1 -0
  115. package/lib/esm/languageservice/services/validation/unused-anchors.d.ts +8 -0
  116. package/lib/esm/languageservice/services/validation/unused-anchors.js +91 -0
  117. package/lib/esm/languageservice/services/validation/unused-anchors.js.map +1 -0
  118. package/lib/esm/languageservice/services/validation/yaml-style.d.ts +12 -0
  119. package/lib/esm/languageservice/services/validation/yaml-style.js +28 -0
  120. package/lib/esm/languageservice/services/validation/yaml-style.js.map +1 -0
  121. package/lib/esm/languageservice/services/yamlCodeActions.d.ts +25 -0
  122. package/lib/esm/languageservice/services/yamlCodeActions.js +342 -0
  123. package/lib/esm/languageservice/services/yamlCodeActions.js.map +1 -0
  124. package/lib/esm/languageservice/services/yamlCodeLens.d.ts +11 -0
  125. package/lib/esm/languageservice/services/yamlCodeLens.js +46 -0
  126. package/lib/esm/languageservice/services/yamlCodeLens.js.map +1 -0
  127. package/lib/esm/languageservice/services/yamlCommands.d.ts +3 -0
  128. package/lib/esm/languageservice/services/yamlCommands.js +46 -0
  129. package/lib/esm/languageservice/services/yamlCommands.js.map +1 -0
  130. package/lib/esm/languageservice/services/yamlCompletion.d.ts +77 -0
  131. package/lib/esm/languageservice/services/yamlCompletion.js +1501 -0
  132. package/lib/esm/languageservice/services/yamlCompletion.js.map +1 -0
  133. package/lib/esm/languageservice/services/yamlDefinition.d.ts +9 -0
  134. package/lib/esm/languageservice/services/yamlDefinition.js +37 -0
  135. package/lib/esm/languageservice/services/yamlDefinition.js.map +1 -0
  136. package/lib/esm/languageservice/services/yamlFolding.d.ts +4 -0
  137. package/lib/esm/languageservice/services/yamlFolding.js +62 -0
  138. package/lib/esm/languageservice/services/yamlFolding.js.map +1 -0
  139. package/lib/esm/languageservice/services/yamlFormatter.d.ts +8 -0
  140. package/lib/esm/languageservice/services/yamlFormatter.js +46 -0
  141. package/lib/esm/languageservice/services/yamlFormatter.js.map +1 -0
  142. package/lib/esm/languageservice/services/yamlHover.d.ts +47 -0
  143. package/lib/esm/languageservice/services/yamlHover.js +366 -0
  144. package/lib/esm/languageservice/services/yamlHover.js.map +1 -0
  145. package/lib/esm/languageservice/services/yamlLinks.d.ts +8 -0
  146. package/lib/esm/languageservice/services/yamlLinks.js +27 -0
  147. package/lib/esm/languageservice/services/yamlLinks.js.map +1 -0
  148. package/lib/esm/languageservice/services/yamlOnTypeFormatting.d.ts +4 -0
  149. package/lib/esm/languageservice/services/yamlOnTypeFormatting.js +43 -0
  150. package/lib/esm/languageservice/services/yamlOnTypeFormatting.js.map +1 -0
  151. package/lib/esm/languageservice/services/yamlRename.d.ts +18 -0
  152. package/lib/esm/languageservice/services/yamlRename.js +184 -0
  153. package/lib/esm/languageservice/services/yamlRename.js.map +1 -0
  154. package/lib/esm/languageservice/services/yamlSchemaService.d.ts +99 -0
  155. package/lib/esm/languageservice/services/yamlSchemaService.js +1110 -0
  156. package/lib/esm/languageservice/services/yamlSchemaService.js.map +1 -0
  157. package/lib/esm/languageservice/services/yamlSelectionRanges.d.ts +3 -0
  158. package/lib/esm/languageservice/services/yamlSelectionRanges.js +130 -0
  159. package/lib/esm/languageservice/services/yamlSelectionRanges.js.map +1 -0
  160. package/lib/esm/languageservice/services/yamlValidation.d.ts +26 -0
  161. package/lib/esm/languageservice/services/yamlValidation.js +135 -0
  162. package/lib/esm/languageservice/services/yamlValidation.js.map +1 -0
  163. package/lib/esm/languageservice/telemetry.d.ts +16 -0
  164. package/lib/esm/languageservice/telemetry.js +6 -0
  165. package/lib/esm/languageservice/telemetry.js.map +1 -0
  166. package/lib/esm/languageservice/utils/arrUtils.d.ts +6 -0
  167. package/lib/esm/languageservice/utils/arrUtils.js +81 -0
  168. package/lib/esm/languageservice/utils/arrUtils.js.map +1 -0
  169. package/lib/esm/languageservice/utils/block-string-rewriter.d.ts +8 -0
  170. package/lib/esm/languageservice/utils/block-string-rewriter.js +215 -0
  171. package/lib/esm/languageservice/utils/block-string-rewriter.js.map +1 -0
  172. package/lib/esm/languageservice/utils/charCode.d.ts +415 -0
  173. package/lib/esm/languageservice/utils/charCode.js +6 -0
  174. package/lib/esm/languageservice/utils/charCode.js.map +1 -0
  175. package/lib/esm/languageservice/utils/diagnostic-filter.d.ts +50 -0
  176. package/lib/esm/languageservice/utils/diagnostic-filter.js +82 -0
  177. package/lib/esm/languageservice/utils/diagnostic-filter.js.map +1 -0
  178. package/lib/esm/languageservice/utils/documentPositionCalculator.d.ts +5 -0
  179. package/lib/esm/languageservice/utils/documentPositionCalculator.js +56 -0
  180. package/lib/esm/languageservice/utils/documentPositionCalculator.js.map +1 -0
  181. package/lib/esm/languageservice/utils/filePatternAssociation.d.ts +8 -0
  182. package/lib/esm/languageservice/utils/filePatternAssociation.js +23 -0
  183. package/lib/esm/languageservice/utils/filePatternAssociation.js.map +1 -0
  184. package/lib/esm/languageservice/utils/flow-style-rewriter.d.ts +6 -0
  185. package/lib/esm/languageservice/utils/flow-style-rewriter.js +53 -0
  186. package/lib/esm/languageservice/utils/flow-style-rewriter.js.map +1 -0
  187. package/lib/esm/languageservice/utils/indentationGuesser.d.ts +15 -0
  188. package/lib/esm/languageservice/utils/indentationGuesser.js +176 -0
  189. package/lib/esm/languageservice/utils/indentationGuesser.js.map +1 -0
  190. package/lib/esm/languageservice/utils/json.d.ts +11 -0
  191. package/lib/esm/languageservice/utils/json.js +79 -0
  192. package/lib/esm/languageservice/utils/json.js.map +1 -0
  193. package/lib/esm/languageservice/utils/math.d.ts +1 -0
  194. package/lib/esm/languageservice/utils/math.js +9 -0
  195. package/lib/esm/languageservice/utils/math.js.map +1 -0
  196. package/lib/esm/languageservice/utils/objects.d.ts +16 -0
  197. package/lib/esm/languageservice/utils/objects.js +92 -0
  198. package/lib/esm/languageservice/utils/objects.js.map +1 -0
  199. package/lib/esm/languageservice/utils/parseUtils.d.ts +17 -0
  200. package/lib/esm/languageservice/utils/parseUtils.js +2 -0
  201. package/lib/esm/languageservice/utils/parseUtils.js.map +1 -0
  202. package/lib/esm/languageservice/utils/paths.d.ts +5 -0
  203. package/lib/esm/languageservice/utils/paths.js +42 -0
  204. package/lib/esm/languageservice/utils/paths.js.map +1 -0
  205. package/lib/esm/languageservice/utils/schemaUrls.d.ts +14 -0
  206. package/lib/esm/languageservice/utils/schemaUrls.js +59 -0
  207. package/lib/esm/languageservice/utils/schemaUrls.js.map +1 -0
  208. package/lib/esm/languageservice/utils/schemaUtils.d.ts +19 -0
  209. package/lib/esm/languageservice/utils/schemaUtils.js +62 -0
  210. package/lib/esm/languageservice/utils/schemaUtils.js.map +1 -0
  211. package/lib/esm/languageservice/utils/strings.d.ts +10 -0
  212. package/lib/esm/languageservice/utils/strings.js +79 -0
  213. package/lib/esm/languageservice/utils/strings.js.map +1 -0
  214. package/lib/esm/languageservice/utils/textBuffer.d.ts +12 -0
  215. package/lib/esm/languageservice/utils/textBuffer.js +45 -0
  216. package/lib/esm/languageservice/utils/textBuffer.js.map +1 -0
  217. package/lib/esm/languageservice/utils/yamlAstUtils.d.ts +13 -0
  218. package/lib/esm/languageservice/utils/yamlAstUtils.js +108 -0
  219. package/lib/esm/languageservice/utils/yamlAstUtils.js.map +1 -0
  220. package/lib/esm/languageservice/utils/yamlScalar.d.ts +1 -0
  221. package/lib/esm/languageservice/utils/yamlScalar.js +69 -0
  222. package/lib/esm/languageservice/utils/yamlScalar.js.map +1 -0
  223. package/lib/esm/languageservice/yamlLanguageService.d.ts +135 -0
  224. package/lib/esm/languageservice/yamlLanguageService.js +101 -0
  225. package/lib/esm/languageservice/yamlLanguageService.js.map +1 -0
  226. package/lib/esm/languageservice/yamlTypes.d.ts +18 -0
  227. package/lib/esm/languageservice/yamlTypes.js +6 -0
  228. package/lib/esm/languageservice/yamlTypes.js.map +1 -0
  229. package/lib/esm/nodeTranslationSetup.d.ts +9 -0
  230. package/lib/esm/nodeTranslationSetup.js +34 -0
  231. package/lib/esm/nodeTranslationSetup.js.map +1 -0
  232. package/lib/esm/requestTypes.d.ts +63 -0
  233. package/lib/esm/requestTypes.js +46 -0
  234. package/lib/esm/requestTypes.js.map +1 -0
  235. package/lib/esm/server.d.ts +1 -0
  236. package/lib/esm/server.js +55 -0
  237. package/lib/esm/server.js.map +1 -0
  238. package/lib/esm/webworker/yamlServerMain.d.ts +1 -0
  239. package/lib/esm/webworker/yamlServerMain.js +40 -0
  240. package/lib/esm/webworker/yamlServerMain.js.map +1 -0
  241. package/lib/esm/yamlServerInit.d.ts +23 -0
  242. package/lib/esm/yamlServerInit.js +123 -0
  243. package/lib/esm/yamlServerInit.js.map +1 -0
  244. package/lib/esm/yamlSettings.d.ts +112 -0
  245. package/lib/esm/yamlSettings.js +69 -0
  246. package/lib/esm/yamlSettings.js.map +1 -0
  247. package/lib/umd/commands.d.ts +3 -0
  248. package/lib/umd/commands.js +22 -0
  249. package/lib/umd/commands.js.map +1 -0
  250. package/lib/umd/index.d.ts +3 -0
  251. package/lib/umd/index.js +32 -0
  252. package/lib/umd/index.js.map +1 -0
  253. package/lib/umd/languageserver/commandExecutor.d.ts +10 -0
  254. package/lib/umd/languageserver/commandExecutor.js +35 -0
  255. package/lib/umd/languageserver/commandExecutor.js.map +1 -0
  256. package/lib/umd/languageserver/handlers/languageHandlers.d.ts +61 -0
  257. package/lib/umd/languageserver/handlers/languageHandlers.js +250 -0
  258. package/lib/umd/languageserver/handlers/languageHandlers.js.map +1 -0
  259. package/lib/umd/languageserver/handlers/notificationHandlers.d.ts +29 -0
  260. package/lib/umd/languageserver/handlers/notificationHandlers.js +60 -0
  261. package/lib/umd/languageserver/handlers/notificationHandlers.js.map +1 -0
  262. package/lib/umd/languageserver/handlers/requestHandlers.d.ts +9 -0
  263. package/lib/umd/languageserver/handlers/requestHandlers.js +37 -0
  264. package/lib/umd/languageserver/handlers/requestHandlers.js.map +1 -0
  265. package/lib/umd/languageserver/handlers/schemaSelectionHandlers.d.ts +13 -0
  266. package/lib/umd/languageserver/handlers/schemaSelectionHandlers.js +86 -0
  267. package/lib/umd/languageserver/handlers/schemaSelectionHandlers.js.map +1 -0
  268. package/lib/umd/languageserver/handlers/settingsHandlers.d.ts +42 -0
  269. package/lib/umd/languageserver/handlers/settingsHandlers.js +330 -0
  270. package/lib/umd/languageserver/handlers/settingsHandlers.js.map +1 -0
  271. package/lib/umd/languageserver/handlers/validationHandlers.d.ts +15 -0
  272. package/lib/umd/languageserver/handlers/validationHandlers.js +122 -0
  273. package/lib/umd/languageserver/handlers/validationHandlers.js.map +1 -0
  274. package/lib/umd/languageserver/handlers/workspaceHandlers.d.ts +9 -0
  275. package/lib/umd/languageserver/handlers/workspaceHandlers.js +31 -0
  276. package/lib/umd/languageserver/handlers/workspaceHandlers.js.map +1 -0
  277. package/lib/umd/languageserver/telemetry.d.ts +9 -0
  278. package/lib/umd/languageserver/telemetry.js +34 -0
  279. package/lib/umd/languageserver/telemetry.js.map +1 -0
  280. package/lib/umd/languageservice/jsonASTTypes.d.ts +49 -0
  281. package/lib/umd/languageservice/jsonASTTypes.js +17 -0
  282. package/lib/umd/languageservice/jsonASTTypes.js.map +1 -0
  283. package/lib/umd/languageservice/jsonSchema.d.ts +103 -0
  284. package/lib/umd/languageservice/jsonSchema.js +25 -0
  285. package/lib/umd/languageservice/jsonSchema.js.map +1 -0
  286. package/lib/umd/languageservice/parser/ast-converter.d.ts +11 -0
  287. package/lib/umd/languageservice/parser/ast-converter.js +191 -0
  288. package/lib/umd/languageservice/parser/ast-converter.js.map +1 -0
  289. package/lib/umd/languageservice/parser/astNodeUtils.d.ts +4 -0
  290. package/lib/umd/languageservice/parser/astNodeUtils.js +64 -0
  291. package/lib/umd/languageservice/parser/astNodeUtils.js.map +1 -0
  292. package/lib/umd/languageservice/parser/custom-tag-provider.d.ts +7 -0
  293. package/lib/umd/languageservice/parser/custom-tag-provider.js +72 -0
  294. package/lib/umd/languageservice/parser/custom-tag-provider.js.map +1 -0
  295. package/lib/umd/languageservice/parser/isKubernetes.d.ts +4 -0
  296. package/lib/umd/languageservice/parser/isKubernetes.js +32 -0
  297. package/lib/umd/languageservice/parser/isKubernetes.js.map +1 -0
  298. package/lib/umd/languageservice/parser/jsonDocument.d.ts +83 -0
  299. package/lib/umd/languageservice/parser/jsonDocument.js +193 -0
  300. package/lib/umd/languageservice/parser/jsonDocument.js.map +1 -0
  301. package/lib/umd/languageservice/parser/scalar-type.d.ts +8 -0
  302. package/lib/umd/languageservice/parser/scalar-type.js +31 -0
  303. package/lib/umd/languageservice/parser/scalar-type.js.map +1 -0
  304. package/lib/umd/languageservice/parser/schemaValidation/baseValidator.d.ts +124 -0
  305. package/lib/umd/languageservice/parser/schemaValidation/baseValidator.js +1270 -0
  306. package/lib/umd/languageservice/parser/schemaValidation/baseValidator.js.map +1 -0
  307. package/lib/umd/languageservice/parser/schemaValidation/draft04Validator.d.ts +17 -0
  308. package/lib/umd/languageservice/parser/schemaValidation/draft04Validator.js +44 -0
  309. package/lib/umd/languageservice/parser/schemaValidation/draft04Validator.js.map +1 -0
  310. package/lib/umd/languageservice/parser/schemaValidation/draft07Validator.d.ts +15 -0
  311. package/lib/umd/languageservice/parser/schemaValidation/draft07Validator.js +42 -0
  312. package/lib/umd/languageservice/parser/schemaValidation/draft07Validator.js.map +1 -0
  313. package/lib/umd/languageservice/parser/schemaValidation/draft2019Validator.d.ts +28 -0
  314. package/lib/umd/languageservice/parser/schemaValidation/draft2019Validator.js +238 -0
  315. package/lib/umd/languageservice/parser/schemaValidation/draft2019Validator.js.map +1 -0
  316. package/lib/umd/languageservice/parser/schemaValidation/draft2020Validator.d.ts +17 -0
  317. package/lib/umd/languageservice/parser/schemaValidation/draft2020Validator.js +140 -0
  318. package/lib/umd/languageservice/parser/schemaValidation/draft2020Validator.js.map +1 -0
  319. package/lib/umd/languageservice/parser/schemaValidation/validatorFactory.d.ts +3 -0
  320. package/lib/umd/languageservice/parser/schemaValidation/validatorFactory.js +38 -0
  321. package/lib/umd/languageservice/parser/schemaValidation/validatorFactory.js.map +1 -0
  322. package/lib/umd/languageservice/parser/yaml-documents.d.ts +71 -0
  323. package/lib/umd/languageservice/parser/yaml-documents.js +274 -0
  324. package/lib/umd/languageservice/parser/yaml-documents.js.map +1 -0
  325. package/lib/umd/languageservice/parser/yamlParser07.d.ts +15 -0
  326. package/lib/umd/languageservice/parser/yamlParser07.js +65 -0
  327. package/lib/umd/languageservice/parser/yamlParser07.js.map +1 -0
  328. package/lib/umd/languageservice/services/crdUtil.d.ts +23 -0
  329. package/lib/umd/languageservice/services/crdUtil.js +89 -0
  330. package/lib/umd/languageservice/services/crdUtil.js.map +1 -0
  331. package/lib/umd/languageservice/services/documentSymbols.d.ts +12 -0
  332. package/lib/umd/languageservice/services/documentSymbols.js +81 -0
  333. package/lib/umd/languageservice/services/documentSymbols.js.map +1 -0
  334. package/lib/umd/languageservice/services/modelineUtil.d.ts +9 -0
  335. package/lib/umd/languageservice/services/modelineUtil.js +44 -0
  336. package/lib/umd/languageservice/services/modelineUtil.js.map +1 -0
  337. package/lib/umd/languageservice/services/schemaRequestHandler.d.ts +12 -0
  338. package/lib/umd/languageservice/services/schemaRequestHandler.js +98 -0
  339. package/lib/umd/languageservice/services/schemaRequestHandler.js.map +1 -0
  340. package/lib/umd/languageservice/services/validation/map-key-order.d.ts +7 -0
  341. package/lib/umd/languageservice/services/validation/map-key-order.js +49 -0
  342. package/lib/umd/languageservice/services/validation/map-key-order.js.map +1 -0
  343. package/lib/umd/languageservice/services/validation/types.d.ts +6 -0
  344. package/lib/umd/languageservice/services/validation/types.js +17 -0
  345. package/lib/umd/languageservice/services/validation/types.js.map +1 -0
  346. package/lib/umd/languageservice/services/validation/unused-anchors.d.ts +8 -0
  347. package/lib/umd/languageservice/services/validation/unused-anchors.js +105 -0
  348. package/lib/umd/languageservice/services/validation/unused-anchors.js.map +1 -0
  349. package/lib/umd/languageservice/services/validation/yaml-style.d.ts +12 -0
  350. package/lib/umd/languageservice/services/validation/yaml-style.js +42 -0
  351. package/lib/umd/languageservice/services/validation/yaml-style.js.map +1 -0
  352. package/lib/umd/languageservice/services/yamlCodeActions.d.ts +25 -0
  353. package/lib/umd/languageservice/services/yamlCodeActions.js +356 -0
  354. package/lib/umd/languageservice/services/yamlCodeActions.js.map +1 -0
  355. package/lib/umd/languageservice/services/yamlCodeLens.d.ts +11 -0
  356. package/lib/umd/languageservice/services/yamlCodeLens.js +60 -0
  357. package/lib/umd/languageservice/services/yamlCodeLens.js.map +1 -0
  358. package/lib/umd/languageservice/services/yamlCommands.d.ts +3 -0
  359. package/lib/umd/languageservice/services/yamlCommands.js +60 -0
  360. package/lib/umd/languageservice/services/yamlCommands.js.map +1 -0
  361. package/lib/umd/languageservice/services/yamlCompletion.d.ts +77 -0
  362. package/lib/umd/languageservice/services/yamlCompletion.js +1515 -0
  363. package/lib/umd/languageservice/services/yamlCompletion.js.map +1 -0
  364. package/lib/umd/languageservice/services/yamlDefinition.d.ts +9 -0
  365. package/lib/umd/languageservice/services/yamlDefinition.js +51 -0
  366. package/lib/umd/languageservice/services/yamlDefinition.js.map +1 -0
  367. package/lib/umd/languageservice/services/yamlFolding.d.ts +4 -0
  368. package/lib/umd/languageservice/services/yamlFolding.js +76 -0
  369. package/lib/umd/languageservice/services/yamlFolding.js.map +1 -0
  370. package/lib/umd/languageservice/services/yamlFormatter.d.ts +8 -0
  371. package/lib/umd/languageservice/services/yamlFormatter.js +60 -0
  372. package/lib/umd/languageservice/services/yamlFormatter.js.map +1 -0
  373. package/lib/umd/languageservice/services/yamlHover.d.ts +47 -0
  374. package/lib/umd/languageservice/services/yamlHover.js +380 -0
  375. package/lib/umd/languageservice/services/yamlHover.js.map +1 -0
  376. package/lib/umd/languageservice/services/yamlLinks.d.ts +8 -0
  377. package/lib/umd/languageservice/services/yamlLinks.js +41 -0
  378. package/lib/umd/languageservice/services/yamlLinks.js.map +1 -0
  379. package/lib/umd/languageservice/services/yamlOnTypeFormatting.d.ts +4 -0
  380. package/lib/umd/languageservice/services/yamlOnTypeFormatting.js +57 -0
  381. package/lib/umd/languageservice/services/yamlOnTypeFormatting.js.map +1 -0
  382. package/lib/umd/languageservice/services/yamlRename.d.ts +18 -0
  383. package/lib/umd/languageservice/services/yamlRename.js +198 -0
  384. package/lib/umd/languageservice/services/yamlRename.js.map +1 -0
  385. package/lib/umd/languageservice/services/yamlSchemaService.d.ts +99 -0
  386. package/lib/umd/languageservice/services/yamlSchemaService.js +1124 -0
  387. package/lib/umd/languageservice/services/yamlSchemaService.js.map +1 -0
  388. package/lib/umd/languageservice/services/yamlSelectionRanges.d.ts +3 -0
  389. package/lib/umd/languageservice/services/yamlSelectionRanges.js +144 -0
  390. package/lib/umd/languageservice/services/yamlSelectionRanges.js.map +1 -0
  391. package/lib/umd/languageservice/services/yamlValidation.d.ts +26 -0
  392. package/lib/umd/languageservice/services/yamlValidation.js +150 -0
  393. package/lib/umd/languageservice/services/yamlValidation.js.map +1 -0
  394. package/lib/umd/languageservice/telemetry.d.ts +16 -0
  395. package/lib/umd/languageservice/telemetry.js +17 -0
  396. package/lib/umd/languageservice/telemetry.js.map +1 -0
  397. package/lib/umd/languageservice/utils/arrUtils.d.ts +6 -0
  398. package/lib/umd/languageservice/utils/arrUtils.js +99 -0
  399. package/lib/umd/languageservice/utils/arrUtils.js.map +1 -0
  400. package/lib/umd/languageservice/utils/block-string-rewriter.d.ts +8 -0
  401. package/lib/umd/languageservice/utils/block-string-rewriter.js +229 -0
  402. package/lib/umd/languageservice/utils/block-string-rewriter.js.map +1 -0
  403. package/lib/umd/languageservice/utils/charCode.d.ts +415 -0
  404. package/lib/umd/languageservice/utils/charCode.js +17 -0
  405. package/lib/umd/languageservice/utils/charCode.js.map +1 -0
  406. package/lib/umd/languageservice/utils/diagnostic-filter.d.ts +50 -0
  407. package/lib/umd/languageservice/utils/diagnostic-filter.js +98 -0
  408. package/lib/umd/languageservice/utils/diagnostic-filter.js.map +1 -0
  409. package/lib/umd/languageservice/utils/documentPositionCalculator.d.ts +5 -0
  410. package/lib/umd/languageservice/utils/documentPositionCalculator.js +73 -0
  411. package/lib/umd/languageservice/utils/documentPositionCalculator.js.map +1 -0
  412. package/lib/umd/languageservice/utils/filePatternAssociation.d.ts +8 -0
  413. package/lib/umd/languageservice/utils/filePatternAssociation.js +37 -0
  414. package/lib/umd/languageservice/utils/filePatternAssociation.js.map +1 -0
  415. package/lib/umd/languageservice/utils/flow-style-rewriter.d.ts +6 -0
  416. package/lib/umd/languageservice/utils/flow-style-rewriter.js +67 -0
  417. package/lib/umd/languageservice/utils/flow-style-rewriter.js.map +1 -0
  418. package/lib/umd/languageservice/utils/indentationGuesser.d.ts +15 -0
  419. package/lib/umd/languageservice/utils/indentationGuesser.js +190 -0
  420. package/lib/umd/languageservice/utils/indentationGuesser.js.map +1 -0
  421. package/lib/umd/languageservice/utils/json.d.ts +11 -0
  422. package/lib/umd/languageservice/utils/json.js +93 -0
  423. package/lib/umd/languageservice/utils/json.js.map +1 -0
  424. package/lib/umd/languageservice/utils/math.d.ts +1 -0
  425. package/lib/umd/languageservice/utils/math.js +23 -0
  426. package/lib/umd/languageservice/utils/math.js.map +1 -0
  427. package/lib/umd/languageservice/utils/objects.d.ts +16 -0
  428. package/lib/umd/languageservice/utils/objects.js +112 -0
  429. package/lib/umd/languageservice/utils/objects.js.map +1 -0
  430. package/lib/umd/languageservice/utils/parseUtils.d.ts +17 -0
  431. package/lib/umd/languageservice/utils/parseUtils.js +15 -0
  432. package/lib/umd/languageservice/utils/parseUtils.js.map +1 -0
  433. package/lib/umd/languageservice/utils/paths.d.ts +5 -0
  434. package/lib/umd/languageservice/utils/paths.js +58 -0
  435. package/lib/umd/languageservice/utils/paths.js.map +1 -0
  436. package/lib/umd/languageservice/utils/schemaUrls.d.ts +14 -0
  437. package/lib/umd/languageservice/utils/schemaUrls.js +74 -0
  438. package/lib/umd/languageservice/utils/schemaUrls.js.map +1 -0
  439. package/lib/umd/languageservice/utils/schemaUtils.d.ts +19 -0
  440. package/lib/umd/languageservice/utils/schemaUtils.js +80 -0
  441. package/lib/umd/languageservice/utils/schemaUtils.js.map +1 -0
  442. package/lib/umd/languageservice/utils/strings.d.ts +10 -0
  443. package/lib/umd/languageservice/utils/strings.js +99 -0
  444. package/lib/umd/languageservice/utils/strings.js.map +1 -0
  445. package/lib/umd/languageservice/utils/textBuffer.d.ts +12 -0
  446. package/lib/umd/languageservice/utils/textBuffer.js +59 -0
  447. package/lib/umd/languageservice/utils/textBuffer.js.map +1 -0
  448. package/lib/umd/languageservice/utils/yamlAstUtils.d.ts +13 -0
  449. package/lib/umd/languageservice/utils/yamlAstUtils.js +126 -0
  450. package/lib/umd/languageservice/utils/yamlAstUtils.js.map +1 -0
  451. package/lib/umd/languageservice/utils/yamlScalar.d.ts +1 -0
  452. package/lib/umd/languageservice/utils/yamlScalar.js +83 -0
  453. package/lib/umd/languageservice/utils/yamlScalar.js.map +1 -0
  454. package/lib/umd/languageservice/yamlLanguageService.d.ts +135 -0
  455. package/lib/umd/languageservice/yamlLanguageService.js +115 -0
  456. package/lib/umd/languageservice/yamlLanguageService.js.map +1 -0
  457. package/lib/umd/languageservice/yamlTypes.d.ts +18 -0
  458. package/lib/umd/languageservice/yamlTypes.js +17 -0
  459. package/lib/umd/languageservice/yamlTypes.js.map +1 -0
  460. package/lib/umd/nodeTranslationSetup.d.ts +9 -0
  461. package/lib/umd/nodeTranslationSetup.js +48 -0
  462. package/lib/umd/nodeTranslationSetup.js.map +1 -0
  463. package/lib/umd/requestTypes.d.ts +63 -0
  464. package/lib/umd/requestTypes.js +59 -0
  465. package/lib/umd/requestTypes.js.map +1 -0
  466. package/lib/umd/server.d.ts +1 -0
  467. package/lib/umd/server.js +67 -0
  468. package/lib/umd/server.js.map +1 -0
  469. package/lib/umd/webworker/yamlServerMain.d.ts +1 -0
  470. package/lib/umd/webworker/yamlServerMain.js +52 -0
  471. package/lib/umd/webworker/yamlServerMain.js.map +1 -0
  472. package/lib/umd/yamlServerInit.d.ts +23 -0
  473. package/lib/umd/yamlServerInit.js +137 -0
  474. package/lib/umd/yamlServerInit.js.map +1 -0
  475. package/lib/umd/yamlSettings.d.ts +112 -0
  476. package/lib/umd/yamlSettings.js +84 -0
  477. package/lib/umd/yamlSettings.js.map +1 -0
  478. package/out/server/src/commands.d.ts +3 -0
  479. package/out/server/src/commands.js +12 -0
  480. package/out/server/src/commands.js.map +1 -0
  481. package/out/server/src/index.d.ts +3 -0
  482. package/out/server/src/index.js +22 -0
  483. package/out/server/src/index.js.map +1 -0
  484. package/out/server/src/languageserver/commandExecutor.d.ts +10 -0
  485. package/out/server/src/languageserver/commandExecutor.js +25 -0
  486. package/out/server/src/languageserver/commandExecutor.js.map +1 -0
  487. package/out/server/src/languageserver/handlers/languageHandlers.d.ts +61 -0
  488. package/out/server/src/languageserver/handlers/languageHandlers.js +240 -0
  489. package/out/server/src/languageserver/handlers/languageHandlers.js.map +1 -0
  490. package/out/server/src/languageserver/handlers/notificationHandlers.d.ts +29 -0
  491. package/out/server/src/languageserver/handlers/notificationHandlers.js +50 -0
  492. package/out/server/src/languageserver/handlers/notificationHandlers.js.map +1 -0
  493. package/out/server/src/languageserver/handlers/requestHandlers.d.ts +9 -0
  494. package/out/server/src/languageserver/handlers/requestHandlers.js +27 -0
  495. package/out/server/src/languageserver/handlers/requestHandlers.js.map +1 -0
  496. package/out/server/src/languageserver/handlers/schemaSelectionHandlers.d.ts +13 -0
  497. package/out/server/src/languageserver/handlers/schemaSelectionHandlers.js +76 -0
  498. package/out/server/src/languageserver/handlers/schemaSelectionHandlers.js.map +1 -0
  499. package/out/server/src/languageserver/handlers/settingsHandlers.d.ts +42 -0
  500. package/out/server/src/languageserver/handlers/settingsHandlers.js +320 -0
  501. package/out/server/src/languageserver/handlers/settingsHandlers.js.map +1 -0
  502. package/out/server/src/languageserver/handlers/validationHandlers.d.ts +15 -0
  503. package/out/server/src/languageserver/handlers/validationHandlers.js +112 -0
  504. package/out/server/src/languageserver/handlers/validationHandlers.js.map +1 -0
  505. package/out/server/src/languageserver/handlers/workspaceHandlers.d.ts +9 -0
  506. package/out/server/src/languageserver/handlers/workspaceHandlers.js +21 -0
  507. package/out/server/src/languageserver/handlers/workspaceHandlers.js.map +1 -0
  508. package/out/server/src/languageserver/telemetry.d.ts +9 -0
  509. package/out/server/src/languageserver/telemetry.js +24 -0
  510. package/out/server/src/languageserver/telemetry.js.map +1 -0
  511. package/out/server/src/languageservice/jsonASTTypes.d.ts +49 -0
  512. package/out/server/src/languageservice/jsonASTTypes.js +7 -0
  513. package/out/server/src/languageservice/jsonASTTypes.js.map +1 -0
  514. package/out/server/src/languageservice/jsonSchema.d.ts +103 -0
  515. package/out/server/src/languageservice/jsonSchema.js +15 -0
  516. package/out/server/src/languageservice/jsonSchema.js.map +1 -0
  517. package/out/server/src/languageservice/parser/ast-converter.d.ts +11 -0
  518. package/out/server/src/languageservice/parser/ast-converter.js +181 -0
  519. package/out/server/src/languageservice/parser/ast-converter.js.map +1 -0
  520. package/out/server/src/languageservice/parser/astNodeUtils.d.ts +4 -0
  521. package/out/server/src/languageservice/parser/astNodeUtils.js +54 -0
  522. package/out/server/src/languageservice/parser/astNodeUtils.js.map +1 -0
  523. package/out/server/src/languageservice/parser/custom-tag-provider.d.ts +7 -0
  524. package/out/server/src/languageservice/parser/custom-tag-provider.js +62 -0
  525. package/out/server/src/languageservice/parser/custom-tag-provider.js.map +1 -0
  526. package/out/server/src/languageservice/parser/isKubernetes.d.ts +4 -0
  527. package/out/server/src/languageservice/parser/isKubernetes.js +22 -0
  528. package/out/server/src/languageservice/parser/isKubernetes.js.map +1 -0
  529. package/out/server/src/languageservice/parser/jsonDocument.d.ts +83 -0
  530. package/out/server/src/languageservice/parser/jsonDocument.js +183 -0
  531. package/out/server/src/languageservice/parser/jsonDocument.js.map +1 -0
  532. package/out/server/src/languageservice/parser/scalar-type.d.ts +8 -0
  533. package/out/server/src/languageservice/parser/scalar-type.js +21 -0
  534. package/out/server/src/languageservice/parser/scalar-type.js.map +1 -0
  535. package/out/server/src/languageservice/parser/schemaValidation/baseValidator.d.ts +124 -0
  536. package/out/server/src/languageservice/parser/schemaValidation/baseValidator.js +1260 -0
  537. package/out/server/src/languageservice/parser/schemaValidation/baseValidator.js.map +1 -0
  538. package/out/server/src/languageservice/parser/schemaValidation/draft04Validator.d.ts +17 -0
  539. package/out/server/src/languageservice/parser/schemaValidation/draft04Validator.js +34 -0
  540. package/out/server/src/languageservice/parser/schemaValidation/draft04Validator.js.map +1 -0
  541. package/out/server/src/languageservice/parser/schemaValidation/draft07Validator.d.ts +15 -0
  542. package/out/server/src/languageservice/parser/schemaValidation/draft07Validator.js +32 -0
  543. package/out/server/src/languageservice/parser/schemaValidation/draft07Validator.js.map +1 -0
  544. package/out/server/src/languageservice/parser/schemaValidation/draft2019Validator.d.ts +28 -0
  545. package/out/server/src/languageservice/parser/schemaValidation/draft2019Validator.js +228 -0
  546. package/out/server/src/languageservice/parser/schemaValidation/draft2019Validator.js.map +1 -0
  547. package/out/server/src/languageservice/parser/schemaValidation/draft2020Validator.d.ts +17 -0
  548. package/out/server/src/languageservice/parser/schemaValidation/draft2020Validator.js +130 -0
  549. package/out/server/src/languageservice/parser/schemaValidation/draft2020Validator.js.map +1 -0
  550. package/out/server/src/languageservice/parser/schemaValidation/validatorFactory.d.ts +3 -0
  551. package/out/server/src/languageservice/parser/schemaValidation/validatorFactory.js +28 -0
  552. package/out/server/src/languageservice/parser/schemaValidation/validatorFactory.js.map +1 -0
  553. package/out/server/src/languageservice/parser/yaml-documents.d.ts +71 -0
  554. package/out/server/src/languageservice/parser/yaml-documents.js +264 -0
  555. package/out/server/src/languageservice/parser/yaml-documents.js.map +1 -0
  556. package/out/server/src/languageservice/parser/yamlParser07.d.ts +15 -0
  557. package/out/server/src/languageservice/parser/yamlParser07.js +55 -0
  558. package/out/server/src/languageservice/parser/yamlParser07.js.map +1 -0
  559. package/out/server/src/languageservice/services/crdUtil.d.ts +23 -0
  560. package/out/server/src/languageservice/services/crdUtil.js +79 -0
  561. package/out/server/src/languageservice/services/crdUtil.js.map +1 -0
  562. package/out/server/src/languageservice/services/documentSymbols.d.ts +12 -0
  563. package/out/server/src/languageservice/services/documentSymbols.js +71 -0
  564. package/out/server/src/languageservice/services/documentSymbols.js.map +1 -0
  565. package/out/server/src/languageservice/services/modelineUtil.d.ts +9 -0
  566. package/out/server/src/languageservice/services/modelineUtil.js +34 -0
  567. package/out/server/src/languageservice/services/modelineUtil.js.map +1 -0
  568. package/out/server/src/languageservice/services/schemaRequestHandler.d.ts +12 -0
  569. package/out/server/src/languageservice/services/schemaRequestHandler.js +88 -0
  570. package/out/server/src/languageservice/services/schemaRequestHandler.js.map +1 -0
  571. package/out/server/src/languageservice/services/validation/map-key-order.d.ts +7 -0
  572. package/out/server/src/languageservice/services/validation/map-key-order.js +39 -0
  573. package/out/server/src/languageservice/services/validation/map-key-order.js.map +1 -0
  574. package/out/server/src/languageservice/services/validation/types.d.ts +6 -0
  575. package/out/server/src/languageservice/services/validation/types.js +7 -0
  576. package/out/server/src/languageservice/services/validation/types.js.map +1 -0
  577. package/out/server/src/languageservice/services/validation/unused-anchors.d.ts +8 -0
  578. package/out/server/src/languageservice/services/validation/unused-anchors.js +95 -0
  579. package/out/server/src/languageservice/services/validation/unused-anchors.js.map +1 -0
  580. package/out/server/src/languageservice/services/validation/yaml-style.d.ts +12 -0
  581. package/out/server/src/languageservice/services/validation/yaml-style.js +32 -0
  582. package/out/server/src/languageservice/services/validation/yaml-style.js.map +1 -0
  583. package/out/server/src/languageservice/services/yamlCodeActions.d.ts +25 -0
  584. package/out/server/src/languageservice/services/yamlCodeActions.js +346 -0
  585. package/out/server/src/languageservice/services/yamlCodeActions.js.map +1 -0
  586. package/out/server/src/languageservice/services/yamlCodeLens.d.ts +11 -0
  587. package/out/server/src/languageservice/services/yamlCodeLens.js +50 -0
  588. package/out/server/src/languageservice/services/yamlCodeLens.js.map +1 -0
  589. package/out/server/src/languageservice/services/yamlCommands.d.ts +3 -0
  590. package/out/server/src/languageservice/services/yamlCommands.js +50 -0
  591. package/out/server/src/languageservice/services/yamlCommands.js.map +1 -0
  592. package/out/server/src/languageservice/services/yamlCompletion.d.ts +77 -0
  593. package/out/server/src/languageservice/services/yamlCompletion.js +1505 -0
  594. package/out/server/src/languageservice/services/yamlCompletion.js.map +1 -0
  595. package/out/server/src/languageservice/services/yamlDefinition.d.ts +9 -0
  596. package/out/server/src/languageservice/services/yamlDefinition.js +41 -0
  597. package/out/server/src/languageservice/services/yamlDefinition.js.map +1 -0
  598. package/out/server/src/languageservice/services/yamlFolding.d.ts +4 -0
  599. package/out/server/src/languageservice/services/yamlFolding.js +66 -0
  600. package/out/server/src/languageservice/services/yamlFolding.js.map +1 -0
  601. package/out/server/src/languageservice/services/yamlFormatter.d.ts +8 -0
  602. package/out/server/src/languageservice/services/yamlFormatter.js +50 -0
  603. package/out/server/src/languageservice/services/yamlFormatter.js.map +1 -0
  604. package/out/server/src/languageservice/services/yamlHover.d.ts +47 -0
  605. package/out/server/src/languageservice/services/yamlHover.js +370 -0
  606. package/out/server/src/languageservice/services/yamlHover.js.map +1 -0
  607. package/out/server/src/languageservice/services/yamlLinks.d.ts +8 -0
  608. package/out/server/src/languageservice/services/yamlLinks.js +31 -0
  609. package/out/server/src/languageservice/services/yamlLinks.js.map +1 -0
  610. package/out/server/src/languageservice/services/yamlOnTypeFormatting.d.ts +4 -0
  611. package/out/server/src/languageservice/services/yamlOnTypeFormatting.js +47 -0
  612. package/out/server/src/languageservice/services/yamlOnTypeFormatting.js.map +1 -0
  613. package/out/server/src/languageservice/services/yamlRename.d.ts +18 -0
  614. package/out/server/src/languageservice/services/yamlRename.js +188 -0
  615. package/out/server/src/languageservice/services/yamlRename.js.map +1 -0
  616. package/out/server/src/languageservice/services/yamlSchemaService.d.ts +99 -0
  617. package/out/server/src/languageservice/services/yamlSchemaService.js +1114 -0
  618. package/out/server/src/languageservice/services/yamlSchemaService.js.map +1 -0
  619. package/out/server/src/languageservice/services/yamlSelectionRanges.d.ts +3 -0
  620. package/out/server/src/languageservice/services/yamlSelectionRanges.js +134 -0
  621. package/out/server/src/languageservice/services/yamlSelectionRanges.js.map +1 -0
  622. package/out/server/src/languageservice/services/yamlValidation.d.ts +26 -0
  623. package/out/server/src/languageservice/services/yamlValidation.js +140 -0
  624. package/out/server/src/languageservice/services/yamlValidation.js.map +1 -0
  625. package/out/server/src/languageservice/telemetry.d.ts +16 -0
  626. package/out/server/src/languageservice/telemetry.js +7 -0
  627. package/out/server/src/languageservice/telemetry.js.map +1 -0
  628. package/out/server/src/languageservice/utils/arrUtils.d.ts +6 -0
  629. package/out/server/src/languageservice/utils/arrUtils.js +89 -0
  630. package/out/server/src/languageservice/utils/arrUtils.js.map +1 -0
  631. package/out/server/src/languageservice/utils/block-string-rewriter.d.ts +8 -0
  632. package/out/server/src/languageservice/utils/block-string-rewriter.js +219 -0
  633. package/out/server/src/languageservice/utils/block-string-rewriter.js.map +1 -0
  634. package/out/server/src/languageservice/utils/charCode.d.ts +415 -0
  635. package/out/server/src/languageservice/utils/charCode.js +7 -0
  636. package/out/server/src/languageservice/utils/charCode.js.map +1 -0
  637. package/out/server/src/languageservice/utils/diagnostic-filter.d.ts +50 -0
  638. package/out/server/src/languageservice/utils/diagnostic-filter.js +88 -0
  639. package/out/server/src/languageservice/utils/diagnostic-filter.js.map +1 -0
  640. package/out/server/src/languageservice/utils/documentPositionCalculator.d.ts +5 -0
  641. package/out/server/src/languageservice/utils/documentPositionCalculator.js +63 -0
  642. package/out/server/src/languageservice/utils/documentPositionCalculator.js.map +1 -0
  643. package/out/server/src/languageservice/utils/filePatternAssociation.d.ts +8 -0
  644. package/out/server/src/languageservice/utils/filePatternAssociation.js +27 -0
  645. package/out/server/src/languageservice/utils/filePatternAssociation.js.map +1 -0
  646. package/out/server/src/languageservice/utils/flow-style-rewriter.d.ts +6 -0
  647. package/out/server/src/languageservice/utils/flow-style-rewriter.js +57 -0
  648. package/out/server/src/languageservice/utils/flow-style-rewriter.js.map +1 -0
  649. package/out/server/src/languageservice/utils/indentationGuesser.d.ts +15 -0
  650. package/out/server/src/languageservice/utils/indentationGuesser.js +180 -0
  651. package/out/server/src/languageservice/utils/indentationGuesser.js.map +1 -0
  652. package/out/server/src/languageservice/utils/json.d.ts +11 -0
  653. package/out/server/src/languageservice/utils/json.js +83 -0
  654. package/out/server/src/languageservice/utils/json.js.map +1 -0
  655. package/out/server/src/languageservice/utils/math.d.ts +1 -0
  656. package/out/server/src/languageservice/utils/math.js +13 -0
  657. package/out/server/src/languageservice/utils/math.js.map +1 -0
  658. package/out/server/src/languageservice/utils/objects.d.ts +16 -0
  659. package/out/server/src/languageservice/utils/objects.js +102 -0
  660. package/out/server/src/languageservice/utils/objects.js.map +1 -0
  661. package/out/server/src/languageservice/utils/parseUtils.d.ts +17 -0
  662. package/out/server/src/languageservice/utils/parseUtils.js +5 -0
  663. package/out/server/src/languageservice/utils/parseUtils.js.map +1 -0
  664. package/out/server/src/languageservice/utils/paths.d.ts +5 -0
  665. package/out/server/src/languageservice/utils/paths.js +48 -0
  666. package/out/server/src/languageservice/utils/paths.js.map +1 -0
  667. package/out/server/src/languageservice/utils/schemaUrls.d.ts +14 -0
  668. package/out/server/src/languageservice/utils/schemaUrls.js +64 -0
  669. package/out/server/src/languageservice/utils/schemaUrls.js.map +1 -0
  670. package/out/server/src/languageservice/utils/schemaUtils.d.ts +19 -0
  671. package/out/server/src/languageservice/utils/schemaUtils.js +70 -0
  672. package/out/server/src/languageservice/utils/schemaUtils.js.map +1 -0
  673. package/out/server/src/languageservice/utils/strings.d.ts +10 -0
  674. package/out/server/src/languageservice/utils/strings.js +89 -0
  675. package/out/server/src/languageservice/utils/strings.js.map +1 -0
  676. package/out/server/src/languageservice/utils/textBuffer.d.ts +12 -0
  677. package/out/server/src/languageservice/utils/textBuffer.js +49 -0
  678. package/out/server/src/languageservice/utils/textBuffer.js.map +1 -0
  679. package/out/server/src/languageservice/utils/yamlAstUtils.d.ts +13 -0
  680. package/out/server/src/languageservice/utils/yamlAstUtils.js +116 -0
  681. package/out/server/src/languageservice/utils/yamlAstUtils.js.map +1 -0
  682. package/out/server/src/languageservice/utils/yamlScalar.d.ts +1 -0
  683. package/out/server/src/languageservice/utils/yamlScalar.js +73 -0
  684. package/out/server/src/languageservice/utils/yamlScalar.js.map +1 -0
  685. package/out/server/src/languageservice/yamlLanguageService.d.ts +135 -0
  686. package/out/server/src/languageservice/yamlLanguageService.js +105 -0
  687. package/out/server/src/languageservice/yamlLanguageService.js.map +1 -0
  688. package/out/server/src/languageservice/yamlTypes.d.ts +18 -0
  689. package/out/server/src/languageservice/yamlTypes.js +7 -0
  690. package/out/server/src/languageservice/yamlTypes.js.map +1 -0
  691. package/out/server/src/nodeTranslationSetup.d.ts +9 -0
  692. package/out/server/src/nodeTranslationSetup.js +38 -0
  693. package/out/server/src/nodeTranslationSetup.js.map +1 -0
  694. package/out/server/src/requestTypes.d.ts +63 -0
  695. package/out/server/src/requestTypes.js +49 -0
  696. package/out/server/src/requestTypes.js.map +1 -0
  697. package/out/server/src/server.d.ts +1 -0
  698. package/out/server/src/server.js +57 -0
  699. package/out/server/src/server.js.map +1 -0
  700. package/out/server/src/webworker/yamlServerMain.d.ts +1 -0
  701. package/out/server/src/webworker/yamlServerMain.js +42 -0
  702. package/out/server/src/webworker/yamlServerMain.js.map +1 -0
  703. package/out/server/src/yamlServerInit.d.ts +23 -0
  704. package/out/server/src/yamlServerInit.js +127 -0
  705. package/out/server/src/yamlServerInit.js.map +1 -0
  706. package/out/server/src/yamlSettings.d.ts +112 -0
  707. package/out/server/src/yamlSettings.js +74 -0
  708. package/out/server/src/yamlSettings.js.map +1 -0
  709. package/out/server/test/arrUtils.test.d.ts +1 -0
  710. package/out/server/test/arrUtils.test.js +60 -0
  711. package/out/server/test/arrUtils.test.js.map +1 -0
  712. package/out/server/test/astUtils.test.d.ts +1 -0
  713. package/out/server/test/astUtils.test.js +79 -0
  714. package/out/server/test/astUtils.test.js.map +1 -0
  715. package/out/server/test/autoCompletion.test.d.ts +1 -0
  716. package/out/server/test/autoCompletion.test.js +2832 -0
  717. package/out/server/test/autoCompletion.test.js.map +1 -0
  718. package/out/server/test/autoCompletionFix.test.d.ts +1 -0
  719. package/out/server/test/autoCompletionFix.test.js +1591 -0
  720. package/out/server/test/autoCompletionFix.test.js.map +1 -0
  721. package/out/server/test/bundlel10n.test.d.ts +1 -0
  722. package/out/server/test/bundlel10n.test.js +73 -0
  723. package/out/server/test/bundlel10n.test.js.map +1 -0
  724. package/out/server/test/code-action-schema.test.d.ts +1 -0
  725. package/out/server/test/code-action-schema.test.js +89 -0
  726. package/out/server/test/code-action-schema.test.js.map +1 -0
  727. package/out/server/test/customTags.test.d.ts +1 -0
  728. package/out/server/test/customTags.test.js +88 -0
  729. package/out/server/test/customTags.test.js.map +1 -0
  730. package/out/server/test/defaultSnippets.test.d.ts +1 -0
  731. package/out/server/test/defaultSnippets.test.js +384 -0
  732. package/out/server/test/defaultSnippets.test.js.map +1 -0
  733. package/out/server/test/diagnostic-filter.test.d.ts +1 -0
  734. package/out/server/test/diagnostic-filter.test.js +161 -0
  735. package/out/server/test/diagnostic-filter.test.js.map +1 -0
  736. package/out/server/test/documentPositionCalculator.test.d.ts +1 -0
  737. package/out/server/test/documentPositionCalculator.test.js +69 -0
  738. package/out/server/test/documentPositionCalculator.test.js.map +1 -0
  739. package/out/server/test/documentSymbols.test.d.ts +1 -0
  740. package/out/server/test/documentSymbols.test.js +267 -0
  741. package/out/server/test/documentSymbols.test.js.map +1 -0
  742. package/out/server/test/findLinks.test.d.ts +1 -0
  743. package/out/server/test/findLinks.test.js +58 -0
  744. package/out/server/test/findLinks.test.js.map +1 -0
  745. package/out/server/test/flow-style-rewriter.test.d.ts +1 -0
  746. package/out/server/test/flow-style-rewriter.test.js +79 -0
  747. package/out/server/test/flow-style-rewriter.test.js.map +1 -0
  748. package/out/server/test/formatter.test.d.ts +1 -0
  749. package/out/server/test/formatter.test.js +170 -0
  750. package/out/server/test/formatter.test.js.map +1 -0
  751. package/out/server/test/hover.test.d.ts +1 -0
  752. package/out/server/test/hover.test.js +1056 -0
  753. package/out/server/test/hover.test.js.map +1 -0
  754. package/out/server/test/integration.test.d.ts +1 -0
  755. package/out/server/test/integration.test.js +293 -0
  756. package/out/server/test/integration.test.js.map +1 -0
  757. package/out/server/test/invalid-metaschema.test.d.ts +1 -0
  758. package/out/server/test/invalid-metaschema.test.js +43 -0
  759. package/out/server/test/invalid-metaschema.test.js.map +1 -0
  760. package/out/server/test/jsonParser.test.d.ts +1 -0
  761. package/out/server/test/jsonParser.test.js +1682 -0
  762. package/out/server/test/jsonParser.test.js.map +1 -0
  763. package/out/server/test/multipleDocuments.test.d.ts +1 -0
  764. package/out/server/test/multipleDocuments.test.js +117 -0
  765. package/out/server/test/multipleDocuments.test.js.map +1 -0
  766. package/out/server/test/objects.test.d.ts +1 -0
  767. package/out/server/test/objects.test.js +110 -0
  768. package/out/server/test/objects.test.js.map +1 -0
  769. package/out/server/test/paths.test.d.ts +1 -0
  770. package/out/server/test/paths.test.js +223 -0
  771. package/out/server/test/paths.test.js.map +1 -0
  772. package/out/server/test/scalaruri.test.d.ts +1 -0
  773. package/out/server/test/scalaruri.test.js +363 -0
  774. package/out/server/test/scalaruri.test.js.map +1 -0
  775. package/out/server/test/schema.test.d.ts +1 -0
  776. package/out/server/test/schema.test.js +952 -0
  777. package/out/server/test/schema.test.js.map +1 -0
  778. package/out/server/test/schema2019Validation.test.d.ts +1 -0
  779. package/out/server/test/schema2019Validation.test.js +3630 -0
  780. package/out/server/test/schema2019Validation.test.js.map +1 -0
  781. package/out/server/test/schema2020Validation.test.d.ts +1 -0
  782. package/out/server/test/schema2020Validation.test.js +2037 -0
  783. package/out/server/test/schema2020Validation.test.js.map +1 -0
  784. package/out/server/test/schemaRequestHandler.test.d.ts +1 -0
  785. package/out/server/test/schemaRequestHandler.test.js +48 -0
  786. package/out/server/test/schemaRequestHandler.test.js.map +1 -0
  787. package/out/server/test/schemaSelectionHandlers.test.d.ts +1 -0
  788. package/out/server/test/schemaSelectionHandlers.test.js +99 -0
  789. package/out/server/test/schemaSelectionHandlers.test.js.map +1 -0
  790. package/out/server/test/schemaValidation.test.d.ts +1 -0
  791. package/out/server/test/schemaValidation.test.js +2269 -0
  792. package/out/server/test/schemaValidation.test.js.map +1 -0
  793. package/out/server/test/settingsHandlers.test.d.ts +1 -0
  794. package/out/server/test/settingsHandlers.test.js +299 -0
  795. package/out/server/test/settingsHandlers.test.js.map +1 -0
  796. package/out/server/test/strings.test.d.ts +1 -0
  797. package/out/server/test/strings.test.js +92 -0
  798. package/out/server/test/strings.test.js.map +1 -0
  799. package/out/server/test/telemetry.test.d.ts +1 -0
  800. package/out/server/test/telemetry.test.js +36 -0
  801. package/out/server/test/telemetry.test.js.map +1 -0
  802. package/out/server/test/textBuffer.test.d.ts +1 -0
  803. package/out/server/test/textBuffer.test.js +41 -0
  804. package/out/server/test/textBuffer.test.js.map +1 -0
  805. package/out/server/test/utils/errorMessages.d.ts +27 -0
  806. package/out/server/test/utils/errorMessages.js +38 -0
  807. package/out/server/test/utils/errorMessages.js.map +1 -0
  808. package/out/server/test/utils/serviceSetup.d.ts +17 -0
  809. package/out/server/test/utils/serviceSetup.js +74 -0
  810. package/out/server/test/utils/serviceSetup.js.map +1 -0
  811. package/out/server/test/utils/testHelper.d.ts +78 -0
  812. package/out/server/test/utils/testHelper.js +202 -0
  813. package/out/server/test/utils/testHelper.js.map +1 -0
  814. package/out/server/test/utils/testsTypes.d.ts +29 -0
  815. package/out/server/test/utils/testsTypes.js +61 -0
  816. package/out/server/test/utils/testsTypes.js.map +1 -0
  817. package/out/server/test/utils/verifyError.d.ts +8 -0
  818. package/out/server/test/utils/verifyError.js +82 -0
  819. package/out/server/test/utils/verifyError.js.map +1 -0
  820. package/out/server/test/yaml-documents.test.d.ts +1 -0
  821. package/out/server/test/yaml-documents.test.js +198 -0
  822. package/out/server/test/yaml-documents.test.js.map +1 -0
  823. package/out/server/test/yamlCodeActions.test.d.ts +1 -0
  824. package/out/server/test/yamlCodeActions.test.js +864 -0
  825. package/out/server/test/yamlCodeActions.test.js.map +1 -0
  826. package/out/server/test/yamlCodeLens.test.d.ts +1 -0
  827. package/out/server/test/yamlCodeLens.test.js +165 -0
  828. package/out/server/test/yamlCodeLens.test.js.map +1 -0
  829. package/out/server/test/yamlCommands.test.d.ts +1 -0
  830. package/out/server/test/yamlCommands.test.js +89 -0
  831. package/out/server/test/yamlCommands.test.js.map +1 -0
  832. package/out/server/test/yamlDefinition.test.d.ts +1 -0
  833. package/out/server/test/yamlDefinition.test.js +30 -0
  834. package/out/server/test/yamlDefinition.test.js.map +1 -0
  835. package/out/server/test/yamlFolding.test.d.ts +1 -0
  836. package/out/server/test/yamlFolding.test.js +142 -0
  837. package/out/server/test/yamlFolding.test.js.map +1 -0
  838. package/out/server/test/yamlLanguageService.test.d.ts +1 -0
  839. package/out/server/test/yamlLanguageService.test.js +90 -0
  840. package/out/server/test/yamlLanguageService.test.js.map +1 -0
  841. package/out/server/test/yamlOnTypeFormatting.test.d.ts +1 -0
  842. package/out/server/test/yamlOnTypeFormatting.test.js +69 -0
  843. package/out/server/test/yamlOnTypeFormatting.test.js.map +1 -0
  844. package/out/server/test/yamlParser.test.d.ts +1 -0
  845. package/out/server/test/yamlParser.test.js +242 -0
  846. package/out/server/test/yamlParser.test.js.map +1 -0
  847. package/out/server/test/yamlRename.test.d.ts +1 -0
  848. package/out/server/test/yamlRename.test.js +106 -0
  849. package/out/server/test/yamlRename.test.js.map +1 -0
  850. package/out/server/test/yamlSchema.test.d.ts +1 -0
  851. package/out/server/test/yamlSchema.test.js +62 -0
  852. package/out/server/test/yamlSchema.test.js.map +1 -0
  853. package/out/server/test/yamlSchemaService.test.d.ts +1 -0
  854. package/out/server/test/yamlSchemaService.test.js +403 -0
  855. package/out/server/test/yamlSchemaService.test.js.map +1 -0
  856. package/out/server/test/yamlSelectionRanges.test.d.ts +1 -0
  857. package/out/server/test/yamlSelectionRanges.test.js +248 -0
  858. package/out/server/test/yamlSelectionRanges.test.js.map +1 -0
  859. package/out/server/test/yamlValidation.test.d.ts +1 -0
  860. package/out/server/test/yamlValidation.test.js +303 -0
  861. package/out/server/test/yamlValidation.test.js.map +1 -0
  862. package/package.json +106 -0
  863. package/scripts/check-dependencies.js +21 -0
  864. package/tsconfig.esm.json +15 -0
  865. package/tsconfig.umd.json +14 -0
@@ -0,0 +1,3630 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*---------------------------------------------------------------------------------------------
4
+ * Copyright (c) IBM Corporation. All rights reserved.
5
+ * Licensed under the MIT License. See License.txt in the project root for license information.
6
+ *--------------------------------------------------------------------------------------------*/
7
+ const testHelper_1 = require("./utils/testHelper");
8
+ const serviceSetup_1 = require("./utils/serviceSetup");
9
+ const chai_1 = require("chai");
10
+ const yamlSettings_1 = require("../src/yamlSettings");
11
+ const schemaUrls_1 = require("../src/languageservice/utils/schemaUrls");
12
+ describe('Validation Tests', () => {
13
+ let languageSettingsSetup;
14
+ let validationHandler;
15
+ let yamlSettings;
16
+ let schemaProvider;
17
+ const toContent = (data) => JSON.stringify(data, null, 2);
18
+ before(() => {
19
+ languageSettingsSetup = new serviceSetup_1.ServiceSetup()
20
+ .withValidate()
21
+ .withCompletion()
22
+ .withCustomTags(['!Test', '!Ref sequence'])
23
+ .withSchemaFileMatch({ uri: schemaUrls_1.KUBERNETES_SCHEMA_URL, fileMatch: ['.drone.yml'] })
24
+ .withSchemaFileMatch({ uri: 'https://json.schemastore.org/drone', fileMatch: ['.drone.yml'] })
25
+ .withSchemaFileMatch({ uri: schemaUrls_1.KUBERNETES_SCHEMA_URL, fileMatch: ['test.yml'] })
26
+ .withSchemaFileMatch({
27
+ uri: 'https://raw.githubusercontent.com/composer/composer/master/res/composer-schema.json',
28
+ fileMatch: ['test.yml'],
29
+ });
30
+ const { validationHandler: valHandler, yamlSettings: settings, schemaProvider: testSchemaProvider, } = (0, testHelper_1.setupLanguageService)(languageSettingsSetup.languageSettings);
31
+ validationHandler = valHandler;
32
+ yamlSettings = settings;
33
+ schemaProvider = testSchemaProvider;
34
+ });
35
+ function parseSetup(content, customSchemaID) {
36
+ const testTextDocument = (0, testHelper_1.setupSchemaIDTextDocument)(content, customSchemaID);
37
+ yamlSettings.documents = new yamlSettings_1.TextDocumentTestManager();
38
+ yamlSettings.documents.set(testTextDocument);
39
+ return validationHandler.validateTextDocument(testTextDocument);
40
+ }
41
+ afterEach(() => {
42
+ schemaProvider.deleteSchema(testHelper_1.SCHEMA_ID);
43
+ });
44
+ describe('$ref resolution', () => {
45
+ it('root pointer ref', async () => {
46
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
47
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
48
+ properties: {
49
+ foo: { $ref: '#' },
50
+ },
51
+ additionalProperties: false,
52
+ });
53
+ // match
54
+ let content = toContent({ foo: false });
55
+ let result = await parseSetup(content);
56
+ (0, chai_1.expect)(result).to.be.empty;
57
+ // recursive match
58
+ content = toContent({ foo: { foo: false } });
59
+ result = await parseSetup(content);
60
+ (0, chai_1.expect)(result).to.be.empty;
61
+ // mismatch
62
+ content = toContent({ bar: false });
63
+ result = await parseSetup(content);
64
+ (0, chai_1.expect)(result).to.have.length(1);
65
+ (0, chai_1.expect)(result[0].message).to.include('not allowed');
66
+ // recursive mismatch
67
+ content = toContent({ foo: { bar: false } });
68
+ result = await parseSetup(content);
69
+ (0, chai_1.expect)(result).to.have.length(1);
70
+ (0, chai_1.expect)(result[0].message).to.include('not allowed');
71
+ });
72
+ it('relative pointer ref to object', async () => {
73
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
74
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
75
+ properties: {
76
+ foo: { type: 'integer' },
77
+ bar: { $ref: '#/properties/foo' },
78
+ },
79
+ });
80
+ // match
81
+ let content = toContent({ bar: 3 });
82
+ let result = await parseSetup(content);
83
+ (0, chai_1.expect)(result).to.be.empty;
84
+ // mismatch
85
+ content = toContent({ bar: true });
86
+ result = await parseSetup(content);
87
+ (0, chai_1.expect)(result).to.have.length(1);
88
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
89
+ });
90
+ it('relative pointer ref to array', async () => {
91
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
92
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
93
+ items: [{ type: 'integer' }, { $ref: '#/items/0' }],
94
+ });
95
+ // match array
96
+ let content = toContent([1, 2]);
97
+ let result = await parseSetup(content);
98
+ (0, chai_1.expect)(result).to.be.empty;
99
+ // mismatch array
100
+ content = toContent([1, 'foo']);
101
+ result = await parseSetup(content);
102
+ (0, chai_1.expect)(result).to.have.length(1);
103
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
104
+ });
105
+ it('escaped pointer ref', async () => {
106
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
107
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
108
+ $defs: {
109
+ 'tilde~field': { type: 'integer' },
110
+ 'slash/field': { type: 'integer' },
111
+ 'percent%field': { type: 'integer' },
112
+ },
113
+ properties: {
114
+ tilde: { $ref: '#/$defs/tilde~0field' },
115
+ slash: { $ref: '#/$defs/slash~1field' },
116
+ percent: { $ref: '#/$defs/percent%25field' },
117
+ },
118
+ });
119
+ // slash invalid
120
+ let content = toContent({ slash: 'aoeu' });
121
+ let result = await parseSetup(content);
122
+ (0, chai_1.expect)(result).to.have.length(1);
123
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
124
+ // tilde invalid
125
+ content = toContent({ tilde: 'aoeu' });
126
+ result = await parseSetup(content);
127
+ (0, chai_1.expect)(result).to.have.length(1);
128
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
129
+ // percent invalid
130
+ content = toContent({ percent: 'aoeu' });
131
+ result = await parseSetup(content);
132
+ (0, chai_1.expect)(result).to.have.length(1);
133
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
134
+ // slash valid
135
+ content = toContent({ slash: 123 });
136
+ result = await parseSetup(content);
137
+ (0, chai_1.expect)(result).to.be.empty;
138
+ // tilde valid
139
+ content = toContent({ tilde: 123 });
140
+ result = await parseSetup(content);
141
+ (0, chai_1.expect)(result).to.be.empty;
142
+ // percent valid
143
+ content = toContent({ percent: 123 });
144
+ result = await parseSetup(content);
145
+ (0, chai_1.expect)(result).to.be.empty;
146
+ });
147
+ it('nested refs', async () => {
148
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
149
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
150
+ $defs: {
151
+ a: { type: 'integer' },
152
+ b: { $ref: '#/$defs/a' },
153
+ c: { $ref: '#/$defs/b' },
154
+ },
155
+ $ref: '#/$defs/c',
156
+ });
157
+ // nested ref valid
158
+ let content = toContent(5);
159
+ let result = await parseSetup(content);
160
+ (0, chai_1.expect)(result).to.be.empty;
161
+ // nested ref invalid
162
+ content = toContent('a');
163
+ result = await parseSetup(content);
164
+ (0, chai_1.expect)(result).to.have.length(1);
165
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
166
+ });
167
+ it('ref applies alongside sibling keywords', async () => {
168
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
169
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
170
+ $defs: {
171
+ reffed: {
172
+ type: 'array',
173
+ },
174
+ },
175
+ properties: {
176
+ foo: {
177
+ $ref: '#/$defs/reffed',
178
+ maxItems: 2,
179
+ },
180
+ },
181
+ });
182
+ // ref valid, maxItems valid
183
+ let content = toContent({ foo: [] });
184
+ let result = await parseSetup(content);
185
+ (0, chai_1.expect)(result).to.be.empty;
186
+ // ref valid, maxItems invalid
187
+ content = toContent({ foo: [1, 2, 3] });
188
+ result = await parseSetup(content);
189
+ (0, chai_1.expect)(result).to.have.length(1);
190
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items');
191
+ // ref invalid
192
+ content = toContent({ foo: 'string' });
193
+ result = await parseSetup(content);
194
+ (0, chai_1.expect)(result).to.have.length(1);
195
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
196
+ });
197
+ it('property named $ref that is not a reference', async () => {
198
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
199
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
200
+ properties: {
201
+ $ref: { type: 'string' },
202
+ },
203
+ });
204
+ // property named $ref valid
205
+ let content = toContent({ $ref: 'a' });
206
+ let result = await parseSetup(content);
207
+ (0, chai_1.expect)(result).to.be.empty;
208
+ // property named $ref invalid
209
+ content = toContent({ $ref: 2 });
210
+ result = await parseSetup(content);
211
+ (0, chai_1.expect)(result).to.have.length(1);
212
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
213
+ });
214
+ it('property named $ref, containing an actual $ref', async () => {
215
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
216
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
217
+ properties: {
218
+ $ref: { $ref: '#/$defs/is-string' },
219
+ },
220
+ $defs: {
221
+ 'is-string': {
222
+ type: 'string',
223
+ },
224
+ },
225
+ });
226
+ // property named $ref valid
227
+ let content = toContent({ $ref: 'a' });
228
+ let result = await parseSetup(content);
229
+ (0, chai_1.expect)(result).to.be.empty;
230
+ // property named $ref invalid
231
+ content = toContent({ $ref: 2 });
232
+ result = await parseSetup(content);
233
+ (0, chai_1.expect)(result).to.have.length(1);
234
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
235
+ });
236
+ it('$ref to boolean schema true', async () => {
237
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
238
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
239
+ $ref: '#/$defs/bool',
240
+ $defs: {
241
+ bool: true,
242
+ },
243
+ });
244
+ // any value is valid
245
+ const content = toContent('foo');
246
+ const result = await parseSetup(content);
247
+ (0, chai_1.expect)(result).to.be.empty;
248
+ });
249
+ it('$ref to boolean schema false', async () => {
250
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
251
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
252
+ $ref: '#/$defs/bool',
253
+ $defs: {
254
+ bool: false,
255
+ },
256
+ });
257
+ // any value is invalid
258
+ const content = toContent('foo');
259
+ const result = await parseSetup(content);
260
+ (0, chai_1.expect)(result).to.have.length(1);
261
+ (0, chai_1.expect)(result[0].message).to.include('Matches a schema that is not allowed');
262
+ });
263
+ });
264
+ describe('$anchor resolution', () => {
265
+ it('Location-independent identifier', async () => {
266
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
267
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
268
+ $ref: '#foo',
269
+ $defs: {
270
+ A: {
271
+ $anchor: 'foo',
272
+ type: 'integer',
273
+ },
274
+ },
275
+ });
276
+ // match
277
+ let content = toContent(1);
278
+ let result = await parseSetup(content);
279
+ (0, chai_1.expect)(result).to.be.empty;
280
+ // mismatch
281
+ content = toContent('a');
282
+ result = await parseSetup(content);
283
+ (0, chai_1.expect)(result).to.have.length(1);
284
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
285
+ (0, chai_1.expect)(result[0].message).to.include('integer');
286
+ });
287
+ it('Location-independent identifier with absolute URI', async () => {
288
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
289
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
290
+ $ref: 'http://localhost:1234/draft2019-09/bar#foo',
291
+ $defs: {
292
+ A: {
293
+ $id: 'http://localhost:1234/draft2019-09/bar',
294
+ $anchor: 'foo',
295
+ type: 'integer',
296
+ },
297
+ },
298
+ });
299
+ // match
300
+ let content = toContent(1);
301
+ let result = await parseSetup(content);
302
+ (0, chai_1.expect)(result).to.be.empty;
303
+ // mismatch
304
+ content = toContent('a');
305
+ result = await parseSetup(content);
306
+ (0, chai_1.expect)(result).to.have.length(1);
307
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
308
+ (0, chai_1.expect)(result[0].message).to.include('integer');
309
+ });
310
+ it('Location-independent identifier with base URI change in subschema', async () => {
311
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
312
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
313
+ $id: 'http://localhost:1234/draft2019-09/root',
314
+ $ref: 'http://localhost:1234/draft2019-09/nested.json#foo',
315
+ $defs: {
316
+ A: {
317
+ $id: 'nested.json',
318
+ $defs: {
319
+ B: {
320
+ $anchor: 'foo',
321
+ type: 'integer',
322
+ },
323
+ },
324
+ },
325
+ },
326
+ });
327
+ // match
328
+ let content = toContent(1);
329
+ let result = await parseSetup(content);
330
+ (0, chai_1.expect)(result).to.be.empty;
331
+ // mismatch
332
+ content = toContent('a');
333
+ result = await parseSetup(content);
334
+ (0, chai_1.expect)(result).to.have.length(1);
335
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
336
+ (0, chai_1.expect)(result[0].message).to.include('integer');
337
+ });
338
+ it('same $anchor with different base uri', async () => {
339
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
340
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
341
+ $id: 'http://localhost:1234/draft2019-09/foobar',
342
+ $defs: {
343
+ A: {
344
+ $id: 'child1',
345
+ allOf: [
346
+ {
347
+ $id: 'child2',
348
+ $anchor: 'my_anchor',
349
+ type: 'number',
350
+ },
351
+ {
352
+ $anchor: 'my_anchor',
353
+ type: 'string',
354
+ },
355
+ ],
356
+ },
357
+ },
358
+ $ref: 'child1#my_anchor',
359
+ });
360
+ // $ref resolves to /$defs/A/allOf/1
361
+ let content = toContent('a');
362
+ let result = await parseSetup(content);
363
+ (0, chai_1.expect)(result).to.be.empty;
364
+ // $ref does not resolve to /$defs/A/allOf/0
365
+ content = toContent(1);
366
+ result = await parseSetup(content);
367
+ (0, chai_1.expect)(result).to.have.length(1);
368
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
369
+ (0, chai_1.expect)(result[0].message).to.include('string');
370
+ });
371
+ it('resolves $ref "#name" via $anchor in same document', async () => {
372
+ const schema = {
373
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
374
+ $defs: {
375
+ Name: {
376
+ $anchor: 'name',
377
+ type: 'string',
378
+ minLength: 2,
379
+ },
380
+ },
381
+ $ref: '#name',
382
+ };
383
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
384
+ const content = `A`;
385
+ const result = await parseSetup(content);
386
+ (0, chai_1.expect)(result).to.have.length(1);
387
+ (0, chai_1.expect)(result[0].message).to.include('String is shorter than the minimum length of 2.');
388
+ });
389
+ it('resolves external $ref to a root $anchor', async () => {
390
+ const rootSchema = {
391
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
392
+ $anchor: 'rootThing',
393
+ type: 'object',
394
+ properties: {
395
+ x: {
396
+ type: 'number',
397
+ },
398
+ },
399
+ required: ['x'],
400
+ };
401
+ const useRootSchema = {
402
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
403
+ $ref: 'file:///root.schema.json#rootThing',
404
+ };
405
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'file:///root.schema.json', rootSchema);
406
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'file:///use-root.schema.json', useRootSchema);
407
+ const content = `# yaml-language-server: $schema=file:///use-root.schema.json\n{}`;
408
+ const result = await parseSetup(content);
409
+ (0, chai_1.expect)(result).to.have.length(1);
410
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
411
+ });
412
+ it('resolves external $ref to $anchor in another schema', async () => {
413
+ const typesSchema = {
414
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
415
+ $defs: {
416
+ Port: {
417
+ $anchor: 'port',
418
+ type: 'integer',
419
+ minimum: 1,
420
+ maximum: 65535,
421
+ },
422
+ },
423
+ };
424
+ const serverSchema = {
425
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
426
+ type: 'object',
427
+ properties: {
428
+ port: { $ref: 'file:///types.schema.json#port' },
429
+ },
430
+ };
431
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'file:///types.schema.json', typesSchema);
432
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'file:///server.schema.json', serverSchema);
433
+ const content = `# yaml-language-server: $schema=file:///server.schema.json\nport: 70000`;
434
+ const result = await parseSetup(content);
435
+ (0, chai_1.expect)(result).to.have.length(1);
436
+ (0, chai_1.expect)(result[0].message).to.include('Value is above the maximum of 65535.');
437
+ });
438
+ });
439
+ describe('keyword: unevaluatedProperties', () => {
440
+ it('unevaluatedProperties as schema validates remaining property values', async () => {
441
+ const schema = {
442
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
443
+ type: 'object',
444
+ properties: {
445
+ known: { type: 'string' },
446
+ },
447
+ unevaluatedProperties: { type: 'number' },
448
+ };
449
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
450
+ const content = `known: ok\nextra: hi`;
451
+ const result = await parseSetup(content);
452
+ (0, chai_1.expect)(result).to.have.length(1);
453
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
454
+ (0, chai_1.expect)(result[0].message).to.include('number');
455
+ });
456
+ it('unevaluatedProperties=false sees evaluated props across allOf', async () => {
457
+ const schema = {
458
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
459
+ allOf: [
460
+ { type: 'object', properties: { a: { type: 'string' } } },
461
+ { type: 'object', properties: { b: { type: 'number' } } },
462
+ ],
463
+ unevaluatedProperties: false,
464
+ };
465
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
466
+ const content = `a: ok\nb: 1\nc: 2`;
467
+ const result = await parseSetup(content);
468
+ (0, chai_1.expect)(result).to.have.length(1);
469
+ (0, chai_1.expect)(result[0].message).to.include('Property c is not allowed');
470
+ });
471
+ it('unevaluatedProperties sees properties defined across $ref', async () => {
472
+ const baseSchema = {
473
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
474
+ type: 'object',
475
+ properties: {
476
+ a: { type: 'string' },
477
+ },
478
+ };
479
+ const strictSchema = {
480
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
481
+ allOf: [{ $ref: 'file:///base-uneval.schema.json' }],
482
+ unevaluatedProperties: false,
483
+ };
484
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'file:///base-uneval.schema.json', baseSchema);
485
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'file:///strict-uneval.schema.json', strictSchema);
486
+ const content = `# yaml-language-server: $schema=file:///strict-uneval.schema.json\na: ok\nc: nope`;
487
+ const result = await parseSetup(content);
488
+ (0, chai_1.expect)(result).to.have.length(1);
489
+ (0, chai_1.expect)(result[0].message).to.include('Property c is not allowed');
490
+ });
491
+ it('unevaluatedProperties true', async () => {
492
+ const schema = {
493
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
494
+ type: 'object',
495
+ unevaluatedProperties: true,
496
+ };
497
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
498
+ (0, chai_1.expect)(await parseSetup(toContent({}))).to.be.empty;
499
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
500
+ });
501
+ it('unevaluatedProperties schema', async () => {
502
+ const schema = {
503
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
504
+ type: 'object',
505
+ unevaluatedProperties: {
506
+ type: 'string',
507
+ minLength: 3,
508
+ },
509
+ };
510
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
511
+ (0, chai_1.expect)(await parseSetup(toContent({}))).to.be.empty;
512
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
513
+ const result = await parseSetup(toContent({ foo: 'fo' }));
514
+ (0, chai_1.expect)(result).to.have.length(1);
515
+ (0, chai_1.expect)(result[0].message).to.include('String is shorter than the minimum length of 3.');
516
+ });
517
+ it('unevaluatedProperties false', async () => {
518
+ const schema = {
519
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
520
+ type: 'object',
521
+ unevaluatedProperties: false,
522
+ };
523
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
524
+ (0, chai_1.expect)(await parseSetup(toContent({}))).to.be.empty;
525
+ const result = await parseSetup(toContent({ foo: 'foo' }));
526
+ (0, chai_1.expect)(result).to.have.length(1);
527
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
528
+ });
529
+ it('unevaluatedProperties with adjacent properties', async () => {
530
+ const schema = {
531
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
532
+ type: 'object',
533
+ properties: {
534
+ foo: { type: 'string' },
535
+ },
536
+ unevaluatedProperties: false,
537
+ };
538
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
539
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
540
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar' }));
541
+ (0, chai_1.expect)(result).to.have.length(1);
542
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
543
+ });
544
+ it('unevaluatedProperties with adjacent patternProperties', async () => {
545
+ const schema = {
546
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
547
+ type: 'object',
548
+ patternProperties: {
549
+ '^foo': { type: 'string' },
550
+ },
551
+ unevaluatedProperties: false,
552
+ };
553
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
554
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
555
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar' }));
556
+ (0, chai_1.expect)(result).to.have.length(1);
557
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
558
+ });
559
+ it('unevaluatedProperties with adjacent additionalProperties', async () => {
560
+ const schema = {
561
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
562
+ type: 'object',
563
+ properties: {
564
+ foo: { type: 'string' },
565
+ },
566
+ additionalProperties: true,
567
+ unevaluatedProperties: false,
568
+ };
569
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
570
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
571
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
572
+ });
573
+ it('unevaluatedProperties with nested properties', async () => {
574
+ const schema = {
575
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
576
+ type: 'object',
577
+ properties: {
578
+ foo: { type: 'string' },
579
+ },
580
+ allOf: [
581
+ {
582
+ properties: {
583
+ bar: { type: 'string' },
584
+ },
585
+ },
586
+ ],
587
+ unevaluatedProperties: false,
588
+ };
589
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
590
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
591
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar', baz: 'baz' }));
592
+ (0, chai_1.expect)(result).to.have.length(1);
593
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
594
+ });
595
+ it('unevaluatedProperties with nested patternProperties', async () => {
596
+ const schema = {
597
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
598
+ type: 'object',
599
+ properties: {
600
+ foo: { type: 'string' },
601
+ },
602
+ allOf: [
603
+ {
604
+ patternProperties: {
605
+ '^bar': { type: 'string' },
606
+ },
607
+ },
608
+ ],
609
+ unevaluatedProperties: false,
610
+ };
611
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
612
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
613
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar', baz: 'baz' }));
614
+ (0, chai_1.expect)(result).to.have.length(1);
615
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
616
+ });
617
+ it('unevaluatedProperties with nested additionalProperties', async () => {
618
+ const schema = {
619
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
620
+ type: 'object',
621
+ properties: {
622
+ foo: { type: 'string' },
623
+ },
624
+ allOf: [
625
+ {
626
+ additionalProperties: true,
627
+ },
628
+ ],
629
+ unevaluatedProperties: false,
630
+ };
631
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
632
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
633
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
634
+ });
635
+ it('unevaluatedProperties with nested unevaluatedProperties', async () => {
636
+ const schema = {
637
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
638
+ type: 'object',
639
+ properties: {
640
+ foo: { type: 'string' },
641
+ },
642
+ allOf: [
643
+ {
644
+ unevaluatedProperties: true,
645
+ },
646
+ ],
647
+ unevaluatedProperties: {
648
+ type: 'string',
649
+ maxLength: 2,
650
+ },
651
+ };
652
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
653
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
654
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
655
+ });
656
+ it('unevaluatedProperties with anyOf', async () => {
657
+ const schema = {
658
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
659
+ type: 'object',
660
+ properties: {
661
+ foo: { type: 'string' },
662
+ },
663
+ anyOf: [
664
+ {
665
+ properties: {
666
+ bar: { const: 'bar' },
667
+ },
668
+ required: ['bar'],
669
+ },
670
+ {
671
+ properties: {
672
+ baz: { const: 'baz' },
673
+ },
674
+ required: ['baz'],
675
+ },
676
+ {
677
+ properties: {
678
+ quux: { const: 'quux' },
679
+ },
680
+ required: ['quux'],
681
+ },
682
+ ],
683
+ unevaluatedProperties: false,
684
+ };
685
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
686
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
687
+ let result = await parseSetup(toContent({ foo: 'foo', bar: 'bar', baz: 'not-baz' }));
688
+ (0, chai_1.expect)(result).to.have.length(1);
689
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
690
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar', baz: 'baz' }))).to.be.empty;
691
+ result = await parseSetup(toContent({ foo: 'foo', bar: 'bar', baz: 'baz', quux: 'not-quux' }));
692
+ (0, chai_1.expect)(result).to.have.length(1);
693
+ (0, chai_1.expect)(result[0].message).to.include('Property quux is not allowed.');
694
+ });
695
+ it('unevaluatedProperties with oneOf', async () => {
696
+ const schema = {
697
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
698
+ type: 'object',
699
+ properties: {
700
+ foo: { type: 'string' },
701
+ },
702
+ oneOf: [
703
+ {
704
+ properties: {
705
+ bar: { const: 'bar' },
706
+ },
707
+ required: ['bar'],
708
+ },
709
+ {
710
+ properties: {
711
+ baz: { const: 'baz' },
712
+ },
713
+ required: ['baz'],
714
+ },
715
+ ],
716
+ unevaluatedProperties: false,
717
+ };
718
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
719
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
720
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar', quux: 'quux' }));
721
+ (0, chai_1.expect)(result).to.have.length(1);
722
+ (0, chai_1.expect)(result[0].message).to.include('Property quux is not allowed.');
723
+ });
724
+ it('unevaluatedProperties with not', async () => {
725
+ const schema = {
726
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
727
+ type: 'object',
728
+ properties: {
729
+ foo: { type: 'string' },
730
+ },
731
+ not: {
732
+ not: {
733
+ properties: {
734
+ bar: { const: 'bar' },
735
+ },
736
+ required: ['bar'],
737
+ },
738
+ },
739
+ unevaluatedProperties: false,
740
+ };
741
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
742
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar' }));
743
+ (0, chai_1.expect)(result).to.have.length(1);
744
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
745
+ });
746
+ it('unevaluatedProperties with if/then/else', async () => {
747
+ const schema = {
748
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
749
+ type: 'object',
750
+ if: {
751
+ properties: {
752
+ foo: { const: 'then' },
753
+ },
754
+ required: ['foo'],
755
+ },
756
+ then: {
757
+ properties: {
758
+ bar: { type: 'string' },
759
+ },
760
+ required: ['bar'],
761
+ },
762
+ else: {
763
+ properties: {
764
+ baz: { type: 'string' },
765
+ },
766
+ required: ['baz'],
767
+ },
768
+ unevaluatedProperties: false,
769
+ };
770
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
771
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'then', bar: 'bar' }))).to.be.empty;
772
+ let result = await parseSetup(toContent({ foo: 'then', bar: 'bar', baz: 'baz' }));
773
+ (0, chai_1.expect)(result).to.have.length(1);
774
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
775
+ (0, chai_1.expect)(await parseSetup(toContent({ baz: 'baz' }))).to.be.empty;
776
+ result = await parseSetup(toContent({ foo: 'else', baz: 'baz' }));
777
+ (0, chai_1.expect)(result).to.have.length(1);
778
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
779
+ });
780
+ it('unevaluatedProperties with if/then/else, then not defined', async () => {
781
+ const schema = {
782
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
783
+ type: 'object',
784
+ if: {
785
+ properties: {
786
+ foo: { const: 'then' },
787
+ },
788
+ required: ['foo'],
789
+ },
790
+ else: {
791
+ properties: {
792
+ baz: { type: 'string' },
793
+ },
794
+ required: ['baz'],
795
+ },
796
+ unevaluatedProperties: false,
797
+ };
798
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
799
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'then' }))).to.be.empty;
800
+ let result = await parseSetup(toContent({ foo: 'then', bar: 'bar' }));
801
+ (0, chai_1.expect)(result).to.have.length(1);
802
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
803
+ (0, chai_1.expect)(await parseSetup(toContent({ baz: 'baz' }))).to.be.empty;
804
+ result = await parseSetup(toContent({ foo: 'else', baz: 'baz' }));
805
+ (0, chai_1.expect)(result).to.have.length(1);
806
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
807
+ });
808
+ it('unevaluatedProperties with if/then/else, else not defined', async () => {
809
+ const schema = {
810
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
811
+ type: 'object',
812
+ if: {
813
+ properties: {
814
+ foo: { const: 'then' },
815
+ },
816
+ required: ['foo'],
817
+ },
818
+ then: {
819
+ properties: {
820
+ bar: { type: 'string' },
821
+ },
822
+ required: ['bar'],
823
+ },
824
+ unevaluatedProperties: false,
825
+ };
826
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
827
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'then', bar: 'bar' }))).to.be.empty;
828
+ let result = await parseSetup(toContent({ foo: 'then', bar: 'bar', baz: 'baz' }));
829
+ (0, chai_1.expect)(result).to.have.length(1);
830
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
831
+ result = await parseSetup(toContent({ baz: 'baz' }));
832
+ (0, chai_1.expect)(result).to.have.length(1);
833
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
834
+ result = await parseSetup(toContent({ foo: 'else', baz: 'baz' }));
835
+ (0, chai_1.expect)(result).to.have.length(2);
836
+ const messages = result.map((entry) => entry.message).join(' | ');
837
+ (0, chai_1.expect)(messages).to.include('Property foo is not allowed.');
838
+ (0, chai_1.expect)(messages).to.include('Property baz is not allowed.');
839
+ });
840
+ it('unevaluatedProperties with dependentSchemas', async () => {
841
+ const schema = {
842
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
843
+ type: 'object',
844
+ properties: {
845
+ foo: { type: 'string' },
846
+ },
847
+ dependentSchemas: {
848
+ foo: {
849
+ properties: {
850
+ bar: { const: 'bar' },
851
+ },
852
+ required: ['bar'],
853
+ },
854
+ },
855
+ unevaluatedProperties: false,
856
+ };
857
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
858
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
859
+ const result = await parseSetup(toContent({ bar: 'bar' }));
860
+ (0, chai_1.expect)(result).to.have.length(1);
861
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
862
+ });
863
+ it('unevaluatedProperties with boolean schemas', async () => {
864
+ const schema = {
865
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
866
+ type: 'object',
867
+ properties: {
868
+ foo: { type: 'string' },
869
+ },
870
+ allOf: [true],
871
+ unevaluatedProperties: false,
872
+ };
873
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
874
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
875
+ const result = await parseSetup(toContent({ bar: 'bar' }));
876
+ (0, chai_1.expect)(result).to.have.length(1);
877
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
878
+ });
879
+ it('unevaluatedProperties with $ref', async () => {
880
+ const schema = {
881
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
882
+ type: 'object',
883
+ $ref: '#/$defs/bar',
884
+ properties: {
885
+ foo: { type: 'string' },
886
+ },
887
+ unevaluatedProperties: false,
888
+ $defs: {
889
+ bar: {
890
+ properties: {
891
+ bar: { type: 'string' },
892
+ },
893
+ },
894
+ },
895
+ };
896
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
897
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
898
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar', baz: 'baz' }));
899
+ (0, chai_1.expect)(result).to.have.length(1);
900
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
901
+ });
902
+ it('unevaluatedProperties before $ref', async () => {
903
+ const schema = {
904
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
905
+ type: 'object',
906
+ unevaluatedProperties: false,
907
+ properties: {
908
+ foo: { type: 'string' },
909
+ },
910
+ $ref: '#/$defs/bar',
911
+ $defs: {
912
+ bar: {
913
+ properties: {
914
+ bar: { type: 'string' },
915
+ },
916
+ },
917
+ },
918
+ };
919
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
920
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
921
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar', baz: 'baz' }));
922
+ (0, chai_1.expect)(result).to.have.length(1);
923
+ (0, chai_1.expect)(result[0].message).to.include('Property baz is not allowed.');
924
+ });
925
+ it('unevaluatedProperties with $recursiveRef', async () => {
926
+ const schema = {
927
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
928
+ $id: 'https://example.com/unevaluated-properties-with-recursive-ref/extended-tree',
929
+ $recursiveAnchor: true,
930
+ $ref: './tree',
931
+ properties: {
932
+ name: { type: 'string' },
933
+ },
934
+ $defs: {
935
+ tree: {
936
+ $id: './tree',
937
+ $recursiveAnchor: true,
938
+ type: 'object',
939
+ properties: {
940
+ node: true,
941
+ branches: {
942
+ $comment: "unevaluatedProperties comes first so it's more likely to bugs errors with implementations that are sensitive to keyword ordering",
943
+ unevaluatedProperties: false,
944
+ $recursiveRef: '#',
945
+ },
946
+ },
947
+ required: ['node'],
948
+ },
949
+ },
950
+ };
951
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
952
+ (0, chai_1.expect)(await parseSetup(toContent({
953
+ name: 'a',
954
+ node: 1,
955
+ branches: {
956
+ name: 'b',
957
+ node: 2,
958
+ },
959
+ }))).to.be.empty;
960
+ const result = await parseSetup(toContent({
961
+ name: 'a',
962
+ node: 1,
963
+ branches: {
964
+ foo: 'b',
965
+ node: 2,
966
+ },
967
+ }));
968
+ (0, chai_1.expect)(result).to.have.length(1);
969
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
970
+ });
971
+ it("unevaluatedProperties can't see inside cousins", async () => {
972
+ const schema = {
973
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
974
+ allOf: [
975
+ {
976
+ properties: {
977
+ foo: true,
978
+ },
979
+ },
980
+ {
981
+ unevaluatedProperties: false,
982
+ },
983
+ ],
984
+ };
985
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
986
+ const result = await parseSetup(toContent({ foo: 1 }));
987
+ (0, chai_1.expect)(result).to.have.length(1);
988
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
989
+ });
990
+ it("unevaluatedProperties can't see inside cousins (reverse order)", async () => {
991
+ const schema = {
992
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
993
+ allOf: [
994
+ {
995
+ unevaluatedProperties: false,
996
+ },
997
+ {
998
+ properties: {
999
+ foo: true,
1000
+ },
1001
+ },
1002
+ ],
1003
+ };
1004
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1005
+ const result = await parseSetup(toContent({ foo: 1 }));
1006
+ (0, chai_1.expect)(result).to.have.length(1);
1007
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
1008
+ });
1009
+ it('nested unevaluatedProperties, outer false, inner true, properties outside', async () => {
1010
+ const schema = {
1011
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1012
+ type: 'object',
1013
+ properties: {
1014
+ foo: { type: 'string' },
1015
+ },
1016
+ allOf: [
1017
+ {
1018
+ unevaluatedProperties: true,
1019
+ },
1020
+ ],
1021
+ unevaluatedProperties: false,
1022
+ };
1023
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1024
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
1025
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
1026
+ });
1027
+ it('nested unevaluatedProperties, outer false, inner true, properties inside', async () => {
1028
+ const schema = {
1029
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1030
+ type: 'object',
1031
+ allOf: [
1032
+ {
1033
+ properties: {
1034
+ foo: { type: 'string' },
1035
+ },
1036
+ unevaluatedProperties: true,
1037
+ },
1038
+ ],
1039
+ unevaluatedProperties: false,
1040
+ };
1041
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1042
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
1043
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo', bar: 'bar' }))).to.be.empty;
1044
+ });
1045
+ it('nested unevaluatedProperties, outer true, inner false, properties outside', async () => {
1046
+ const schema = {
1047
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1048
+ type: 'object',
1049
+ properties: {
1050
+ foo: { type: 'string' },
1051
+ },
1052
+ allOf: [
1053
+ {
1054
+ unevaluatedProperties: false,
1055
+ },
1056
+ ],
1057
+ unevaluatedProperties: true,
1058
+ };
1059
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1060
+ const result1 = await parseSetup(toContent({ foo: 'foo' }));
1061
+ (0, chai_1.expect)(result1).to.have.length(1);
1062
+ (0, chai_1.expect)(result1[0].message).to.include('Property foo is not allowed.');
1063
+ const result2 = await parseSetup(toContent({ foo: 'foo', bar: 'bar' }));
1064
+ (0, chai_1.expect)(result2).to.have.length(2);
1065
+ const messages = result2.map((entry) => entry.message).join(' | ');
1066
+ (0, chai_1.expect)(messages).to.include('Property foo is not allowed.');
1067
+ (0, chai_1.expect)(messages).to.include('Property bar is not allowed.');
1068
+ });
1069
+ it('nested unevaluatedProperties, outer true, inner false, properties inside', async () => {
1070
+ const schema = {
1071
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1072
+ type: 'object',
1073
+ allOf: [
1074
+ {
1075
+ properties: {
1076
+ foo: { type: 'string' },
1077
+ },
1078
+ unevaluatedProperties: false,
1079
+ },
1080
+ ],
1081
+ unevaluatedProperties: true,
1082
+ };
1083
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1084
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
1085
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar' }));
1086
+ (0, chai_1.expect)(result).to.have.length(1);
1087
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
1088
+ });
1089
+ it('cousin unevaluatedProperties, true and false, true with properties', async () => {
1090
+ const schema = {
1091
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1092
+ type: 'object',
1093
+ allOf: [
1094
+ {
1095
+ properties: {
1096
+ foo: { type: 'string' },
1097
+ },
1098
+ unevaluatedProperties: true,
1099
+ },
1100
+ {
1101
+ unevaluatedProperties: false,
1102
+ },
1103
+ ],
1104
+ };
1105
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1106
+ const result1 = await parseSetup(toContent({ foo: 'foo' }));
1107
+ (0, chai_1.expect)(result1).to.have.length(1);
1108
+ (0, chai_1.expect)(result1[0].message).to.include('Property foo is not allowed.');
1109
+ const result2 = await parseSetup(toContent({ foo: 'foo', bar: 'bar' }));
1110
+ (0, chai_1.expect)(result2).to.have.length(2);
1111
+ const messages = result2.map((entry) => entry.message).join(' | ');
1112
+ (0, chai_1.expect)(messages).to.include('Property foo is not allowed.');
1113
+ (0, chai_1.expect)(messages).to.include('Property bar is not allowed.');
1114
+ });
1115
+ it('cousin unevaluatedProperties, true and false, false with properties', async () => {
1116
+ const schema = {
1117
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1118
+ type: 'object',
1119
+ allOf: [
1120
+ {
1121
+ unevaluatedProperties: true,
1122
+ },
1123
+ {
1124
+ properties: {
1125
+ foo: { type: 'string' },
1126
+ },
1127
+ unevaluatedProperties: false,
1128
+ },
1129
+ ],
1130
+ };
1131
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1132
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'foo' }))).to.be.empty;
1133
+ const result = await parseSetup(toContent({ foo: 'foo', bar: 'bar' }));
1134
+ (0, chai_1.expect)(result).to.have.length(1);
1135
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
1136
+ });
1137
+ it('property is evaluated in an uncle schema to unevaluatedProperties', async () => {
1138
+ const schema = {
1139
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1140
+ type: 'object',
1141
+ properties: {
1142
+ foo: {
1143
+ type: 'object',
1144
+ properties: {
1145
+ bar: {
1146
+ type: 'string',
1147
+ },
1148
+ },
1149
+ unevaluatedProperties: false,
1150
+ },
1151
+ },
1152
+ anyOf: [
1153
+ {
1154
+ properties: {
1155
+ foo: {
1156
+ properties: {
1157
+ faz: {
1158
+ type: 'string',
1159
+ },
1160
+ },
1161
+ },
1162
+ },
1163
+ },
1164
+ ],
1165
+ };
1166
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1167
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: { bar: 'test' } }))).to.be.empty;
1168
+ const result = await parseSetup(toContent({ foo: { bar: 'test', faz: 'test' } }));
1169
+ (0, chai_1.expect)(result).to.have.length(1);
1170
+ (0, chai_1.expect)(result[0].message).to.include('Property faz is not allowed.');
1171
+ });
1172
+ describe('in-place applicator siblings, allOf has unevaluated', () => {
1173
+ const schema = {
1174
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1175
+ type: 'object',
1176
+ allOf: [
1177
+ {
1178
+ properties: {
1179
+ foo: true,
1180
+ },
1181
+ unevaluatedProperties: false,
1182
+ },
1183
+ ],
1184
+ anyOf: [
1185
+ {
1186
+ properties: {
1187
+ bar: true,
1188
+ },
1189
+ },
1190
+ ],
1191
+ };
1192
+ beforeEach(() => {
1193
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1194
+ });
1195
+ it('base case: both properties present', async () => {
1196
+ const result = await parseSetup(toContent({ foo: 1, bar: 1 }));
1197
+ (0, chai_1.expect)(result).to.have.length(1);
1198
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
1199
+ });
1200
+ it('in place applicator siblings, bar is missing', async () => {
1201
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 1 }))).to.be.empty;
1202
+ });
1203
+ it('in place applicator siblings, foo is missing', async () => {
1204
+ const result = await parseSetup(toContent({ bar: 1 }));
1205
+ (0, chai_1.expect)(result).to.have.length(1);
1206
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
1207
+ });
1208
+ });
1209
+ describe('in-place applicator siblings, anyOf has unevaluated', () => {
1210
+ const schema = {
1211
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1212
+ type: 'object',
1213
+ allOf: [
1214
+ {
1215
+ properties: {
1216
+ foo: true,
1217
+ },
1218
+ },
1219
+ ],
1220
+ anyOf: [
1221
+ {
1222
+ properties: {
1223
+ bar: true,
1224
+ },
1225
+ unevaluatedProperties: false,
1226
+ },
1227
+ ],
1228
+ };
1229
+ beforeEach(() => {
1230
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1231
+ });
1232
+ it('base case: both properties present', async () => {
1233
+ const result = await parseSetup(toContent({ foo: 1, bar: 1 }));
1234
+ (0, chai_1.expect)(result).to.have.length(1);
1235
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
1236
+ });
1237
+ it('in place applicator siblings, bar is missing', async () => {
1238
+ const result = await parseSetup(toContent({ foo: 1 }));
1239
+ (0, chai_1.expect)(result).to.have.length(1);
1240
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
1241
+ });
1242
+ it('in place applicator siblings, foo is missing', async () => {
1243
+ (0, chai_1.expect)(await parseSetup(toContent({ bar: 1 }))).to.be.empty;
1244
+ });
1245
+ });
1246
+ describe('unevaluatedProperties + single cyclic ref', () => {
1247
+ const schema = {
1248
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1249
+ type: 'object',
1250
+ properties: {
1251
+ x: { $ref: '#' },
1252
+ },
1253
+ unevaluatedProperties: false,
1254
+ };
1255
+ beforeEach(() => {
1256
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1257
+ });
1258
+ it('Empty is valid', async () => {
1259
+ (0, chai_1.expect)(await parseSetup(toContent({}))).to.be.empty;
1260
+ });
1261
+ it('Single is valid', async () => {
1262
+ (0, chai_1.expect)(await parseSetup(toContent({ x: {} }))).to.be.empty;
1263
+ });
1264
+ it('Unevaluated on 1st level is invalid', async () => {
1265
+ const result = await parseSetup(toContent({ x: {}, y: {} }));
1266
+ (0, chai_1.expect)(result).to.have.length(1);
1267
+ (0, chai_1.expect)(result[0].message).to.include('Property y is not allowed.');
1268
+ });
1269
+ it('Nested is valid', async () => {
1270
+ (0, chai_1.expect)(await parseSetup(toContent({ x: { x: {} } }))).to.be.empty;
1271
+ });
1272
+ it('Unevaluated on 2nd level is invalid', async () => {
1273
+ const result = await parseSetup(toContent({ x: { x: {}, y: {} } }));
1274
+ (0, chai_1.expect)(result).to.have.length(1);
1275
+ (0, chai_1.expect)(result[0].message).to.include('Property y is not allowed.');
1276
+ });
1277
+ it('Deep nested is valid', async () => {
1278
+ (0, chai_1.expect)(await parseSetup(toContent({ x: { x: { x: {} } } }))).to.be.empty;
1279
+ });
1280
+ it('Unevaluated on 3rd level is invalid', async () => {
1281
+ const result = await parseSetup(toContent({ x: { x: { x: {}, y: {} } } }));
1282
+ (0, chai_1.expect)(result).to.have.length(1);
1283
+ (0, chai_1.expect)(result[0].message).to.include('Property y is not allowed.');
1284
+ });
1285
+ });
1286
+ describe('unevaluatedProperties + ref inside allOf / oneOf', () => {
1287
+ const schema = {
1288
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1289
+ $defs: {
1290
+ one: {
1291
+ properties: { a: true },
1292
+ },
1293
+ two: {
1294
+ required: ['x'],
1295
+ properties: { x: true },
1296
+ },
1297
+ },
1298
+ allOf: [
1299
+ { $ref: '#/$defs/one' },
1300
+ { properties: { b: true } },
1301
+ {
1302
+ oneOf: [
1303
+ { $ref: '#/$defs/two' },
1304
+ {
1305
+ required: ['y'],
1306
+ properties: { y: true },
1307
+ },
1308
+ ],
1309
+ },
1310
+ ],
1311
+ unevaluatedProperties: false,
1312
+ };
1313
+ beforeEach(() => {
1314
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1315
+ });
1316
+ it('Empty is invalid (no x or y)', async () => {
1317
+ const result = await parseSetup(toContent({}));
1318
+ (0, chai_1.expect)(result).to.have.length(1);
1319
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
1320
+ (0, chai_1.expect)(result[0].message).to.include('x');
1321
+ });
1322
+ it('a and b are invalid (no x or y)', async () => {
1323
+ const result = await parseSetup(toContent({ a: 1, b: 1 }));
1324
+ (0, chai_1.expect)(result).to.have.length(1);
1325
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
1326
+ (0, chai_1.expect)(result[0].message).to.include('x');
1327
+ });
1328
+ it('x and y are invalid', async () => {
1329
+ const result = await parseSetup(toContent({ x: 1, y: 1 }));
1330
+ (0, chai_1.expect)(result).to.have.length(1);
1331
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1332
+ });
1333
+ it('a and x are valid', async () => {
1334
+ (0, chai_1.expect)(await parseSetup(toContent({ a: 1, x: 1 }))).to.be.empty;
1335
+ });
1336
+ it('a and y are valid', async () => {
1337
+ (0, chai_1.expect)(await parseSetup(toContent({ a: 1, y: 1 }))).to.be.empty;
1338
+ });
1339
+ it('a and b and x are valid', async () => {
1340
+ (0, chai_1.expect)(await parseSetup(toContent({ a: 1, b: 1, x: 1 }))).to.be.empty;
1341
+ });
1342
+ it('a and b and y are valid', async () => {
1343
+ (0, chai_1.expect)(await parseSetup(toContent({ a: 1, b: 1, y: 1 }))).to.be.empty;
1344
+ });
1345
+ it('a and b and x and y are invalid', async () => {
1346
+ const result = await parseSetup(toContent({ a: 1, b: 1, x: 1, y: 1 }));
1347
+ (0, chai_1.expect)(result).to.have.length(1);
1348
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1349
+ });
1350
+ });
1351
+ describe('dynamic evalation inside nested refs', () => {
1352
+ const schema = {
1353
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1354
+ $defs: {
1355
+ one: {
1356
+ oneOf: [
1357
+ { $ref: '#/$defs/two' },
1358
+ { required: ['b'], properties: { b: true } },
1359
+ { required: ['xx'], patternProperties: { x: true } },
1360
+ { required: ['all'], unevaluatedProperties: true },
1361
+ ],
1362
+ },
1363
+ two: {
1364
+ oneOf: [
1365
+ { required: ['c'], properties: { c: true } },
1366
+ { required: ['d'], properties: { d: true } },
1367
+ ],
1368
+ },
1369
+ },
1370
+ oneOf: [{ $ref: '#/$defs/one' }, { required: ['a'], properties: { a: true } }],
1371
+ unevaluatedProperties: false,
1372
+ };
1373
+ beforeEach(() => {
1374
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1375
+ });
1376
+ it('Empty is invalid', async () => {
1377
+ const result = await parseSetup(toContent({}));
1378
+ (0, chai_1.expect)(result).to.have.length(1);
1379
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
1380
+ });
1381
+ it('a is valid', async () => {
1382
+ (0, chai_1.expect)(await parseSetup(toContent({ a: 1 }))).to.be.empty;
1383
+ });
1384
+ it('b is valid', async () => {
1385
+ (0, chai_1.expect)(await parseSetup(toContent({ b: 1 }))).to.be.empty;
1386
+ });
1387
+ it('c is valid', async () => {
1388
+ (0, chai_1.expect)(await parseSetup(toContent({ c: 1 }))).to.be.empty;
1389
+ });
1390
+ it('d is valid', async () => {
1391
+ (0, chai_1.expect)(await parseSetup(toContent({ d: 1 }))).to.be.empty;
1392
+ });
1393
+ it('a + b is invalid', async () => {
1394
+ const result = await parseSetup(toContent({ a: 1, b: 1 }));
1395
+ (0, chai_1.expect)(result).to.have.length(1);
1396
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1397
+ });
1398
+ it('a + c is invalid', async () => {
1399
+ const result = await parseSetup(toContent({ a: 1, c: 1 }));
1400
+ (0, chai_1.expect)(result).to.have.length(1);
1401
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1402
+ });
1403
+ it('a + d is invalid', async () => {
1404
+ const result = await parseSetup(toContent({ a: 1, d: 1 }));
1405
+ (0, chai_1.expect)(result).to.have.length(1);
1406
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1407
+ });
1408
+ it('b + c is invalid', async () => {
1409
+ const result = await parseSetup(toContent({ b: 1, c: 1 }));
1410
+ (0, chai_1.expect)(result).to.have.length(1);
1411
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1412
+ });
1413
+ it('b + d is invalid', async () => {
1414
+ const result = await parseSetup(toContent({ b: 1, d: 1 }));
1415
+ (0, chai_1.expect)(result).to.have.length(1);
1416
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1417
+ });
1418
+ it('c + d is invalid', async () => {
1419
+ const result = await parseSetup(toContent({ c: 1, d: 1 }));
1420
+ (0, chai_1.expect)(result).to.have.length(1);
1421
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1422
+ });
1423
+ it('xx is valid', async () => {
1424
+ (0, chai_1.expect)(await parseSetup(toContent({ xx: 1 }))).to.be.empty;
1425
+ });
1426
+ it('xx + foox is valid', async () => {
1427
+ (0, chai_1.expect)(await parseSetup(toContent({ xx: 1, foox: 1 }))).to.be.empty;
1428
+ });
1429
+ it('xx + foo is invalid', async () => {
1430
+ const result = await parseSetup(toContent({ xx: 1, foo: 1 }));
1431
+ (0, chai_1.expect)(result).to.have.length(1);
1432
+ (0, chai_1.expect)(result[0].message).to.include('Property foo is not allowed.');
1433
+ });
1434
+ it('xx + a is invalid', async () => {
1435
+ const result = await parseSetup(toContent({ xx: 1, a: 1 }));
1436
+ (0, chai_1.expect)(result).to.have.length(1);
1437
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1438
+ });
1439
+ it('xx + b is invalid', async () => {
1440
+ const result = await parseSetup(toContent({ xx: 1, b: 1 }));
1441
+ (0, chai_1.expect)(result).to.have.length(1);
1442
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1443
+ });
1444
+ it('xx + c is invalid', async () => {
1445
+ const result = await parseSetup(toContent({ xx: 1, c: 1 }));
1446
+ (0, chai_1.expect)(result).to.have.length(1);
1447
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1448
+ });
1449
+ it('xx + d is invalid', async () => {
1450
+ const result = await parseSetup(toContent({ xx: 1, d: 1 }));
1451
+ (0, chai_1.expect)(result).to.have.length(1);
1452
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1453
+ });
1454
+ it('all is valid', async () => {
1455
+ (0, chai_1.expect)(await parseSetup(toContent({ all: 1 }))).to.be.empty;
1456
+ });
1457
+ it('all + foo is valid', async () => {
1458
+ (0, chai_1.expect)(await parseSetup(toContent({ all: 1, foo: 1 }))).to.be.empty;
1459
+ });
1460
+ it('all + a is invalid', async () => {
1461
+ const result = await parseSetup(toContent({ all: 1, a: 1 }));
1462
+ (0, chai_1.expect)(result).to.have.length(1);
1463
+ (0, chai_1.expect)(result[0].message).to.include('Matches multiple schemas when only one must validate.');
1464
+ });
1465
+ });
1466
+ it('non-object instances are valid', async () => {
1467
+ const schema = {
1468
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1469
+ unevaluatedProperties: false,
1470
+ };
1471
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1472
+ (0, chai_1.expect)(await parseSetup(toContent(true))).to.be.empty;
1473
+ (0, chai_1.expect)(await parseSetup(toContent(123))).to.be.empty;
1474
+ (0, chai_1.expect)(await parseSetup(toContent(1.0))).to.be.empty;
1475
+ (0, chai_1.expect)(await parseSetup(toContent([]))).to.be.empty;
1476
+ (0, chai_1.expect)(await parseSetup(toContent('foo'))).to.be.empty;
1477
+ (0, chai_1.expect)(await parseSetup(toContent(null))).to.be.empty;
1478
+ });
1479
+ it('unevaluatedProperties with null valued instance properties', async () => {
1480
+ const schema = {
1481
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1482
+ unevaluatedProperties: {
1483
+ type: 'null',
1484
+ },
1485
+ };
1486
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1487
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: null }))).to.be.empty;
1488
+ });
1489
+ it('unevaluatedProperties not affected by propertyNames', async () => {
1490
+ const schema = {
1491
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1492
+ propertyNames: { maxLength: 1 },
1493
+ unevaluatedProperties: {
1494
+ type: 'number',
1495
+ },
1496
+ };
1497
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1498
+ (0, chai_1.expect)(await parseSetup(toContent({ a: 1 }))).to.be.empty;
1499
+ const result = await parseSetup(toContent({ a: 'b' }));
1500
+ (0, chai_1.expect)(result).to.have.length(1);
1501
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
1502
+ (0, chai_1.expect)(result[0].message).to.include('number');
1503
+ });
1504
+ it('unevaluatedProperties can see annotations from if without then and else', async () => {
1505
+ const schema = {
1506
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1507
+ if: {
1508
+ patternProperties: {
1509
+ foo: {
1510
+ type: 'string',
1511
+ },
1512
+ },
1513
+ },
1514
+ unevaluatedProperties: false,
1515
+ };
1516
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1517
+ (0, chai_1.expect)(await parseSetup(toContent({ foo: 'a' }))).to.be.empty;
1518
+ const result = await parseSetup(toContent({ bar: 'a' }));
1519
+ (0, chai_1.expect)(result).to.have.length(1);
1520
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
1521
+ });
1522
+ it('dependentSchemas with unevaluatedProperties', async () => {
1523
+ const schema = {
1524
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1525
+ properties: { foo2: {} },
1526
+ dependentSchemas: {
1527
+ foo: {},
1528
+ foo2: {
1529
+ properties: {
1530
+ bar: {},
1531
+ },
1532
+ },
1533
+ },
1534
+ unevaluatedProperties: false,
1535
+ };
1536
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1537
+ const result1 = await parseSetup(toContent({ foo: '' }));
1538
+ (0, chai_1.expect)(result1).to.have.length(1);
1539
+ (0, chai_1.expect)(result1[0].message).to.include('Property foo is not allowed.');
1540
+ const result2 = await parseSetup(toContent({ bar: '' }));
1541
+ (0, chai_1.expect)(result2).to.have.length(1);
1542
+ (0, chai_1.expect)(result2[0].message).to.include('Property bar is not allowed.');
1543
+ (0, chai_1.expect)(await parseSetup(toContent({ foo2: '', bar: '' }))).to.be.empty;
1544
+ });
1545
+ it('Evaluated properties collection needs to consider instance location', async () => {
1546
+ const schema = {
1547
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1548
+ properties: {
1549
+ foo: {
1550
+ properties: {
1551
+ bar: { type: 'string' },
1552
+ },
1553
+ },
1554
+ },
1555
+ unevaluatedProperties: false,
1556
+ };
1557
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1558
+ const result = await parseSetup(toContent({ foo: { bar: 'foo' }, bar: 'bar' }));
1559
+ (0, chai_1.expect)(result).to.have.length(1);
1560
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
1561
+ });
1562
+ });
1563
+ describe('keyword: unevaluatedItems', () => {
1564
+ it('unevaluatedItems true', async () => {
1565
+ const schema = {
1566
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1567
+ unevaluatedItems: true,
1568
+ };
1569
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1570
+ (0, chai_1.expect)(await parseSetup(`[]`)).to.be.empty;
1571
+ (0, chai_1.expect)(await parseSetup(`- foo`)).to.be.empty;
1572
+ });
1573
+ it('unevaluatedItems false', async () => {
1574
+ const schema = {
1575
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1576
+ unevaluatedItems: false,
1577
+ };
1578
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1579
+ (0, chai_1.expect)(await parseSetup(`[]`)).to.be.empty;
1580
+ const content = `- foo`;
1581
+ const result = await parseSetup(content);
1582
+ (0, chai_1.expect)(result).to.have.length(1);
1583
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 0 or fewer.');
1584
+ });
1585
+ it('unevaluatedItems as schema', async () => {
1586
+ const schema = {
1587
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1588
+ unevaluatedItems: { type: 'string' },
1589
+ };
1590
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1591
+ (0, chai_1.expect)(await parseSetup(`[]`)).to.be.empty;
1592
+ (0, chai_1.expect)(await parseSetup(`- foo`)).to.be.empty;
1593
+ const result = await parseSetup(`- 42`);
1594
+ (0, chai_1.expect)(result).to.have.length(1);
1595
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type. Expected');
1596
+ (0, chai_1.expect)(result[0].message).to.include('string');
1597
+ });
1598
+ it('unevaluatedItems with uniform items', async () => {
1599
+ const schema = {
1600
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1601
+ items: { type: 'string' },
1602
+ unevaluatedItems: false,
1603
+ };
1604
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1605
+ const content = `- foo\n- bar`;
1606
+ const result = await parseSetup(content);
1607
+ (0, chai_1.expect)(result).to.be.empty;
1608
+ });
1609
+ it('unevaluatedItems with tuple', async () => {
1610
+ const schema = {
1611
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1612
+ items: [{ type: 'string' }],
1613
+ unevaluatedItems: false,
1614
+ };
1615
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1616
+ (0, chai_1.expect)(await parseSetup(`- foo`)).to.be.empty;
1617
+ const content = `- foo\n- bar`;
1618
+ const result = await parseSetup(content);
1619
+ (0, chai_1.expect)(result).to.have.length(1);
1620
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 1 or fewer.');
1621
+ });
1622
+ it('unevaluatedItems with items and additionalItems', async () => {
1623
+ const schema = {
1624
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1625
+ items: [{ type: 'string' }],
1626
+ additionalItems: true,
1627
+ unevaluatedItems: false,
1628
+ };
1629
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1630
+ const content = `- foo\n- 42`;
1631
+ const result = await parseSetup(content);
1632
+ (0, chai_1.expect)(result).to.be.empty;
1633
+ });
1634
+ it('unevaluatedItems with ignored additionalItems', async () => {
1635
+ const schema = {
1636
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1637
+ additionalItems: { type: 'number' },
1638
+ unevaluatedItems: { type: 'string' },
1639
+ };
1640
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1641
+ const content = `- foo\n- 1`;
1642
+ const result = await parseSetup(content);
1643
+ (0, chai_1.expect)(result).to.have.length(1);
1644
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type. Expected');
1645
+ (0, chai_1.expect)(result[0].message).to.include('string');
1646
+ (0, chai_1.expect)(await parseSetup(`- foo\n- bar\n- baz`)).to.be.empty;
1647
+ });
1648
+ it('unevaluatedItems with ignored applicator additionalItems', async () => {
1649
+ const schema = {
1650
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1651
+ allOf: [{ additionalItems: { type: 'number' } }],
1652
+ unevaluatedItems: { type: 'string' },
1653
+ };
1654
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1655
+ const content = `- foo\n- 1`;
1656
+ const result = await parseSetup(content);
1657
+ (0, chai_1.expect)(result).to.have.length(1);
1658
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type. Expected');
1659
+ (0, chai_1.expect)(result[0].message).to.include('string');
1660
+ (0, chai_1.expect)(await parseSetup(`- foo\n- bar\n- baz`)).to.be.empty;
1661
+ });
1662
+ it('unevaluatedItems with nested tuple', async () => {
1663
+ const schema = {
1664
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1665
+ items: [{ type: 'string' }],
1666
+ allOf: [
1667
+ {
1668
+ items: [true, { type: 'number' }],
1669
+ },
1670
+ ],
1671
+ unevaluatedItems: false,
1672
+ };
1673
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1674
+ (0, chai_1.expect)(await parseSetup(`- foo\n- 42`)).to.be.empty;
1675
+ const content = `- foo\n- 42\n- true`;
1676
+ const result = await parseSetup(content);
1677
+ (0, chai_1.expect)(result).to.have.length(1);
1678
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 2 or fewer.');
1679
+ });
1680
+ it('unevaluatedItems with nested items', async () => {
1681
+ const schema = {
1682
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1683
+ unevaluatedItems: { type: 'boolean' },
1684
+ anyOf: [{ items: { type: 'string' } }, true],
1685
+ };
1686
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1687
+ const content1 = `- true\n- false`;
1688
+ const result1 = await parseSetup(content1);
1689
+ (0, chai_1.expect)(result1).to.be.empty;
1690
+ const content2 = `- "yes"\n- false`;
1691
+ const result2 = await parseSetup(content2);
1692
+ (0, chai_1.expect)(result2).to.have.length(1);
1693
+ (0, chai_1.expect)(result2[0].message).to.include('Incorrect type.');
1694
+ const content3 = `- "yes"\n- "no"`;
1695
+ const result3 = await parseSetup(content3);
1696
+ (0, chai_1.expect)(result3).to.be.empty;
1697
+ });
1698
+ it('unevaluatedItems with nested items and additionalItems', async () => {
1699
+ const schema = {
1700
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1701
+ allOf: [
1702
+ {
1703
+ items: [{ type: 'string' }],
1704
+ additionalItems: true,
1705
+ },
1706
+ ],
1707
+ unevaluatedItems: false,
1708
+ };
1709
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1710
+ (0, chai_1.expect)(await parseSetup(`- foo`)).to.be.empty;
1711
+ (0, chai_1.expect)(await parseSetup(`- foo\n- 42\n- true`)).to.be.empty;
1712
+ });
1713
+ it('unevaluatedItems with nested unevaluatedItems', async () => {
1714
+ const schema = {
1715
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1716
+ allOf: [
1717
+ {
1718
+ items: [{ type: 'string' }],
1719
+ },
1720
+ { unevaluatedItems: true },
1721
+ ],
1722
+ unevaluatedItems: false,
1723
+ };
1724
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1725
+ (0, chai_1.expect)(await parseSetup(`- foo`)).to.be.empty;
1726
+ const content = `- foo\n- 42\n- true`;
1727
+ const result = await parseSetup(content);
1728
+ (0, chai_1.expect)(result).to.be.empty;
1729
+ });
1730
+ it('unevaluatedItems with anyOf', async () => {
1731
+ const schema = {
1732
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1733
+ items: [{ const: 'foo' }],
1734
+ anyOf: [
1735
+ {
1736
+ items: [true, { const: 'bar' }],
1737
+ },
1738
+ {
1739
+ items: [true, true, { const: 'baz' }],
1740
+ },
1741
+ ],
1742
+ unevaluatedItems: false,
1743
+ };
1744
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1745
+ const content1 = `- foo\n- bar`;
1746
+ const result1 = await parseSetup(content1);
1747
+ (0, chai_1.expect)(result1).to.be.empty;
1748
+ const content2 = `- foo\n- bar\n- 42`;
1749
+ const result2 = await parseSetup(content2);
1750
+ (0, chai_1.expect)(result2).to.have.length(1);
1751
+ (0, chai_1.expect)(result2[0].message).to.include('Array has too many items according to schema. Expected 2 or fewer.');
1752
+ const content3 = `- foo\n- bar\n- baz`;
1753
+ const result3 = await parseSetup(content3);
1754
+ (0, chai_1.expect)(result3).to.be.empty;
1755
+ const content4 = `- foo\n- bar\n- baz\n- 42`;
1756
+ const result4 = await parseSetup(content4);
1757
+ (0, chai_1.expect)(result4).to.have.length(1);
1758
+ (0, chai_1.expect)(result4[0].message).to.include('Array has too many items according to schema. Expected 3 or fewer.');
1759
+ });
1760
+ it('unevaluatedItems with oneOf', async () => {
1761
+ const schema = {
1762
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1763
+ items: [{ const: 'foo' }],
1764
+ oneOf: [
1765
+ {
1766
+ items: [true, { const: 'bar' }],
1767
+ },
1768
+ {
1769
+ items: [true, { const: 'baz' }],
1770
+ },
1771
+ ],
1772
+ unevaluatedItems: false,
1773
+ };
1774
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1775
+ (0, chai_1.expect)(await parseSetup(`- foo\n- bar`)).to.be.empty;
1776
+ const content = `- foo\n- bar\n- 42`;
1777
+ const result = await parseSetup(content);
1778
+ (0, chai_1.expect)(result).to.have.length(1);
1779
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 2 or fewer.');
1780
+ });
1781
+ it('unevaluatedItems with not', async () => {
1782
+ const schema = {
1783
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1784
+ items: [{ const: 'foo' }],
1785
+ not: {
1786
+ not: {
1787
+ items: [true, { const: 'bar' }],
1788
+ },
1789
+ },
1790
+ unevaluatedItems: false,
1791
+ };
1792
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1793
+ const content = `- foo\n- bar`;
1794
+ const result = await parseSetup(content);
1795
+ (0, chai_1.expect)(result).to.have.length(1);
1796
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 1 or fewer.');
1797
+ });
1798
+ it('unevaluatedItems with if/then/else', async () => {
1799
+ const schema = {
1800
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1801
+ items: [{ const: 'foo' }],
1802
+ if: {
1803
+ items: [true, { const: 'bar' }],
1804
+ },
1805
+ then: {
1806
+ items: [true, true, { const: 'then' }],
1807
+ },
1808
+ else: {
1809
+ items: [true, true, true, { const: 'else' }],
1810
+ },
1811
+ unevaluatedItems: false,
1812
+ };
1813
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1814
+ const result1 = await parseSetup(`- foo\n- bar\n- then`);
1815
+ (0, chai_1.expect)(result1).to.be.empty;
1816
+ const result2 = await parseSetup(`- foo\n- bar\n- then\n- else`);
1817
+ (0, chai_1.expect)(result2).to.have.length(1);
1818
+ (0, chai_1.expect)(result2[0].message).to.include('Array has too many items according to schema. Expected 3 or fewer.');
1819
+ const result3 = await parseSetup(`- foo\n- 42\n- 42\n- else`);
1820
+ (0, chai_1.expect)(result3).to.be.empty;
1821
+ const result = await parseSetup(`- foo\n- 42\n- 42\n- else\n- 42`);
1822
+ (0, chai_1.expect)(result).to.have.length(1);
1823
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 4 or fewer.');
1824
+ });
1825
+ it('unevaluatedItems with boolean schemas', async () => {
1826
+ const schema = {
1827
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1828
+ allOf: [true],
1829
+ unevaluatedItems: false,
1830
+ };
1831
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1832
+ (0, chai_1.expect)(await parseSetup(`[]`)).to.be.empty;
1833
+ const content = `- foo`;
1834
+ const result = await parseSetup(content);
1835
+ (0, chai_1.expect)(result).to.have.length(1);
1836
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 0 or fewer.');
1837
+ });
1838
+ it('unevaluatedItems with $ref', async () => {
1839
+ const schema = {
1840
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1841
+ $ref: '#/$defs/bar',
1842
+ items: [{ type: 'string' }],
1843
+ unevaluatedItems: false,
1844
+ $defs: {
1845
+ bar: {
1846
+ items: [true, { type: 'string' }],
1847
+ },
1848
+ },
1849
+ };
1850
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1851
+ (0, chai_1.expect)(await parseSetup(`- foo\n- bar`)).to.be.empty;
1852
+ const content = `- foo\n- bar\n- baz`;
1853
+ const result = await parseSetup(content);
1854
+ (0, chai_1.expect)(result).to.have.length(1);
1855
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 2 or fewer.');
1856
+ });
1857
+ it('unevaluatedItems before $ref', async () => {
1858
+ const schema = {
1859
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1860
+ unevaluatedItems: false,
1861
+ items: [{ type: 'string' }],
1862
+ $ref: '#/$defs/bar',
1863
+ $defs: {
1864
+ bar: {
1865
+ items: [true, { type: 'string' }],
1866
+ },
1867
+ },
1868
+ };
1869
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1870
+ (0, chai_1.expect)(await parseSetup(`- foo\n- bar`)).to.be.empty;
1871
+ const content = `- foo\n- bar\n- baz`;
1872
+ const result = await parseSetup(content);
1873
+ (0, chai_1.expect)(result).to.have.length(1);
1874
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 2 or fewer.');
1875
+ });
1876
+ it('unevaluatedItems with $recursiveRef', async () => {
1877
+ const schema = {
1878
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1879
+ $id: 'https://example.com/unevaluated-items-with-recursive-ref/extended-tree',
1880
+ $recursiveAnchor: true,
1881
+ $ref: './tree',
1882
+ items: [true, true, { type: 'string' }],
1883
+ $defs: {
1884
+ tree: {
1885
+ $id: './tree',
1886
+ $recursiveAnchor: true,
1887
+ type: 'array',
1888
+ items: [
1889
+ { type: 'number' },
1890
+ {
1891
+ unevaluatedItems: false,
1892
+ $recursiveRef: '#',
1893
+ },
1894
+ ],
1895
+ },
1896
+ },
1897
+ };
1898
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1899
+ (0, chai_1.expect)(await parseSetup(`- 1\n- - 2\n - []\n - b\n- a`)).to.be.empty;
1900
+ const content = `- 1\n- - 2\n - []\n - b\n - too many\n- a`;
1901
+ const result = await parseSetup(content);
1902
+ (0, chai_1.expect)(result).to.have.length(1);
1903
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 3 or fewer.');
1904
+ });
1905
+ it("unevaluatedItems can't see inside cousins", async () => {
1906
+ const schema = {
1907
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1908
+ allOf: [{ items: [true] }, { unevaluatedItems: false }],
1909
+ };
1910
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1911
+ const content = `- 1`;
1912
+ const result = await parseSetup(content);
1913
+ (0, chai_1.expect)(result).to.have.length(1);
1914
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 0 or fewer.');
1915
+ });
1916
+ it('item is evaluated in an uncle schema to unevaluatedItems', async () => {
1917
+ const schema = {
1918
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1919
+ properties: {
1920
+ foo: {
1921
+ items: [{ type: 'string' }],
1922
+ unevaluatedItems: false,
1923
+ },
1924
+ },
1925
+ anyOf: [
1926
+ {
1927
+ properties: {
1928
+ foo: {
1929
+ items: [true, { type: 'string' }],
1930
+ },
1931
+ },
1932
+ },
1933
+ ],
1934
+ };
1935
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1936
+ (0, chai_1.expect)(await parseSetup(`foo:\n - test`)).to.be.empty;
1937
+ const content = `foo:\n - test\n - test`;
1938
+ const result = await parseSetup(content);
1939
+ (0, chai_1.expect)(result).to.have.length(1);
1940
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 1 or fewer.');
1941
+ });
1942
+ describe('non-array instances are valid', () => {
1943
+ it('', async () => {
1944
+ const schema = {
1945
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1946
+ unevaluatedItems: false,
1947
+ };
1948
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1949
+ const content = `true`;
1950
+ const result = await parseSetup(content);
1951
+ (0, chai_1.expect)(result).to.be.empty;
1952
+ });
1953
+ it('ignores integers', async () => {
1954
+ const schema = {
1955
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1956
+ unevaluatedItems: false,
1957
+ };
1958
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1959
+ const content = `123`;
1960
+ const result = await parseSetup(content);
1961
+ (0, chai_1.expect)(result).to.be.empty;
1962
+ });
1963
+ it('ignores floats', async () => {
1964
+ const schema = {
1965
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1966
+ unevaluatedItems: false,
1967
+ };
1968
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1969
+ const content = `1.0`;
1970
+ const result = await parseSetup(content);
1971
+ (0, chai_1.expect)(result).to.be.empty;
1972
+ });
1973
+ it('ignores objects', async () => {
1974
+ const schema = {
1975
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1976
+ unevaluatedItems: false,
1977
+ };
1978
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1979
+ const content = `{}`;
1980
+ const result = await parseSetup(content);
1981
+ (0, chai_1.expect)(result).to.be.empty;
1982
+ });
1983
+ it('ignores strings', async () => {
1984
+ const schema = {
1985
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1986
+ unevaluatedItems: false,
1987
+ };
1988
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1989
+ const content = `foo`;
1990
+ const result = await parseSetup(content);
1991
+ (0, chai_1.expect)(result).to.be.empty;
1992
+ });
1993
+ it('ignores null', async () => {
1994
+ const schema = {
1995
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
1996
+ unevaluatedItems: false,
1997
+ };
1998
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
1999
+ const content = `null`;
2000
+ const result = await parseSetup(content);
2001
+ (0, chai_1.expect)(result).to.be.empty;
2002
+ });
2003
+ });
2004
+ it('unevaluatedItems with null instance elements', async () => {
2005
+ const schema = {
2006
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2007
+ unevaluatedItems: {
2008
+ type: 'null',
2009
+ },
2010
+ };
2011
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2012
+ const content = `- null`;
2013
+ const result = await parseSetup(content);
2014
+ (0, chai_1.expect)(result).to.be.empty;
2015
+ });
2016
+ it('unevaluatedItems can see annotations from if without then and else', async () => {
2017
+ const schema = {
2018
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2019
+ if: {
2020
+ items: [{ const: 'a' }],
2021
+ },
2022
+ unevaluatedItems: false,
2023
+ };
2024
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2025
+ (0, chai_1.expect)(await parseSetup(`- a`)).to.be.empty;
2026
+ const content = `- b`;
2027
+ const result = await parseSetup(content);
2028
+ (0, chai_1.expect)(result).to.have.length(1);
2029
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 0 or fewer.');
2030
+ });
2031
+ it('Evaluated items collection needs to consider instance location', async () => {
2032
+ const schema = {
2033
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2034
+ items: [
2035
+ {
2036
+ items: [true, { type: 'string' }],
2037
+ },
2038
+ ],
2039
+ unevaluatedItems: false,
2040
+ };
2041
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2042
+ const content = `- - foo\n - bar\n- bar`;
2043
+ const result = await parseSetup(content);
2044
+ (0, chai_1.expect)(result).to.have.length(1);
2045
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items according to schema. Expected 1 or fewer.');
2046
+ });
2047
+ });
2048
+ describe('keyword: contains + minContains/maxContains', () => {
2049
+ it('minContains fails when too few items match contains subschema', async () => {
2050
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2051
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2052
+ type: 'array',
2053
+ contains: {
2054
+ type: 'object',
2055
+ properties: {
2056
+ kind: { const: 'ok' },
2057
+ id: { type: 'number' },
2058
+ },
2059
+ required: ['kind', 'id'],
2060
+ },
2061
+ minContains: 2,
2062
+ });
2063
+ const content = `- kind: ok\n id: 1\n- kind: ok\n id: "2"\n- kind: nope\n id: 3`;
2064
+ const result = await parseSetup(content);
2065
+ (0, chai_1.expect)(result).to.have.length(1);
2066
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
2067
+ (0, chai_1.expect)(result[0].message).to.include('contains');
2068
+ (0, chai_1.expect)(result[0].message).to.include('Expected 2 or more.');
2069
+ });
2070
+ it('maxContains fails when too many items match contains subschema', async () => {
2071
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2072
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2073
+ type: 'array',
2074
+ contains: {
2075
+ type: 'object',
2076
+ properties: {
2077
+ kind: { const: 'ok' },
2078
+ id: { type: 'number' },
2079
+ },
2080
+ required: ['kind', 'id'],
2081
+ },
2082
+ maxContains: 3,
2083
+ });
2084
+ const content = `- kind: ok\n id: 1\n- kind: ok\n id: 2\n- kind: ok\n id: 3\n- kind: ok\n id: 4`;
2085
+ const result = await parseSetup(content);
2086
+ (0, chai_1.expect)(result).to.have.length(1);
2087
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items matching');
2088
+ (0, chai_1.expect)(result[0].message).to.include('contains');
2089
+ (0, chai_1.expect)(result[0].message).to.include('Expected 3 or fewer.');
2090
+ });
2091
+ it('minContains/maxContains passes when match count is within bounds', async () => {
2092
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2093
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2094
+ type: 'array',
2095
+ contains: {
2096
+ type: 'object',
2097
+ properties: {
2098
+ kind: { const: 'ok' },
2099
+ id: { type: 'number' },
2100
+ },
2101
+ required: ['kind', 'id'],
2102
+ },
2103
+ minContains: 2,
2104
+ maxContains: 3,
2105
+ });
2106
+ const content = `
2107
+ - kind: ok
2108
+ id: 1
2109
+ - kind: ok
2110
+ id: 2
2111
+ - kind: nope
2112
+ id: 3
2113
+ `;
2114
+ const result = await parseSetup(content);
2115
+ (0, chai_1.expect)(result).to.be.empty;
2116
+ });
2117
+ it('contains matching is based on subschema, not just item type', async () => {
2118
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2119
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2120
+ type: 'array',
2121
+ contains: {
2122
+ type: 'object',
2123
+ required: ['tag'],
2124
+ properties: {
2125
+ tag: { const: 'match' },
2126
+ },
2127
+ },
2128
+ minContains: 1,
2129
+ });
2130
+ const okYaml = `
2131
+ - tag: other
2132
+ - tag: match
2133
+ - nope: 1
2134
+ `;
2135
+ let result = await parseSetup(okYaml);
2136
+ (0, chai_1.expect)(result).to.be.empty;
2137
+ const badYaml = `
2138
+ - tag: other
2139
+ - tag: nope
2140
+ - nope: 1`;
2141
+ result = await parseSetup(badYaml);
2142
+ (0, chai_1.expect)(result).to.have.length(1);
2143
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
2144
+ (0, chai_1.expect)(result[0].message).to.include('contains');
2145
+ (0, chai_1.expect)(result[0].message).to.include('Expected 1 or more.');
2146
+ });
2147
+ });
2148
+ describe('keyword: dependentRequired', () => {
2149
+ beforeEach(() => {
2150
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2151
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2152
+ type: 'object',
2153
+ properties: {
2154
+ billing_address: { type: 'string' },
2155
+ credit_card: { type: 'string' },
2156
+ },
2157
+ dependentRequired: {
2158
+ billing_address: ['credit_card'],
2159
+ },
2160
+ });
2161
+ });
2162
+ it('requires dependent properties when the trigger property is present', async () => {
2163
+ const content = `billing_address: "123 King St"`;
2164
+ const result = await parseSetup(content);
2165
+ (0, chai_1.expect)(result).to.have.length(1);
2166
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property credit_card required by property billing_address.');
2167
+ });
2168
+ it('passes when required dependent properties are present', async () => {
2169
+ const content = `billing_address: "123 King St"\ncredit_card: "4111-1111"`;
2170
+ const result = await parseSetup(content);
2171
+ (0, chai_1.expect)(result).to.be.empty;
2172
+ });
2173
+ });
2174
+ describe('keyword: dependentSchemas', () => {
2175
+ it('does not apply when the trigger property is absent', async () => {
2176
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2177
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2178
+ type: 'object',
2179
+ properties: {
2180
+ kind: { type: 'string' },
2181
+ port: { type: 'number' },
2182
+ },
2183
+ dependentSchemas: {
2184
+ kind: { required: ['port'] },
2185
+ },
2186
+ });
2187
+ const content = `port: 8080`;
2188
+ const result = await parseSetup(content);
2189
+ (0, chai_1.expect)(result).to.be.empty;
2190
+ });
2191
+ it('applies dependent schema when the trigger property is present', async () => {
2192
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2193
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2194
+ type: 'object',
2195
+ properties: {
2196
+ kind: { type: 'string' },
2197
+ port: { type: 'number' },
2198
+ },
2199
+ dependentSchemas: {
2200
+ kind: { required: ['port'] },
2201
+ },
2202
+ });
2203
+ const content = `kind: service`;
2204
+ const result = await parseSetup(content);
2205
+ (0, chai_1.expect)(result).to.have.length(1);
2206
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
2207
+ (0, chai_1.expect)(result[0].message).to.include('port');
2208
+ });
2209
+ it('can enforce additional constraints from the dependent schema', async () => {
2210
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2211
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2212
+ type: 'object',
2213
+ properties: {
2214
+ tls: { type: 'boolean' },
2215
+ port: { type: 'number' },
2216
+ },
2217
+ dependentSchemas: {
2218
+ tls: {
2219
+ required: ['port'],
2220
+ properties: {
2221
+ port: { minimum: 1024 },
2222
+ },
2223
+ },
2224
+ },
2225
+ });
2226
+ const content = `tls: true\nport: 80`;
2227
+ const result = await parseSetup(content);
2228
+ (0, chai_1.expect)(result).to.have.length(1);
2229
+ (0, chai_1.expect)(result[0].message).to.include('Value is below the minimum of 1024.');
2230
+ });
2231
+ it('applies multiple dependentSchemas when multiple triggers are present', async () => {
2232
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2233
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2234
+ type: 'object',
2235
+ properties: {
2236
+ kind: { type: 'string' },
2237
+ tls: { type: 'boolean' },
2238
+ port: { type: 'number' },
2239
+ },
2240
+ dependentSchemas: {
2241
+ kind: { required: ['port'] },
2242
+ tls: {
2243
+ required: ['port'],
2244
+ properties: { port: { minimum: 1024 } },
2245
+ },
2246
+ },
2247
+ });
2248
+ const content = `kind: service\ntls: true\nport: 80`;
2249
+ const result = await parseSetup(content);
2250
+ (0, chai_1.expect)(result).to.have.length(1);
2251
+ (0, chai_1.expect)(result[0].message).to.include('Value is below the minimum of 1024.');
2252
+ });
2253
+ });
2254
+ describe('keyword: dependencies (backward compatibility)', () => {
2255
+ describe('property dependencies tests', () => {
2256
+ beforeEach(() => {
2257
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2258
+ $schema: 'http://json-schema.org/draft-07/schema#',
2259
+ type: 'object',
2260
+ properties: {
2261
+ credit_card: { type: 'string' },
2262
+ billing_address: { type: 'string' },
2263
+ },
2264
+ dependencies: {
2265
+ credit_card: ['billing_address'],
2266
+ },
2267
+ });
2268
+ });
2269
+ it('requires dependent properties when the trigger property is present', async () => {
2270
+ const content = `credit_card: "4111-1111-1111-1111"`;
2271
+ const result = await parseSetup(content);
2272
+ (0, chai_1.expect)(result).to.have.length(1);
2273
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property billing_address required by property credit_card.');
2274
+ });
2275
+ it('does not apply when the trigger property is absent', async () => {
2276
+ const content = `billing_address: "123 Main St"`;
2277
+ const result = await parseSetup(content);
2278
+ (0, chai_1.expect)(result).to.be.empty;
2279
+ });
2280
+ });
2281
+ describe('schema dependencies tests', () => {
2282
+ beforeEach(() => {
2283
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2284
+ $schema: 'http://json-schema.org/draft-07/schema#',
2285
+ type: 'object',
2286
+ properties: {
2287
+ mode: { type: 'string' },
2288
+ port: { type: 'number' },
2289
+ },
2290
+ dependencies: {
2291
+ mode: {
2292
+ required: ['port'],
2293
+ properties: {
2294
+ port: { minimum: 1024 },
2295
+ },
2296
+ },
2297
+ },
2298
+ });
2299
+ });
2300
+ it('enforces dependent schema constraints when trigger property is present', async () => {
2301
+ const content = `mode: "server"\nport: 80`;
2302
+ const result = await parseSetup(content);
2303
+ (0, chai_1.expect)(result).to.have.length(1);
2304
+ (0, chai_1.expect)(result[0].message).to.include('Value is below the minimum of 1024.');
2305
+ });
2306
+ it('enforces dependent schema required properties when trigger property is present', async () => {
2307
+ const content = `mode: "server"`;
2308
+ const result = await parseSetup(content);
2309
+ (0, chai_1.expect)(result).to.have.length(1);
2310
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
2311
+ (0, chai_1.expect)(result[0].message).to.include('port');
2312
+ });
2313
+ it('does not apply the dependent schema when trigger property is absent', async () => {
2314
+ const content = `port: 80`;
2315
+ const result = await parseSetup(content);
2316
+ (0, chai_1.expect)(result).to.be.empty;
2317
+ });
2318
+ });
2319
+ });
2320
+ describe('$ref resolution should support sibling keywords', () => {
2321
+ it('should apply sibling keywords next to $ref', async () => {
2322
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2323
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2324
+ type: 'object',
2325
+ properties: {
2326
+ value: {
2327
+ $ref: '#/$defs/A',
2328
+ type: 'number',
2329
+ },
2330
+ },
2331
+ $defs: {
2332
+ A: { type: 'string' },
2333
+ },
2334
+ });
2335
+ // both should fail: must be both string and number
2336
+ (0, chai_1.expect)((await parseSetup(`value: hello`)).length).to.be.greaterThan(0);
2337
+ (0, chai_1.expect)((await parseSetup(`value: 1`)).length).to.be.greaterThan(0);
2338
+ });
2339
+ it('should apply sibling keywords next to $ref (top level)', async () => {
2340
+ const schema = {
2341
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2342
+ definitions: {
2343
+ obj1: {
2344
+ type: 'object',
2345
+ properties: {
2346
+ value: { type: 'string' },
2347
+ },
2348
+ required: ['value'],
2349
+ },
2350
+ },
2351
+ $ref: '#/definitions/obj1',
2352
+ additionalProperties: false,
2353
+ properties: {
2354
+ value: {},
2355
+ extra: { type: 'number' },
2356
+ },
2357
+ };
2358
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2359
+ const content = `value: hello
2360
+ extra: notANumber
2361
+ unknown: 1
2362
+ `;
2363
+ const result = await parseSetup(content);
2364
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type. Expected');
2365
+ (0, chai_1.expect)(result[0].message).to.include('number');
2366
+ (0, chai_1.expect)(result[1].message).to.include('Property unknown is not allowed.');
2367
+ });
2368
+ });
2369
+ describe('$id resolution', () => {
2370
+ it('$id inside an enum is not a real identifier (the implementation must not be confused by an $id buried in the enum)', async () => {
2371
+ const root = {
2372
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2373
+ $defs: {
2374
+ id_in_enum: {
2375
+ enum: [
2376
+ {
2377
+ $id: 'https://localhost:1234/draft2019-09/id/my_identifier.json',
2378
+ type: 'null',
2379
+ },
2380
+ ],
2381
+ },
2382
+ real_id_in_schema: {
2383
+ $id: 'https://localhost:1234/draft2019-09/id/my_identifier.json',
2384
+ type: 'string',
2385
+ },
2386
+ zzz_id_in_const: {
2387
+ const: {
2388
+ $id: 'https://localhost:1234/draft2019-09/id/my_identifier.json',
2389
+ type: 'null',
2390
+ },
2391
+ },
2392
+ },
2393
+ anyOf: [{ $ref: '#/$defs/id_in_enum' }, { $ref: 'https://localhost:1234/draft2019-09/id/my_identifier.json' }],
2394
+ };
2395
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, root);
2396
+ // exact match to enum, and type matches
2397
+ (0, chai_1.expect)(await parseSetup(toContent({
2398
+ $id: 'https://localhost:1234/draft2019-09/id/my_identifier.json',
2399
+ type: 'null',
2400
+ }))).to.be.empty;
2401
+ // match $ref to $id
2402
+ (0, chai_1.expect)(await parseSetup('a string to match #/$defs/id_in_enum')).to.be.empty;
2403
+ // no match on enum or $ref to $id
2404
+ const result = await parseSetup(`1`);
2405
+ (0, chai_1.expect)(result).to.have.length(1);
2406
+ (0, chai_1.expect)(result[0].message).to.include('Value is not accepted. Valid values:');
2407
+ });
2408
+ it('should resolve embedded resource $id for relative $ref without external load', async () => {
2409
+ const root = {
2410
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2411
+ type: 'object',
2412
+ properties: {
2413
+ x: { $ref: 'other.json#bar' },
2414
+ },
2415
+ required: ['x'],
2416
+ $defs: {
2417
+ B: {
2418
+ $id: 'other.json',
2419
+ $defs: {
2420
+ X: {
2421
+ $anchor: 'bar',
2422
+ type: 'string',
2423
+ minLength: 2,
2424
+ },
2425
+ },
2426
+ },
2427
+ },
2428
+ };
2429
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, root);
2430
+ const yaml = `x: A`;
2431
+ const result = await parseSetup(yaml);
2432
+ (0, chai_1.expect)(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false);
2433
+ (0, chai_1.expect)(result).to.have.length(1);
2434
+ (0, chai_1.expect)(result[0].message).to.include('String is shorter than the minimum length of 2.');
2435
+ });
2436
+ it('should handle $id changing base URI for nested $anchor resolution', async () => {
2437
+ const root = {
2438
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2439
+ type: 'object',
2440
+ properties: {
2441
+ address: { $ref: 'schemas/address.json#USAddress' },
2442
+ },
2443
+ $defs: {
2444
+ addressSchema: {
2445
+ $id: 'schemas/address.json',
2446
+ $defs: {
2447
+ us: {
2448
+ $anchor: 'USAddress',
2449
+ type: 'object',
2450
+ properties: {
2451
+ zipCode: { type: 'string', minLength: 5 },
2452
+ },
2453
+ required: ['zipCode'],
2454
+ },
2455
+ },
2456
+ },
2457
+ },
2458
+ };
2459
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, root);
2460
+ const yaml = `address:\n zipCode: "123"`;
2461
+ const result = await parseSetup(yaml);
2462
+ (0, chai_1.expect)(result.some((d) => /Problems loading reference/i.test(d.message))).to.eq(false);
2463
+ (0, chai_1.expect)(result[0].message).to.include('String is shorter than the minimum length of 5.');
2464
+ });
2465
+ });
2466
+ describe('$recursiveAnchor and $recursiveRef resolution', () => {
2467
+ describe('$recursiveRef without $recursiveAnchor works like $ref', () => {
2468
+ const schema = {
2469
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2470
+ properties: {
2471
+ foo: { $recursiveRef: '#' },
2472
+ },
2473
+ additionalProperties: false,
2474
+ };
2475
+ beforeEach(() => {
2476
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2477
+ });
2478
+ it('match', async () => {
2479
+ (0, chai_1.expect)(await parseSetup('foo: false')).to.be.empty;
2480
+ });
2481
+ it('recursive match', async () => {
2482
+ (0, chai_1.expect)(await parseSetup(`foo:
2483
+ foo: false`)).to.be.empty;
2484
+ });
2485
+ it('mismatch', async () => {
2486
+ const result = await parseSetup('bar: false');
2487
+ (0, chai_1.expect)(result).to.have.length(1);
2488
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
2489
+ });
2490
+ it('recursive mismatch', async () => {
2491
+ const result = await parseSetup(`foo:
2492
+ bar: false`);
2493
+ (0, chai_1.expect)(result).to.have.length(1);
2494
+ (0, chai_1.expect)(result[0].message).to.include('Property bar is not allowed.');
2495
+ });
2496
+ });
2497
+ describe('$recursiveRef without using nesting', () => {
2498
+ const schema = {
2499
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2500
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef2/schema.json',
2501
+ $defs: {
2502
+ myobject: {
2503
+ $id: 'myobject.json',
2504
+ $recursiveAnchor: true,
2505
+ anyOf: [
2506
+ { type: 'string' },
2507
+ {
2508
+ type: 'object',
2509
+ additionalProperties: { $recursiveRef: '#' },
2510
+ },
2511
+ ],
2512
+ },
2513
+ },
2514
+ anyOf: [{ type: 'integer' }, { $ref: '#/$defs/myobject' }],
2515
+ };
2516
+ beforeEach(() => {
2517
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2518
+ });
2519
+ it('integer matches at the outer level', async () => {
2520
+ (0, chai_1.expect)(await parseSetup(`1`)).to.be.empty;
2521
+ });
2522
+ it('single level match', async () => {
2523
+ (0, chai_1.expect)(await parseSetup(`foo: hi`)).to.be.empty;
2524
+ });
2525
+ it('integer does not match as a property value', async () => {
2526
+ const result = await parseSetup(`foo: 1`);
2527
+ (0, chai_1.expect)(result).to.have.length(1);
2528
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2529
+ (0, chai_1.expect)(result[0].message).to.include('string | object');
2530
+ });
2531
+ it('two levels, properties match with inner definition', async () => {
2532
+ (0, chai_1.expect)(await parseSetup(`foo:
2533
+ bar: hi`)).to.be.empty;
2534
+ });
2535
+ it('two levels, no match', async () => {
2536
+ const result = await parseSetup(`foo:
2537
+ bar: 1`);
2538
+ (0, chai_1.expect)(result).to.have.length(1);
2539
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2540
+ (0, chai_1.expect)(result[0].message).to.include('string | object');
2541
+ });
2542
+ });
2543
+ describe('$recursiveRef with nesting', () => {
2544
+ const schema = {
2545
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2546
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef3/schema.json',
2547
+ $recursiveAnchor: true,
2548
+ $defs: {
2549
+ myobject: {
2550
+ $id: 'myobject.json',
2551
+ $recursiveAnchor: true,
2552
+ anyOf: [
2553
+ { type: 'string' },
2554
+ {
2555
+ type: 'object',
2556
+ additionalProperties: { $recursiveRef: '#' },
2557
+ },
2558
+ ],
2559
+ },
2560
+ },
2561
+ anyOf: [{ type: 'integer' }, { $ref: '#/$defs/myobject' }],
2562
+ };
2563
+ beforeEach(() => {
2564
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2565
+ });
2566
+ it('integer matches at the outer level', async () => {
2567
+ (0, chai_1.expect)(await parseSetup(`1`)).to.be.empty;
2568
+ });
2569
+ it('single level match', async () => {
2570
+ (0, chai_1.expect)(await parseSetup(`foo: hi`)).to.be.empty;
2571
+ });
2572
+ it('integer now matches as a property value', async () => {
2573
+ (0, chai_1.expect)(await parseSetup(`foo: 1`)).to.be.empty;
2574
+ });
2575
+ it('two levels, properties match with inner definition', async () => {
2576
+ (0, chai_1.expect)(await parseSetup(`foo:
2577
+ bar: hi`)).to.be.empty;
2578
+ });
2579
+ it('two levels, properties match with $recursiveRef', async () => {
2580
+ (0, chai_1.expect)(await parseSetup(`foo:
2581
+ bar: 1`)).to.be.empty;
2582
+ });
2583
+ });
2584
+ describe('$recursiveRef with $recursiveAnchor: false works like $ref', () => {
2585
+ const schema = {
2586
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2587
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef4/schema.json',
2588
+ $recursiveAnchor: false,
2589
+ $defs: {
2590
+ myobject: {
2591
+ $id: 'myobject.json',
2592
+ $recursiveAnchor: false,
2593
+ anyOf: [
2594
+ { type: 'string' },
2595
+ {
2596
+ type: 'object',
2597
+ additionalProperties: { $recursiveRef: '#' },
2598
+ },
2599
+ ],
2600
+ },
2601
+ },
2602
+ anyOf: [{ type: 'integer' }, { $ref: '#/$defs/myobject' }],
2603
+ };
2604
+ beforeEach(() => {
2605
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2606
+ });
2607
+ it('integer matches at the outer level', async () => {
2608
+ (0, chai_1.expect)(await parseSetup(`1`)).to.be.empty;
2609
+ });
2610
+ it('single level match', async () => {
2611
+ (0, chai_1.expect)(await parseSetup(`foo: hi`)).to.be.empty;
2612
+ });
2613
+ it('integer does not match as a property value', async () => {
2614
+ const result = await parseSetup(`foo: 1`);
2615
+ (0, chai_1.expect)(result).to.have.length(1);
2616
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2617
+ (0, chai_1.expect)(result[0].message).to.include('string | object');
2618
+ });
2619
+ it('two levels, properties match with inner definition', async () => {
2620
+ (0, chai_1.expect)(await parseSetup(`foo:
2621
+ bar: hi`)).to.be.empty;
2622
+ });
2623
+ it('two levels, integer does not match as a property value', async () => {
2624
+ const result = await parseSetup(`foo:
2625
+ bar: 1`);
2626
+ (0, chai_1.expect)(result).to.have.length(1);
2627
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2628
+ (0, chai_1.expect)(result[0].message).to.include('string | object');
2629
+ });
2630
+ });
2631
+ describe('$recursiveRef with no $recursiveAnchor works like $ref', () => {
2632
+ const schema = {
2633
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2634
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef5/schema.json',
2635
+ $defs: {
2636
+ myobject: {
2637
+ $id: 'myobject.json',
2638
+ $recursiveAnchor: false,
2639
+ anyOf: [
2640
+ { type: 'string' },
2641
+ {
2642
+ type: 'object',
2643
+ additionalProperties: { $recursiveRef: '#' },
2644
+ },
2645
+ ],
2646
+ },
2647
+ },
2648
+ anyOf: [{ type: 'integer' }, { $ref: '#/$defs/myobject' }],
2649
+ };
2650
+ beforeEach(() => {
2651
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2652
+ });
2653
+ it('integer matches at the outer level', async () => {
2654
+ (0, chai_1.expect)(await parseSetup(`1`)).to.be.empty;
2655
+ });
2656
+ it('single level match', async () => {
2657
+ (0, chai_1.expect)(await parseSetup(`foo: hi`)).to.be.empty;
2658
+ });
2659
+ it('integer does not match as a property value', async () => {
2660
+ const result = await parseSetup(`foo: 1`);
2661
+ (0, chai_1.expect)(result).to.have.length(1);
2662
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2663
+ (0, chai_1.expect)(result[0].message).to.include('string | object');
2664
+ });
2665
+ it('two levels, properties match with inner definition', async () => {
2666
+ (0, chai_1.expect)(await parseSetup(`foo:
2667
+ bar: hi`)).to.be.empty;
2668
+ });
2669
+ it('two levels, integer does not match as a property value', async () => {
2670
+ const result = await parseSetup(`foo:
2671
+ bar: 1`);
2672
+ (0, chai_1.expect)(result).to.have.length(1);
2673
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2674
+ (0, chai_1.expect)(result[0].message).to.include('string | object');
2675
+ });
2676
+ });
2677
+ describe('$recursiveRef with no $recursiveAnchor in the initial target schema resource', () => {
2678
+ const schema = {
2679
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2680
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef6/base.json',
2681
+ $recursiveAnchor: true,
2682
+ anyOf: [
2683
+ { type: 'boolean' },
2684
+ {
2685
+ type: 'object',
2686
+ additionalProperties: {
2687
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef6/inner.json',
2688
+ $comment: 'there is no $recursiveAnchor: true here, so we do NOT recurse to the base',
2689
+ anyOf: [{ type: 'integer' }, { type: 'object', additionalProperties: { $recursiveRef: '#' } }],
2690
+ },
2691
+ },
2692
+ ],
2693
+ };
2694
+ beforeEach(() => {
2695
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2696
+ });
2697
+ it('leaf node does not match; no recursion', async () => {
2698
+ const result = await parseSetup(`foo: true`);
2699
+ (0, chai_1.expect)(result).to.have.length(1);
2700
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2701
+ (0, chai_1.expect)(result[0].message).to.include('integer | object');
2702
+ });
2703
+ it('leaf node matches: recursion uses the inner schema', async () => {
2704
+ (0, chai_1.expect)(await parseSetup(`foo:
2705
+ bar: 1`)).to.be.empty;
2706
+ });
2707
+ it('leaf node does not match: recursion uses the inner schema', async () => {
2708
+ const result = await parseSetup(`foo:
2709
+ bar: true`);
2710
+ (0, chai_1.expect)(result).to.have.length(1);
2711
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2712
+ (0, chai_1.expect)(result[0].message).to.include('integer | object');
2713
+ });
2714
+ });
2715
+ describe('$recursiveRef with no $recursiveAnchor in the outer schema resource', () => {
2716
+ const schema = {
2717
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2718
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef7/base.json',
2719
+ anyOf: [
2720
+ { type: 'boolean' },
2721
+ {
2722
+ type: 'object',
2723
+ additionalProperties: {
2724
+ $id: 'http://localhost:4242/draft2019-09/recursiveRef7/inner.json',
2725
+ $recursiveAnchor: true,
2726
+ anyOf: [{ type: 'integer' }, { type: 'object', additionalProperties: { $recursiveRef: '#' } }],
2727
+ },
2728
+ },
2729
+ ],
2730
+ };
2731
+ beforeEach(() => {
2732
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2733
+ });
2734
+ it('leaf node does not match; no recursion', async () => {
2735
+ const result = await parseSetup(`foo: true`);
2736
+ (0, chai_1.expect)(result).to.have.length(1);
2737
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2738
+ (0, chai_1.expect)(result[0].message).to.include('integer | object');
2739
+ });
2740
+ it('leaf node matches: recursion only uses inner schema', async () => {
2741
+ (0, chai_1.expect)(await parseSetup(`foo:
2742
+ bar: 1`)).to.be.empty;
2743
+ });
2744
+ it('leaf node does not match: recursion only uses inner schema', async () => {
2745
+ const result = await parseSetup(`foo:
2746
+ bar: true`);
2747
+ (0, chai_1.expect)(result).to.have.length(1);
2748
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2749
+ (0, chai_1.expect)(result[0].message).to.include('integer | object');
2750
+ });
2751
+ });
2752
+ describe('multiple dynamic paths to the $recursiveRef keyword', () => {
2753
+ const schema = {
2754
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2755
+ $id: 'https://example.com/recursiveRef8_main.json',
2756
+ $defs: {
2757
+ inner: {
2758
+ $id: 'recursiveRef8_inner.json',
2759
+ $recursiveAnchor: true,
2760
+ title: 'inner',
2761
+ additionalProperties: {
2762
+ $recursiveRef: '#',
2763
+ },
2764
+ },
2765
+ },
2766
+ if: {
2767
+ propertyNames: {
2768
+ pattern: '^[a-m]',
2769
+ },
2770
+ },
2771
+ then: {
2772
+ title: 'any type of node',
2773
+ $id: 'recursiveRef8_anyLeafNode.json',
2774
+ $recursiveAnchor: true,
2775
+ $ref: 'recursiveRef8_inner.json',
2776
+ },
2777
+ else: {
2778
+ title: 'integer node',
2779
+ $id: 'recursiveRef8_integerNode.json',
2780
+ $recursiveAnchor: true,
2781
+ type: ['object', 'integer'],
2782
+ $ref: 'recursiveRef8_inner.json',
2783
+ },
2784
+ };
2785
+ beforeEach(() => {
2786
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2787
+ });
2788
+ it('recurse to anyLeafNode - floats are allowed', async () => {
2789
+ (0, chai_1.expect)(await parseSetup(`alpha: 1.1`)).to.be.empty;
2790
+ });
2791
+ it('recurse to integerNode - floats are not allowed', async () => {
2792
+ const result = await parseSetup(`november: 1.1`);
2793
+ (0, chai_1.expect)(result).to.have.length(1);
2794
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type. Expected one of object, integer.');
2795
+ });
2796
+ });
2797
+ describe('dynamic $recursiveRef destination (not predictable at schema compile time)', () => {
2798
+ const schema = {
2799
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2800
+ $id: 'https://example.com/main.json',
2801
+ $defs: {
2802
+ inner: {
2803
+ $id: 'inner.json',
2804
+ $recursiveAnchor: true,
2805
+ title: 'inner',
2806
+ additionalProperties: {
2807
+ $recursiveRef: '#',
2808
+ },
2809
+ },
2810
+ },
2811
+ if: { propertyNames: { pattern: '^[a-m]' } },
2812
+ then: {
2813
+ title: 'any type of node',
2814
+ $id: 'anyLeafNode.json',
2815
+ $recursiveAnchor: true,
2816
+ $ref: 'main.json#/$defs/inner',
2817
+ },
2818
+ else: {
2819
+ title: 'integer node',
2820
+ $id: 'integerNode.json',
2821
+ $recursiveAnchor: true,
2822
+ type: ['object', 'integer'],
2823
+ $ref: 'main.json#/$defs/inner',
2824
+ },
2825
+ };
2826
+ beforeEach(() => {
2827
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, schema);
2828
+ });
2829
+ it('numeric node', async () => {
2830
+ (0, chai_1.expect)(await parseSetup(`alpha: 1.1`)).to.be.empty;
2831
+ });
2832
+ it('integer node', async () => {
2833
+ const result = await parseSetup(`november: 1.1`);
2834
+ (0, chai_1.expect)(result).to.have.length(1);
2835
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type. Expected one of object, integer.');
2836
+ });
2837
+ });
2838
+ it('does not infinite loop on self-recursive $recursiveRef', async () => {
2839
+ const schema = {
2840
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2841
+ $id: 'http://localhost:4242/recursive.json',
2842
+ $recursiveAnchor: true,
2843
+ anyOf: [
2844
+ { type: 'string' },
2845
+ {
2846
+ type: 'object',
2847
+ additionalProperties: { $recursiveRef: '#' },
2848
+ },
2849
+ ],
2850
+ };
2851
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'http://localhost:4242/recursive.json', schema);
2852
+ const result = await parseSetup(`# yaml-language-server: $schema=http://localhost:4242/recursive.json
2853
+ foo:
2854
+ bar:
2855
+ baz: 1`);
2856
+ (0, chai_1.expect)(result).to.have.length(1);
2857
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type.');
2858
+ (0, chai_1.expect)(result[0].message).to.include('string | object');
2859
+ });
2860
+ describe('tree schema with unevaluatedProperties', () => {
2861
+ it('$recursiveRef resolves to outermost schema with $recursiveAnchor in dynamic scope', async () => {
2862
+ const treeSchema = {
2863
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2864
+ $id: 'http://example.com/tree.json',
2865
+ $recursiveAnchor: true,
2866
+ type: 'object',
2867
+ properties: {
2868
+ value: { type: 'integer' },
2869
+ children: { type: 'array', items: { $recursiveRef: '#' } },
2870
+ },
2871
+ required: ['value'],
2872
+ };
2873
+ const treeWithMetaSchema = {
2874
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2875
+ $id: 'http://example.com/tree-with-meta.json',
2876
+ $recursiveAnchor: true,
2877
+ allOf: [{ $ref: 'http://example.com/tree.json' }],
2878
+ properties: {
2879
+ meta: { type: 'string' },
2880
+ },
2881
+ required: ['meta'],
2882
+ unevaluatedProperties: false,
2883
+ };
2884
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'http://example.com/tree.json', treeSchema);
2885
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'http://example.com/tree-with-meta.json', treeWithMetaSchema);
2886
+ const content = `# yaml-language-server: $schema=http://example.com/tree-with-meta.json
2887
+ value: 1
2888
+ meta: root
2889
+ children:
2890
+ - value: 2
2891
+ `;
2892
+ const result = await parseSetup(content);
2893
+ (0, chai_1.expect)(result).to.have.length(1);
2894
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
2895
+ (0, chai_1.expect)(result[0].message).to.include('meta');
2896
+ });
2897
+ it('$recursiveRef with all required properties should pass', async () => {
2898
+ const treeSchema = {
2899
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2900
+ $id: 'http://example.com/tree2.json',
2901
+ $recursiveAnchor: true,
2902
+ type: 'object',
2903
+ properties: {
2904
+ value: { type: 'integer' },
2905
+ children: { type: 'array', items: { $recursiveRef: '#' } },
2906
+ },
2907
+ required: ['value'],
2908
+ };
2909
+ const treeWithMetaSchema = {
2910
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2911
+ $id: 'http://example.com/tree-with-meta2.json',
2912
+ $recursiveAnchor: true,
2913
+ allOf: [{ $ref: 'http://example.com/tree2.json' }],
2914
+ properties: {
2915
+ meta: { type: 'string' },
2916
+ },
2917
+ required: ['meta'],
2918
+ unevaluatedProperties: false,
2919
+ };
2920
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'http://example.com/tree2.json', treeSchema);
2921
+ schemaProvider.addSchemaWithUri(testHelper_1.SCHEMA_ID, 'http://example.com/tree-with-meta2.json', treeWithMetaSchema);
2922
+ const content = `# yaml-language-server: $schema=http://example.com/tree-with-meta2.json
2923
+ value: 1
2924
+ meta: root
2925
+ children:
2926
+ - value: 2
2927
+ meta: child
2928
+ `;
2929
+ (0, chai_1.expect)(await parseSetup(content)).to.be.empty;
2930
+ });
2931
+ });
2932
+ });
2933
+ describe('keyword: contains', () => {
2934
+ it('contains keyword validation', async () => {
2935
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2936
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2937
+ contains: { minimum: 5 },
2938
+ });
2939
+ // array with item matching schema (5) is valid
2940
+ let content = toContent([3, 4, 5]);
2941
+ let result = await parseSetup(content);
2942
+ (0, chai_1.expect)(result).to.be.empty;
2943
+ // array with item matching schema (6) is valid
2944
+ content = toContent([3, 4, 6]);
2945
+ result = await parseSetup(content);
2946
+ (0, chai_1.expect)(result).to.be.empty;
2947
+ // array with two items matching schema (5, 6) is valid
2948
+ content = toContent([3, 4, 5, 6]);
2949
+ result = await parseSetup(content);
2950
+ (0, chai_1.expect)(result).to.be.empty;
2951
+ // array without items matching schema is invalid
2952
+ content = toContent([2, 3, 4]);
2953
+ result = await parseSetup(content);
2954
+ (0, chai_1.expect)(result).to.have.length(1);
2955
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
2956
+ // empty array is invalid
2957
+ content = toContent([]);
2958
+ result = await parseSetup(content);
2959
+ (0, chai_1.expect)(result).to.have.length(1);
2960
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
2961
+ // not array is valid
2962
+ content = toContent({});
2963
+ result = await parseSetup(content);
2964
+ (0, chai_1.expect)(result).to.be.empty;
2965
+ });
2966
+ it('contains keyword with const keyword', async () => {
2967
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2968
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2969
+ contains: { const: 5 },
2970
+ });
2971
+ // array with item 5 is valid
2972
+ let content = toContent([3, 4, 5]);
2973
+ let result = await parseSetup(content);
2974
+ (0, chai_1.expect)(result).to.be.empty;
2975
+ // array with two items 5 is valid
2976
+ content = toContent([3, 4, 5, 5]);
2977
+ result = await parseSetup(content);
2978
+ (0, chai_1.expect)(result).to.be.empty;
2979
+ // array without item 5 is invalid
2980
+ content = toContent([1, 2, 3, 4]);
2981
+ result = await parseSetup(content);
2982
+ (0, chai_1.expect)(result).to.have.length(1);
2983
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
2984
+ });
2985
+ it('contains keyword with boolean schema true', async () => {
2986
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
2987
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
2988
+ contains: true,
2989
+ });
2990
+ // any non-empty array is valid
2991
+ let content = toContent(['foo']);
2992
+ let result = await parseSetup(content);
2993
+ (0, chai_1.expect)(result).to.be.empty;
2994
+ // empty array is invalid
2995
+ content = toContent([]);
2996
+ result = await parseSetup(content);
2997
+ (0, chai_1.expect)(result).to.have.length(1);
2998
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
2999
+ });
3000
+ it('contains keyword with boolean schema false', async () => {
3001
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3002
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3003
+ contains: false,
3004
+ });
3005
+ // any non-empty array is invalid
3006
+ let content = toContent(['foo']);
3007
+ let result = await parseSetup(content);
3008
+ (0, chai_1.expect)(result).to.have.length(1);
3009
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3010
+ // empty array is invalid
3011
+ content = toContent([]);
3012
+ result = await parseSetup(content);
3013
+ (0, chai_1.expect)(result).to.have.length(1);
3014
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3015
+ // non-arrays are valid
3016
+ content = toContent('contains does not apply to strings');
3017
+ result = await parseSetup(content);
3018
+ (0, chai_1.expect)(result).to.be.empty;
3019
+ });
3020
+ it('items + contains', async () => {
3021
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3022
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3023
+ items: { multipleOf: 2 },
3024
+ contains: { multipleOf: 3 },
3025
+ });
3026
+ // matches items, does not match contains
3027
+ let content = toContent([2, 4, 8]);
3028
+ let result = await parseSetup(content);
3029
+ (0, chai_1.expect)(result).to.have.length(1);
3030
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3031
+ // does not match items, matches contains
3032
+ content = toContent([3, 6, 9]);
3033
+ result = await parseSetup(content);
3034
+ (0, chai_1.expect)(result).to.have.length(2);
3035
+ (0, chai_1.expect)(result[0].message).to.include('Value is not divisible by 2.');
3036
+ (0, chai_1.expect)(result[1].message).to.include('Value is not divisible by 2.');
3037
+ // matches both items and contains
3038
+ content = toContent([6, 12]);
3039
+ result = await parseSetup(content);
3040
+ (0, chai_1.expect)(result).to.be.empty;
3041
+ // matches neither items nor contains
3042
+ content = toContent([1, 5]);
3043
+ result = await parseSetup(content);
3044
+ (0, chai_1.expect)(result).to.have.length(3);
3045
+ (0, chai_1.expect)(result[0].message).to.include('Value is not divisible by 2.');
3046
+ (0, chai_1.expect)(result[1].message).to.include('Value is not divisible by 2.');
3047
+ (0, chai_1.expect)(result[2].message).to.include('Array has too few items matching');
3048
+ });
3049
+ it('contains with false if subschema', async () => {
3050
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3051
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3052
+ contains: {
3053
+ if: false,
3054
+ else: true,
3055
+ },
3056
+ });
3057
+ // any non-empty array is valid
3058
+ let content = toContent(['foo']);
3059
+ let result = await parseSetup(content);
3060
+ (0, chai_1.expect)(result).to.be.empty;
3061
+ // empty array is invalid
3062
+ content = toContent([]);
3063
+ result = await parseSetup(content);
3064
+ (0, chai_1.expect)(result).to.have.length(1);
3065
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3066
+ });
3067
+ it('contains with null instance elements', async () => {
3068
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3069
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3070
+ contains: {
3071
+ type: 'null',
3072
+ },
3073
+ });
3074
+ // allows null items
3075
+ const content = toContent([null]);
3076
+ const result = await parseSetup(content);
3077
+ (0, chai_1.expect)(result).to.be.empty;
3078
+ });
3079
+ });
3080
+ describe('keyword: maxContains', () => {
3081
+ it('maxContains without contains is ignored', async () => {
3082
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3083
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3084
+ maxContains: 1,
3085
+ });
3086
+ // one item valid against lone maxContains
3087
+ let content = toContent([1]);
3088
+ let result = await parseSetup(content);
3089
+ (0, chai_1.expect)(result).to.be.empty;
3090
+ // two items still valid against lone maxContains
3091
+ content = toContent([1, 2]);
3092
+ result = await parseSetup(content);
3093
+ (0, chai_1.expect)(result).to.be.empty;
3094
+ });
3095
+ it('maxContains with contains', async () => {
3096
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3097
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3098
+ contains: { const: 1 },
3099
+ maxContains: 1,
3100
+ });
3101
+ // empty data
3102
+ let content = toContent([]);
3103
+ let result = await parseSetup(content);
3104
+ (0, chai_1.expect)(result).to.have.length(1);
3105
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3106
+ // all elements match, valid maxContains
3107
+ content = toContent([1]);
3108
+ result = await parseSetup(content);
3109
+ (0, chai_1.expect)(result).to.be.empty;
3110
+ // all elements match, invalid maxContains
3111
+ content = toContent([1, 1]);
3112
+ result = await parseSetup(content);
3113
+ (0, chai_1.expect)(result).to.have.length(1);
3114
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items matching');
3115
+ // some elements match, valid maxContains
3116
+ content = toContent([1, 2]);
3117
+ result = await parseSetup(content);
3118
+ (0, chai_1.expect)(result).to.be.empty;
3119
+ // some elements match, invalid maxContains
3120
+ content = toContent([1, 2, 1]);
3121
+ result = await parseSetup(content);
3122
+ (0, chai_1.expect)(result).to.have.length(1);
3123
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items matching');
3124
+ });
3125
+ it('maxContains with contains, value with a decimal', async () => {
3126
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3127
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3128
+ contains: { const: 1 },
3129
+ maxContains: 1.0,
3130
+ });
3131
+ // one element matches, valid maxContains
3132
+ let content = toContent([1]);
3133
+ let result = await parseSetup(content);
3134
+ (0, chai_1.expect)(result).to.be.empty;
3135
+ // too many elements match, invalid maxContains
3136
+ content = toContent([1, 1]);
3137
+ result = await parseSetup(content);
3138
+ (0, chai_1.expect)(result).to.have.length(1);
3139
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items matching');
3140
+ });
3141
+ it('minContains < maxContains', async () => {
3142
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3143
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3144
+ contains: { const: 1 },
3145
+ minContains: 1,
3146
+ maxContains: 3,
3147
+ });
3148
+ // actual < minContains < maxContains
3149
+ let content = toContent([]);
3150
+ let result = await parseSetup(content);
3151
+ (0, chai_1.expect)(result).to.have.length(1);
3152
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3153
+ // minContains < actual < maxContains
3154
+ content = toContent([1, 1]);
3155
+ result = await parseSetup(content);
3156
+ (0, chai_1.expect)(result).to.be.empty;
3157
+ // minContains < maxContains < actual
3158
+ content = toContent([1, 1, 1, 1]);
3159
+ result = await parseSetup(content);
3160
+ (0, chai_1.expect)(result).to.have.length(1);
3161
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items matching');
3162
+ });
3163
+ });
3164
+ describe('keyword: minContains', () => {
3165
+ it('minContains without contains is ignored', async () => {
3166
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3167
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3168
+ minContains: 1,
3169
+ });
3170
+ // one item valid against lone minContains
3171
+ let content = toContent([1]);
3172
+ let result = await parseSetup(content);
3173
+ (0, chai_1.expect)(result).to.be.empty;
3174
+ // zero items still valid against lone minContains
3175
+ content = toContent([]);
3176
+ result = await parseSetup(content);
3177
+ (0, chai_1.expect)(result).to.be.empty;
3178
+ });
3179
+ it('minContains=1 with contains', async () => {
3180
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3181
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3182
+ contains: { const: 1 },
3183
+ minContains: 1,
3184
+ });
3185
+ // empty data
3186
+ let content = toContent([]);
3187
+ let result = await parseSetup(content);
3188
+ (0, chai_1.expect)(result).to.have.length(1);
3189
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3190
+ // no elements match
3191
+ content = toContent([2]);
3192
+ result = await parseSetup(content);
3193
+ (0, chai_1.expect)(result).to.have.length(1);
3194
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3195
+ // single element matches, valid minContains
3196
+ content = toContent([1]);
3197
+ result = await parseSetup(content);
3198
+ (0, chai_1.expect)(result).to.be.empty;
3199
+ // some elements match, valid minContains
3200
+ content = toContent([1, 2]);
3201
+ result = await parseSetup(content);
3202
+ (0, chai_1.expect)(result).to.be.empty;
3203
+ // all elements match, valid minContains
3204
+ content = toContent([1, 1]);
3205
+ result = await parseSetup(content);
3206
+ (0, chai_1.expect)(result).to.be.empty;
3207
+ });
3208
+ it('minContains=2 with contains', async () => {
3209
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3210
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3211
+ contains: { const: 1 },
3212
+ minContains: 2,
3213
+ });
3214
+ // empty data
3215
+ let content = toContent([]);
3216
+ let result = await parseSetup(content);
3217
+ (0, chai_1.expect)(result).to.have.length(1);
3218
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3219
+ // all elements match, invalid minContains
3220
+ content = toContent([1]);
3221
+ result = await parseSetup(content);
3222
+ (0, chai_1.expect)(result).to.have.length(1);
3223
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3224
+ // some elements match, invalid minContains
3225
+ content = toContent([1, 2]);
3226
+ result = await parseSetup(content);
3227
+ (0, chai_1.expect)(result).to.have.length(1);
3228
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3229
+ // all elements match, valid minContains (exactly as needed)
3230
+ content = toContent([1, 1]);
3231
+ result = await parseSetup(content);
3232
+ (0, chai_1.expect)(result).to.be.empty;
3233
+ // all elements match, valid minContains (more than needed)
3234
+ content = toContent([1, 1, 1]);
3235
+ result = await parseSetup(content);
3236
+ (0, chai_1.expect)(result).to.be.empty;
3237
+ // some elements match, valid minContains
3238
+ content = toContent([1, 2, 1]);
3239
+ result = await parseSetup(content);
3240
+ (0, chai_1.expect)(result).to.be.empty;
3241
+ });
3242
+ it('minContains=2 with contains with a decimal value', async () => {
3243
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3244
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3245
+ contains: { const: 1 },
3246
+ minContains: 2.0,
3247
+ });
3248
+ // one element matches, invalid minContains
3249
+ let content = toContent([1]);
3250
+ let result = await parseSetup(content);
3251
+ (0, chai_1.expect)(result).to.have.length(1);
3252
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3253
+ // both elements match, valid minContains
3254
+ content = toContent([1, 1]);
3255
+ result = await parseSetup(content);
3256
+ (0, chai_1.expect)(result).to.be.empty;
3257
+ });
3258
+ it('maxContains = minContains', async () => {
3259
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3260
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3261
+ contains: { const: 1 },
3262
+ maxContains: 2,
3263
+ minContains: 2,
3264
+ });
3265
+ // empty data
3266
+ let content = toContent([]);
3267
+ let result = await parseSetup(content);
3268
+ (0, chai_1.expect)(result).to.have.length(1);
3269
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3270
+ // all elements match, invalid minContains
3271
+ content = toContent([1]);
3272
+ result = await parseSetup(content);
3273
+ (0, chai_1.expect)(result).to.have.length(1);
3274
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3275
+ // all elements match, invalid maxContains
3276
+ content = toContent([1, 1, 1]);
3277
+ result = await parseSetup(content);
3278
+ (0, chai_1.expect)(result).to.have.length(1);
3279
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items matching');
3280
+ // all elements match, valid maxContains and minContains
3281
+ content = toContent([1, 1]);
3282
+ result = await parseSetup(content);
3283
+ (0, chai_1.expect)(result).to.be.empty;
3284
+ });
3285
+ it('maxContains < minContains', async () => {
3286
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3287
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3288
+ contains: { const: 1 },
3289
+ maxContains: 1,
3290
+ minContains: 3,
3291
+ });
3292
+ // empty data
3293
+ let content = toContent([]);
3294
+ let result = await parseSetup(content);
3295
+ (0, chai_1.expect)(result).to.have.length(1);
3296
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3297
+ // invalid minContains
3298
+ content = toContent([1]);
3299
+ result = await parseSetup(content);
3300
+ (0, chai_1.expect)(result).to.have.length(1);
3301
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3302
+ // invalid maxContains
3303
+ content = toContent([1, 1, 1]);
3304
+ result = await parseSetup(content);
3305
+ (0, chai_1.expect)(result).to.have.length(2);
3306
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3307
+ (0, chai_1.expect)(result[1].message).to.include('Array has too many items matching');
3308
+ // invalid maxContains and minContains
3309
+ content = toContent([1, 1]);
3310
+ result = await parseSetup(content);
3311
+ (0, chai_1.expect)(result).to.have.length(2);
3312
+ (0, chai_1.expect)(result[0].message).to.include('Array has too few items matching');
3313
+ (0, chai_1.expect)(result[1].message).to.include('Array has too many items matching');
3314
+ });
3315
+ it('minContains = 0 with no maxContains', async () => {
3316
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3317
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3318
+ contains: { const: 1 },
3319
+ minContains: 0,
3320
+ });
3321
+ // empty data
3322
+ let content = toContent([]);
3323
+ let result = await parseSetup(content);
3324
+ (0, chai_1.expect)(result).to.be.empty;
3325
+ // minContains = 0 makes contains always pass
3326
+ content = toContent([2]);
3327
+ result = await parseSetup(content);
3328
+ (0, chai_1.expect)(result).to.be.empty;
3329
+ });
3330
+ it('minContains = 0 with maxContains', async () => {
3331
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3332
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3333
+ contains: { const: 1 },
3334
+ minContains: 0,
3335
+ maxContains: 1,
3336
+ });
3337
+ // empty data
3338
+ let content = toContent([]);
3339
+ let result = await parseSetup(content);
3340
+ (0, chai_1.expect)(result).to.be.empty;
3341
+ // not more than maxContains
3342
+ content = toContent([1]);
3343
+ result = await parseSetup(content);
3344
+ (0, chai_1.expect)(result).to.be.empty;
3345
+ // too many
3346
+ content = toContent([1, 1]);
3347
+ result = await parseSetup(content);
3348
+ (0, chai_1.expect)(result).to.have.length(1);
3349
+ (0, chai_1.expect)(result[0].message).to.include('Array has too many items matching');
3350
+ });
3351
+ });
3352
+ describe('keyword: dependentSchemas', () => {
3353
+ it('single dependency', async () => {
3354
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3355
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3356
+ dependentSchemas: {
3357
+ bar: {
3358
+ properties: {
3359
+ foo: { type: 'integer' },
3360
+ bar: { type: 'integer' },
3361
+ },
3362
+ },
3363
+ },
3364
+ });
3365
+ // valid
3366
+ let content = toContent({ foo: 1, bar: 2 });
3367
+ let result = await parseSetup(content);
3368
+ (0, chai_1.expect)(result).to.be.empty;
3369
+ // no dependency
3370
+ content = toContent({ foo: 'quux' });
3371
+ result = await parseSetup(content);
3372
+ (0, chai_1.expect)(result).to.be.empty;
3373
+ // wrong type
3374
+ content = toContent({ foo: 'quux', bar: 2 });
3375
+ result = await parseSetup(content);
3376
+ (0, chai_1.expect)(result).to.have.length(1);
3377
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
3378
+ // wrong type other
3379
+ content = toContent({ foo: 2, bar: 'quux' });
3380
+ result = await parseSetup(content);
3381
+ (0, chai_1.expect)(result).to.have.length(1);
3382
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
3383
+ // wrong type both
3384
+ content = toContent({ foo: 'quux', bar: 'quux' });
3385
+ result = await parseSetup(content);
3386
+ (0, chai_1.expect)(result).to.have.length(2);
3387
+ (0, chai_1.expect)(result[0].message).to.include('Incorrect type');
3388
+ (0, chai_1.expect)(result[1].message).to.include('Incorrect type');
3389
+ // ignores arrays
3390
+ content = toContent(['bar']);
3391
+ result = await parseSetup(content);
3392
+ (0, chai_1.expect)(result).to.be.empty;
3393
+ // ignores strings
3394
+ content = toContent('foobar');
3395
+ result = await parseSetup(content);
3396
+ (0, chai_1.expect)(result).to.be.empty;
3397
+ // ignores other non-objects
3398
+ content = toContent(12);
3399
+ result = await parseSetup(content);
3400
+ (0, chai_1.expect)(result).to.be.empty;
3401
+ });
3402
+ it('boolean subschemas', async () => {
3403
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3404
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3405
+ dependentSchemas: {
3406
+ foo: true,
3407
+ bar: false,
3408
+ },
3409
+ });
3410
+ // object with property having schema true is valid
3411
+ let content = toContent({ foo: 1 });
3412
+ let result = await parseSetup(content);
3413
+ (0, chai_1.expect)(result).to.be.empty;
3414
+ // object with property having schema false is invalid
3415
+ content = toContent({ bar: 2 });
3416
+ result = await parseSetup(content);
3417
+ (0, chai_1.expect)(result).to.have.length(1);
3418
+ (0, chai_1.expect)(result[0].message).to.include('Matches a schema that is not allowed');
3419
+ // object with both properties is invalid
3420
+ content = toContent({ foo: 1, bar: 2 });
3421
+ result = await parseSetup(content);
3422
+ (0, chai_1.expect)(result).to.have.length(1);
3423
+ (0, chai_1.expect)(result[0].message).to.include('Matches a schema that is not allowed');
3424
+ // empty object is valid
3425
+ content = toContent({});
3426
+ result = await parseSetup(content);
3427
+ (0, chai_1.expect)(result).to.be.empty;
3428
+ });
3429
+ it('dependencies with escaped characters', async () => {
3430
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3431
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3432
+ dependentSchemas: {
3433
+ 'foo\tbar': { minProperties: 4 },
3434
+ "foo'bar": { required: ['foo"bar'] },
3435
+ },
3436
+ });
3437
+ // quoted tab
3438
+ let content = toContent({
3439
+ 'foo\tbar': 1,
3440
+ a: 2,
3441
+ b: 3,
3442
+ c: 4,
3443
+ });
3444
+ let result = await parseSetup(content);
3445
+ (0, chai_1.expect)(result).to.be.empty;
3446
+ // quoted quote
3447
+ content = toContent({
3448
+ "foo'bar": { 'foo"bar': 1 },
3449
+ });
3450
+ result = await parseSetup(content);
3451
+ (0, chai_1.expect)(result).to.have.length(1);
3452
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
3453
+ // quoted tab invalid under dependent schema
3454
+ content = toContent({
3455
+ 'foo\tbar': 1,
3456
+ a: 2,
3457
+ });
3458
+ result = await parseSetup(content);
3459
+ (0, chai_1.expect)(result).to.have.length(1);
3460
+ (0, chai_1.expect)(result[0].message).to.include('Object has fewer properties than the required number of 4');
3461
+ // quoted quote invalid under dependent schema
3462
+ content = toContent({ "foo'bar": 1 });
3463
+ result = await parseSetup(content);
3464
+ (0, chai_1.expect)(result).to.have.length(1);
3465
+ (0, chai_1.expect)(result[0].message).to.include('Missing property');
3466
+ });
3467
+ it('dependent subschema incompatible with root', async () => {
3468
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3469
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3470
+ properties: {
3471
+ foo: {},
3472
+ },
3473
+ dependentSchemas: {
3474
+ foo: {
3475
+ properties: {
3476
+ bar: {},
3477
+ },
3478
+ additionalProperties: false,
3479
+ },
3480
+ },
3481
+ });
3482
+ // matches root
3483
+ let content = toContent({ foo: 1 });
3484
+ let result = await parseSetup(content);
3485
+ (0, chai_1.expect)(result).to.have.length(1);
3486
+ (0, chai_1.expect)(result[0].message).to.include('not allowed');
3487
+ // matches dependency
3488
+ content = toContent({ bar: 1 });
3489
+ result = await parseSetup(content);
3490
+ (0, chai_1.expect)(result).to.be.empty;
3491
+ // matches both
3492
+ content = toContent({ foo: 1, bar: 2 });
3493
+ result = await parseSetup(content);
3494
+ (0, chai_1.expect)(result).to.have.length(1);
3495
+ (0, chai_1.expect)(result[0].message).to.include('not allowed');
3496
+ // no dependency
3497
+ content = toContent({ baz: 1 });
3498
+ result = await parseSetup(content);
3499
+ (0, chai_1.expect)(result).to.be.empty;
3500
+ });
3501
+ });
3502
+ describe('keyword: dependentRequired', () => {
3503
+ it('single dependency', async () => {
3504
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3505
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3506
+ dependentRequired: { bar: ['foo'] },
3507
+ });
3508
+ // neither
3509
+ let content = toContent({});
3510
+ let result = await parseSetup(content);
3511
+ (0, chai_1.expect)(result).to.be.empty;
3512
+ // nondependant
3513
+ content = toContent({ foo: 1 });
3514
+ result = await parseSetup(content);
3515
+ (0, chai_1.expect)(result).to.be.empty;
3516
+ // with dependency
3517
+ content = toContent({ foo: 1, bar: 2 });
3518
+ result = await parseSetup(content);
3519
+ (0, chai_1.expect)(result).to.be.empty;
3520
+ // missing dependency
3521
+ content = toContent({ bar: 2 });
3522
+ result = await parseSetup(content);
3523
+ (0, chai_1.expect)(result).to.have.length(1);
3524
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property foo required by property bar.');
3525
+ // ignores arrays
3526
+ content = toContent(['bar']);
3527
+ result = await parseSetup(content);
3528
+ (0, chai_1.expect)(result).to.be.empty;
3529
+ // ignores strings
3530
+ content = toContent('foobar');
3531
+ result = await parseSetup(content);
3532
+ (0, chai_1.expect)(result).to.be.empty;
3533
+ // ignores other non-objects
3534
+ content = toContent(12);
3535
+ result = await parseSetup(content);
3536
+ (0, chai_1.expect)(result).to.be.empty;
3537
+ });
3538
+ it('empty dependents', async () => {
3539
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3540
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3541
+ dependentRequired: { bar: [] },
3542
+ });
3543
+ // empty object
3544
+ let content = toContent({});
3545
+ let result = await parseSetup(content);
3546
+ (0, chai_1.expect)(result).to.be.empty;
3547
+ // object with one property
3548
+ content = toContent({ bar: 2 });
3549
+ result = await parseSetup(content);
3550
+ (0, chai_1.expect)(result).to.be.empty;
3551
+ // non-object is valid
3552
+ content = toContent(1);
3553
+ result = await parseSetup(content);
3554
+ (0, chai_1.expect)(result).to.be.empty;
3555
+ });
3556
+ it('multiple dependents required', async () => {
3557
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3558
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3559
+ dependentRequired: { quux: ['foo', 'bar'] },
3560
+ });
3561
+ // neither
3562
+ let content = toContent({});
3563
+ let result = await parseSetup(content);
3564
+ (0, chai_1.expect)(result).to.be.empty;
3565
+ // nondependants
3566
+ content = toContent({ foo: 1, bar: 2 });
3567
+ result = await parseSetup(content);
3568
+ (0, chai_1.expect)(result).to.be.empty;
3569
+ // with dependencies
3570
+ content = toContent({ foo: 1, bar: 2, quux: 3 });
3571
+ result = await parseSetup(content);
3572
+ (0, chai_1.expect)(result).to.be.empty;
3573
+ // missing dependency
3574
+ content = toContent({ foo: 1, quux: 2 });
3575
+ result = await parseSetup(content);
3576
+ (0, chai_1.expect)(result).to.have.length(1);
3577
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property bar required by property quux.');
3578
+ // missing other dependency
3579
+ content = toContent({ bar: 1, quux: 2 });
3580
+ result = await parseSetup(content);
3581
+ (0, chai_1.expect)(result).to.have.length(1);
3582
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property foo required by property quux.');
3583
+ // missing both dependencies
3584
+ content = toContent({ quux: 1 });
3585
+ result = await parseSetup(content);
3586
+ (0, chai_1.expect)(result).to.have.length(2);
3587
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property foo required by property quux.');
3588
+ (0, chai_1.expect)(result[1].message).to.include('Object is missing property bar required by property quux.');
3589
+ });
3590
+ it('dependencies with escaped characters', async () => {
3591
+ schemaProvider.addSchema(testHelper_1.SCHEMA_ID, {
3592
+ $schema: 'https://json-schema.org/draft/2019-09/schema',
3593
+ dependentRequired: {
3594
+ 'foo\nbar': ['foo\rbar'],
3595
+ 'foo"bar': ["foo'bar"],
3596
+ },
3597
+ });
3598
+ // CRLF
3599
+ let content = toContent({
3600
+ 'foo\nbar': 1,
3601
+ 'foo\rbar': 2,
3602
+ });
3603
+ let result = await parseSetup(content);
3604
+ (0, chai_1.expect)(result).to.be.empty;
3605
+ // quoted quotes
3606
+ content = toContent({
3607
+ "foo'bar": 1,
3608
+ 'foo"bar': 2,
3609
+ });
3610
+ result = await parseSetup(content);
3611
+ (0, chai_1.expect)(result).to.be.empty;
3612
+ // CRLF missing dependent
3613
+ content = toContent({
3614
+ 'foo\nbar': 1,
3615
+ foo: 2,
3616
+ });
3617
+ result = await parseSetup(content);
3618
+ (0, chai_1.expect)(result).to.have.length(1);
3619
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property foo\rbar required by property foo\nbar.');
3620
+ // quoted quotes missing dependent
3621
+ content = toContent({
3622
+ 'foo"bar': 2,
3623
+ });
3624
+ result = await parseSetup(content);
3625
+ (0, chai_1.expect)(result).to.have.length(1);
3626
+ (0, chai_1.expect)(result[0].message).to.include('Object is missing property foo\'bar required by property foo"bar.');
3627
+ });
3628
+ });
3629
+ });
3630
+ //# sourceMappingURL=schema2019Validation.test.js.map