@skmtc/core 0.39.0 → 0.41.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 (373) hide show
  1. package/esm/context/CoreContext.js +22 -8
  2. package/esm/context/GenerateContext.d.ts +6 -5
  3. package/esm/context/GenerateContext.js +112 -38
  4. package/esm/context/ParseContext.d.ts +18 -1
  5. package/esm/context/ParseContext.js +102 -3
  6. package/esm/context/generateTypes.d.ts +33 -4
  7. package/esm/context/generateTypes.js +4 -0
  8. package/esm/context/toGenerationFailure.d.ts +21 -0
  9. package/esm/context/toGenerationFailure.js +38 -0
  10. package/esm/context/tryParseAt.d.ts +4 -1
  11. package/esm/context/tryParseAt.js +10 -3
  12. package/esm/dsl/CustomValue.d.ts +4 -0
  13. package/esm/dsl/CustomValue.js +8 -0
  14. package/esm/dsl/Definition.d.ts +10 -0
  15. package/esm/dsl/Definition.js +14 -0
  16. package/esm/dsl/PendingDefinition.d.ts +47 -0
  17. package/esm/dsl/PendingDefinition.js +83 -0
  18. package/esm/dsl/model/ModelDriver.d.ts +55 -1
  19. package/esm/dsl/model/ModelDriver.js +228 -51
  20. package/esm/dsl/model/toModelEntry.d.ts +1 -1
  21. package/esm/dsl/model/toModelEntry.js +1 -1
  22. package/esm/dsl/model/types.d.ts +1 -1
  23. package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -4
  24. package/esm/dsl/webhook/WebhookDriver.js +1 -4
  25. package/esm/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
  26. package/esm/enrichments/parseEnrichmentUmbrella.js +23 -8
  27. package/esm/enrichments/parseEnrichmentValue.d.ts +17 -0
  28. package/esm/enrichments/parseEnrichmentValue.js +32 -0
  29. package/esm/enrichments/readEnrichments.d.ts +5 -5
  30. package/esm/enrichments/readEnrichments.js +17 -7
  31. package/esm/helpers/collateExamples.js +15 -5
  32. package/esm/helpers/refFns.d.ts +6 -2
  33. package/esm/helpers/refFns.js +24 -7
  34. package/esm/mod.d.ts +2 -0
  35. package/esm/mod.js +2 -0
  36. package/esm/oas/array/Array.d.ts +19 -0
  37. package/esm/oas/array/Array.js +47 -0
  38. package/esm/oas/boolean/Boolean.d.ts +19 -0
  39. package/esm/oas/boolean/Boolean.js +51 -8
  40. package/esm/oas/example/Example.d.ts +4 -0
  41. package/esm/oas/example/Example.js +8 -0
  42. package/esm/oas/header/Header.d.ts +4 -0
  43. package/esm/oas/header/Header.js +8 -0
  44. package/esm/oas/integer/Integer.d.ts +19 -0
  45. package/esm/oas/integer/Integer.js +49 -0
  46. package/esm/oas/link/Link.d.ts +4 -0
  47. package/esm/oas/link/Link.js +8 -0
  48. package/esm/oas/number/Number.d.ts +19 -0
  49. package/esm/oas/number/Number.js +49 -0
  50. package/esm/oas/object/Object.d.ts +19 -0
  51. package/esm/oas/object/Object.js +68 -18
  52. package/esm/oas/operation/Operation.d.ts +8 -1
  53. package/esm/oas/operation/Operation.js +18 -5
  54. package/esm/oas/operation/toEffectiveParameters.d.ts +24 -0
  55. package/esm/oas/operation/toEffectiveParameters.js +42 -0
  56. package/esm/oas/parameter/Parameter.d.ts +4 -0
  57. package/esm/oas/parameter/Parameter.js +8 -0
  58. package/esm/oas/ref/DanglingRefError.d.ts +22 -0
  59. package/esm/oas/ref/DanglingRefError.js +33 -0
  60. package/esm/oas/ref/Ref.d.ts +152 -25
  61. package/esm/oas/ref/Ref.js +414 -26
  62. package/esm/oas/requestBody/RequestBody.d.ts +4 -0
  63. package/esm/oas/requestBody/RequestBody.js +8 -0
  64. package/esm/oas/response/Response.d.ts +4 -0
  65. package/esm/oas/response/Response.js +8 -0
  66. package/esm/oas/schema/siblings.d.ts +127 -0
  67. package/esm/oas/schema/siblings.js +250 -0
  68. package/esm/oas/securitySchemes/SecurityScheme.d.ts +16 -0
  69. package/esm/oas/securitySchemes/SecurityScheme.js +32 -0
  70. package/esm/oas/string/String.d.ts +19 -0
  71. package/esm/oas/string/String.js +47 -0
  72. package/esm/oas/union/Union.d.ts +32 -0
  73. package/esm/oas/union/Union.js +111 -0
  74. package/esm/oas/unknown/Unknown.d.ts +18 -0
  75. package/esm/oas/unknown/Unknown.js +38 -0
  76. package/esm/oas/void/Void.d.ts +4 -0
  77. package/esm/oas/void/Void.js +8 -0
  78. package/esm/oas/webhook/Webhook.d.ts +2 -2
  79. package/esm/oas/webhook/Webhook.js +4 -5
  80. package/esm/parse/allOfSystem.d.ts +32 -0
  81. package/esm/parse/allOfSystem.js +30 -0
  82. package/esm/parse/anyOfSystem.d.ts +68 -0
  83. package/esm/parse/anyOfSystem.js +107 -0
  84. package/esm/parse/securityRequirements.d.ts +6 -0
  85. package/esm/parse/securityRequirements.js +8 -0
  86. package/esm/parse/toSiblingKeywords.d.ts +28 -0
  87. package/esm/parse/toSiblingKeywords.js +109 -0
  88. package/esm/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
  89. package/esm/parse/v3-0/_merge-all-of/decompose-union.js +9 -1
  90. package/esm/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
  91. package/esm/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
  92. package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
  93. package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
  94. package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  95. package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
  96. package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  97. package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
  98. package/esm/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
  99. package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
  100. package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
  101. package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
  102. package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
  103. package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
  104. package/esm/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
  105. package/esm/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
  106. package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
  107. package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
  108. package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
  109. package/esm/parse/v3-0/_merge-all-of/merge-union.js +50 -12
  110. package/esm/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
  111. package/esm/parse/v3-0/_merge-all-of/merge.js +78 -27
  112. package/esm/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
  113. package/esm/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
  114. package/esm/parse/v3-0/_merge-all-of/types.d.ts +33 -0
  115. package/esm/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
  116. package/esm/parse/v3-0/parameter/toParameterV3.js +4 -3
  117. package/esm/parse/v3-0/ref/toRefV31.d.ts +7 -1
  118. package/esm/parse/v3-0/ref/toRefV31.js +6 -3
  119. package/esm/parse/v3-0/schema/toSchemasV3.js +107 -15
  120. package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
  121. package/esm/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
  122. package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
  123. package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
  124. package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
  125. package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
  126. package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  127. package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
  128. package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  129. package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
  130. package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
  131. package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
  132. package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
  133. package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
  134. package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
  135. package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
  136. package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
  137. package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
  138. package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
  139. package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
  140. package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
  141. package/esm/parse/v3-1/_merge-all-of/merge-union.js +54 -15
  142. package/esm/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
  143. package/esm/parse/v3-1/_merge-all-of/merge.js +88 -29
  144. package/esm/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
  145. package/esm/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
  146. package/esm/parse/v3-1/_merge-all-of/types.d.ts +37 -0
  147. package/esm/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
  148. package/esm/parse/v3-1/parameter/toParameterV3.js +4 -3
  149. package/esm/parse/v3-1/ref/toRefV31.d.ts +7 -1
  150. package/esm/parse/v3-1/ref/toRefV31.js +6 -3
  151. package/esm/parse/v3-1/schema/toSchemasV3.js +111 -16
  152. package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
  153. package/esm/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
  154. package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
  155. package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
  156. package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
  157. package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
  158. package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  159. package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
  160. package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  161. package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
  162. package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
  163. package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
  164. package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
  165. package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
  166. package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
  167. package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
  168. package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
  169. package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
  170. package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
  171. package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
  172. package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
  173. package/esm/parse/v3-2/_merge-all-of/merge-union.js +54 -15
  174. package/esm/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
  175. package/esm/parse/v3-2/_merge-all-of/merge.js +88 -29
  176. package/esm/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
  177. package/esm/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
  178. package/esm/parse/v3-2/_merge-all-of/types.d.ts +37 -0
  179. package/esm/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
  180. package/esm/parse/v3-2/parameter/toParameterV3.js +4 -3
  181. package/esm/parse/v3-2/ref/toRefV31.d.ts +7 -1
  182. package/esm/parse/v3-2/ref/toRefV31.js +6 -3
  183. package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
  184. package/esm/types/OasBase.d.ts +1 -1
  185. package/esm/types/Settings.d.ts +44 -0
  186. package/esm/types/Settings.js +9 -0
  187. package/package.json +5 -1
  188. package/script/context/CoreContext.js +22 -8
  189. package/script/context/GenerateContext.d.ts +6 -5
  190. package/script/context/GenerateContext.js +112 -38
  191. package/script/context/ParseContext.d.ts +18 -1
  192. package/script/context/ParseContext.js +102 -3
  193. package/script/context/generateTypes.d.ts +33 -4
  194. package/script/context/generateTypes.js +4 -0
  195. package/script/context/toGenerationFailure.d.ts +21 -0
  196. package/script/context/toGenerationFailure.js +43 -0
  197. package/script/context/tryParseAt.d.ts +4 -1
  198. package/script/context/tryParseAt.js +10 -3
  199. package/script/dsl/CustomValue.d.ts +4 -0
  200. package/script/dsl/CustomValue.js +8 -0
  201. package/script/dsl/Definition.d.ts +10 -0
  202. package/script/dsl/Definition.js +14 -0
  203. package/script/dsl/PendingDefinition.d.ts +47 -0
  204. package/script/dsl/PendingDefinition.js +87 -0
  205. package/script/dsl/model/ModelDriver.d.ts +55 -1
  206. package/script/dsl/model/ModelDriver.js +231 -52
  207. package/script/dsl/model/toModelEntry.d.ts +1 -1
  208. package/script/dsl/model/toModelEntry.js +1 -1
  209. package/script/dsl/model/types.d.ts +1 -1
  210. package/script/dsl/operation/gql/GqlOperationDriver.js +1 -4
  211. package/script/dsl/webhook/WebhookDriver.js +1 -4
  212. package/script/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
  213. package/script/enrichments/parseEnrichmentUmbrella.js +23 -41
  214. package/script/enrichments/parseEnrichmentValue.d.ts +17 -0
  215. package/script/enrichments/parseEnrichmentValue.js +69 -0
  216. package/script/enrichments/readEnrichments.d.ts +5 -5
  217. package/script/enrichments/readEnrichments.js +17 -40
  218. package/script/helpers/collateExamples.js +15 -5
  219. package/script/helpers/refFns.d.ts +6 -2
  220. package/script/helpers/refFns.js +24 -7
  221. package/script/mod.d.ts +2 -0
  222. package/script/mod.js +2 -0
  223. package/script/oas/array/Array.d.ts +19 -0
  224. package/script/oas/array/Array.js +47 -0
  225. package/script/oas/boolean/Boolean.d.ts +19 -0
  226. package/script/oas/boolean/Boolean.js +51 -8
  227. package/script/oas/example/Example.d.ts +4 -0
  228. package/script/oas/example/Example.js +8 -0
  229. package/script/oas/header/Header.d.ts +4 -0
  230. package/script/oas/header/Header.js +8 -0
  231. package/script/oas/integer/Integer.d.ts +19 -0
  232. package/script/oas/integer/Integer.js +49 -0
  233. package/script/oas/link/Link.d.ts +4 -0
  234. package/script/oas/link/Link.js +8 -0
  235. package/script/oas/number/Number.d.ts +19 -0
  236. package/script/oas/number/Number.js +49 -0
  237. package/script/oas/object/Object.d.ts +19 -0
  238. package/script/oas/object/Object.js +68 -18
  239. package/script/oas/operation/Operation.d.ts +8 -1
  240. package/script/oas/operation/Operation.js +18 -5
  241. package/script/oas/operation/toEffectiveParameters.d.ts +24 -0
  242. package/script/oas/operation/toEffectiveParameters.js +47 -0
  243. package/script/oas/parameter/Parameter.d.ts +4 -0
  244. package/script/oas/parameter/Parameter.js +8 -0
  245. package/script/oas/ref/DanglingRefError.d.ts +22 -0
  246. package/script/oas/ref/DanglingRefError.js +37 -0
  247. package/script/oas/ref/Ref.d.ts +152 -25
  248. package/script/oas/ref/Ref.js +414 -26
  249. package/script/oas/requestBody/RequestBody.d.ts +4 -0
  250. package/script/oas/requestBody/RequestBody.js +8 -0
  251. package/script/oas/response/Response.d.ts +4 -0
  252. package/script/oas/response/Response.js +8 -0
  253. package/script/oas/schema/siblings.d.ts +127 -0
  254. package/script/oas/schema/siblings.js +305 -0
  255. package/script/oas/securitySchemes/SecurityScheme.d.ts +16 -0
  256. package/script/oas/securitySchemes/SecurityScheme.js +32 -0
  257. package/script/oas/string/String.d.ts +19 -0
  258. package/script/oas/string/String.js +47 -0
  259. package/script/oas/union/Union.d.ts +32 -0
  260. package/script/oas/union/Union.js +111 -0
  261. package/script/oas/unknown/Unknown.d.ts +18 -0
  262. package/script/oas/unknown/Unknown.js +38 -0
  263. package/script/oas/void/Void.d.ts +4 -0
  264. package/script/oas/void/Void.js +8 -0
  265. package/script/oas/webhook/Webhook.d.ts +2 -2
  266. package/script/oas/webhook/Webhook.js +4 -5
  267. package/script/parse/allOfSystem.d.ts +32 -0
  268. package/script/parse/allOfSystem.js +35 -0
  269. package/script/parse/anyOfSystem.d.ts +68 -0
  270. package/script/parse/anyOfSystem.js +116 -0
  271. package/script/parse/securityRequirements.d.ts +6 -0
  272. package/script/parse/securityRequirements.js +8 -0
  273. package/script/parse/toSiblingKeywords.d.ts +28 -0
  274. package/script/parse/toSiblingKeywords.js +146 -0
  275. package/script/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
  276. package/script/parse/v3-0/_merge-all-of/decompose-union.js +11 -2
  277. package/script/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
  278. package/script/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
  279. package/script/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
  280. package/script/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
  281. package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  282. package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
  283. package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  284. package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
  285. package/script/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
  286. package/script/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
  287. package/script/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
  288. package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
  289. package/script/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
  290. package/script/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
  291. package/script/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
  292. package/script/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
  293. package/script/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
  294. package/script/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
  295. package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
  296. package/script/parse/v3-0/_merge-all-of/merge-union.js +52 -13
  297. package/script/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
  298. package/script/parse/v3-0/_merge-all-of/merge.js +77 -26
  299. package/script/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
  300. package/script/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
  301. package/script/parse/v3-0/_merge-all-of/types.d.ts +33 -0
  302. package/script/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
  303. package/script/parse/v3-0/parameter/toParameterV3.js +4 -3
  304. package/script/parse/v3-0/ref/toRefV31.d.ts +7 -1
  305. package/script/parse/v3-0/ref/toRefV31.js +6 -3
  306. package/script/parse/v3-0/schema/toSchemasV3.js +107 -15
  307. package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
  308. package/script/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
  309. package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
  310. package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
  311. package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
  312. package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
  313. package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  314. package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
  315. package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  316. package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
  317. package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
  318. package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
  319. package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
  320. package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
  321. package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
  322. package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
  323. package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
  324. package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
  325. package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
  326. package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
  327. package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
  328. package/script/parse/v3-1/_merge-all-of/merge-union.js +56 -16
  329. package/script/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
  330. package/script/parse/v3-1/_merge-all-of/merge.js +87 -28
  331. package/script/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
  332. package/script/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
  333. package/script/parse/v3-1/_merge-all-of/types.d.ts +37 -0
  334. package/script/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
  335. package/script/parse/v3-1/parameter/toParameterV3.js +4 -3
  336. package/script/parse/v3-1/ref/toRefV31.d.ts +7 -1
  337. package/script/parse/v3-1/ref/toRefV31.js +6 -3
  338. package/script/parse/v3-1/schema/toSchemasV3.js +111 -16
  339. package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
  340. package/script/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
  341. package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
  342. package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
  343. package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
  344. package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
  345. package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  346. package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
  347. package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  348. package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
  349. package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
  350. package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
  351. package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
  352. package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
  353. package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
  354. package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
  355. package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
  356. package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
  357. package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
  358. package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
  359. package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
  360. package/script/parse/v3-2/_merge-all-of/merge-union.js +56 -16
  361. package/script/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
  362. package/script/parse/v3-2/_merge-all-of/merge.js +87 -28
  363. package/script/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
  364. package/script/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
  365. package/script/parse/v3-2/_merge-all-of/types.d.ts +37 -0
  366. package/script/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
  367. package/script/parse/v3-2/parameter/toParameterV3.js +4 -3
  368. package/script/parse/v3-2/ref/toRefV31.d.ts +7 -1
  369. package/script/parse/v3-2/ref/toRefV31.js +6 -3
  370. package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
  371. package/script/types/OasBase.d.ts +1 -1
  372. package/script/types/Settings.d.ts +44 -0
  373. package/script/types/Settings.js +10 -1
@@ -1,5 +1,7 @@
1
1
  import { traverseSchema } from '../schemaPath/traverseSchema.js';
2
+ import { toSiblingAnnotations } from '../schema/siblings.js';
2
3
  import { OasBase } from '../../types/OasBase.js';
4
+ import { DanglingRefError } from '../ref/DanglingRefError.js';
3
5
  /**
4
6
  * Represents a union type schema in the OpenAPI Specification.
5
7
  *
@@ -213,6 +215,17 @@ export class OasUnion extends OasBase {
213
215
  writable: true,
214
216
  value: void 0
215
217
  });
218
+ /**
219
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
220
+ * `system.not: unknown`: the document says "not something", and core does
221
+ * not read what. `undefined` otherwise.
222
+ */
223
+ Object.defineProperty(this, "not", {
224
+ enumerable: true,
225
+ configurable: true,
226
+ writable: true,
227
+ value: undefined
228
+ });
216
229
  this.title = fields.title;
217
230
  this.description = fields.description;
218
231
  this.externalDocs = fields.externalDocs;
@@ -226,6 +239,36 @@ export class OasUnion extends OasBase {
226
239
  isRef() {
227
240
  return false;
228
241
  }
242
+ /** Always `false`: this schema has no `readOnly`. */
243
+ isReadOnly() {
244
+ return false;
245
+ }
246
+ /** Always `false`: this schema has no `writeOnly`. */
247
+ isWriteOnly() {
248
+ return false;
249
+ }
250
+ /**
251
+ * A copy of this schema with what `ref` adds at its site applied: its
252
+ * `nullable` and the keywords next to it (`SiblingKeywords`) that
253
+ * this type takes, a sibling's value winning. A value that does not fit
254
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
255
+ * This schema does not change, and the copy shares its child schemas.
256
+ */
257
+ clone(ref) {
258
+ const nullable = this.nullable || ref?.nullable || undefined;
259
+ const copy = new OasUnion({
260
+ ...toSiblingAnnotations(this, ref),
261
+ example: ref?.example ?? this.example,
262
+ externalDocs: this.externalDocs,
263
+ nullable,
264
+ discriminator: this.discriminator,
265
+ members: this.members,
266
+ default: ref?.default ?? this.default,
267
+ });
268
+ copy.stackTrail = this.stackTrail;
269
+ copy.not = this.not;
270
+ return copy;
271
+ }
229
272
  traverse(path) {
230
273
  return traverseSchema(this, path);
231
274
  }
@@ -235,6 +278,45 @@ export class OasUnion extends OasBase {
235
278
  resolveOnce() {
236
279
  return this;
237
280
  }
281
+ /**
282
+ * Whether the discriminator alone picks the member of a value: the union
283
+ * names a discriminator, and each member, followed through references, is
284
+ * an object that is not nullable, that requires the discriminator's
285
+ * property, and that allows only string literals for it. No value may
286
+ * belong to two members. A member that is a union, or anything other than
287
+ * an object, makes it `false`, as does a reference on the way that names
288
+ * nothing in the document (kept under `system.danglingRefs: keep`).
289
+ *
290
+ * It reads the schemas only. A generator may refuse more: one that leaves
291
+ * out `readOnly` properties cannot discriminate on one.
292
+ */
293
+ isDiscriminable() {
294
+ const key = this.discriminator?.propertyName;
295
+ if (key === undefined) {
296
+ return false;
297
+ }
298
+ const seen = new Set();
299
+ try {
300
+ return this.members.every(member => {
301
+ const values = toDiscriminatorValues(member, key);
302
+ return (values !== undefined &&
303
+ values.every(value => {
304
+ if (seen.has(value)) {
305
+ return false;
306
+ }
307
+ seen.add(value);
308
+ return true;
309
+ }));
310
+ });
311
+ }
312
+ catch (error) {
313
+ // A dangling reference: the schema it stands for is not known.
314
+ if (DanglingRefError.is(error)) {
315
+ return false;
316
+ }
317
+ throw error;
318
+ }
319
+ }
238
320
  toJsonSchema(options) {
239
321
  return {
240
322
  title: this.title,
@@ -246,3 +328,32 @@ export class OasUnion extends OasBase {
246
328
  };
247
329
  }
248
330
  }
331
+ /**
332
+ * The values a member allows for the discriminator `key`, or `undefined`
333
+ * when the member is not an object, is nullable, or does not require `key`
334
+ * with string literals only.
335
+ */
336
+ const toDiscriminatorValues = (member, key) => {
337
+ // `resolve()`, not `resolveOnce()`: the schema at this site, with the
338
+ // keywords next to the reference (`properties`, `required`) applied.
339
+ if (member.isRef()) {
340
+ return member.nullable ? undefined : toDiscriminatorValues(member.resolve(), key);
341
+ }
342
+ if (member.type !== 'object' || member.nullable) {
343
+ return undefined;
344
+ }
345
+ const property = member.properties?.[key];
346
+ return property === undefined || !member.required?.includes(key) ? undefined : toLiteralValues(property);
347
+ };
348
+ /** The string literals a schema allows, or `undefined` when it allows anything else too. */
349
+ const toLiteralValues = (schema) => {
350
+ if (schema.isRef()) {
351
+ return schema.nullable ? undefined : toLiteralValues(schema.resolve());
352
+ }
353
+ if (schema.type !== 'string' || schema.nullable || schema.enums === undefined) {
354
+ return undefined;
355
+ }
356
+ const enums = schema.enums;
357
+ const strings = enums.filter((value) => value !== null);
358
+ return strings.length > 0 && strings.length === enums.length ? strings : undefined;
359
+ };
@@ -43,8 +43,26 @@ export declare class OasUnknown extends OasBase {
43
43
  example: unknown | undefined;
44
44
  /** Whether the unknown type is nullable */
45
45
  nullable: boolean | undefined;
46
+ /**
47
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
48
+ * `system.not: unknown`: the document says "not something", and core does
49
+ * not read what. `undefined` otherwise.
50
+ */
51
+ not: OasUnknown | undefined;
46
52
  constructor(fields?: UnknownFields, context?: ParseContextType);
47
53
  isRef(): this is OasRef<'schema'>;
54
+ /** Always `false`: this schema has no `readOnly`. */
55
+ isReadOnly(): boolean;
56
+ /** Always `false`: this schema has no `writeOnly`. */
57
+ isWriteOnly(): boolean;
58
+ /**
59
+ * A copy of this schema with what `ref` adds at its site applied: its
60
+ * `nullable` and the keywords next to it (`SiblingKeywords`) that
61
+ * this type takes, a sibling's value winning. A value that does not fit
62
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
63
+ * This schema does not change, and the copy shares its child schemas.
64
+ */
65
+ clone(ref?: OasRef<'schema'>): OasUnknown;
48
66
  traverse(path: SchemaPath): OasSchema | OasRef<'schema'>;
49
67
  resolve(): OasUnknown;
50
68
  resolveOnce(): OasUnknown;
@@ -1,5 +1,6 @@
1
1
  import "../../_dnt.polyfills.js";
2
2
  import { traverseSchema } from '../schemaPath/traverseSchema.js';
3
+ import { toSiblingAnnotations } from '../schema/siblings.js';
3
4
  import { OasBase } from '../../types/OasBase.js';
4
5
  /**
5
6
  * Object representing an unknown type in the OpenAPI Specification.
@@ -69,6 +70,17 @@ export class OasUnknown extends OasBase {
69
70
  writable: true,
70
71
  value: void 0
71
72
  });
73
+ /**
74
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
75
+ * `system.not: unknown`: the document says "not something", and core does
76
+ * not read what. `undefined` otherwise.
77
+ */
78
+ Object.defineProperty(this, "not", {
79
+ enumerable: true,
80
+ configurable: true,
81
+ writable: true,
82
+ value: undefined
83
+ });
72
84
  this.title = fields.title;
73
85
  this.description = fields.description;
74
86
  this.extensionFields = fields.extensionFields;
@@ -78,6 +90,32 @@ export class OasUnknown extends OasBase {
78
90
  isRef() {
79
91
  return false;
80
92
  }
93
+ /** Always `false`: this schema has no `readOnly`. */
94
+ isReadOnly() {
95
+ return false;
96
+ }
97
+ /** Always `false`: this schema has no `writeOnly`. */
98
+ isWriteOnly() {
99
+ return false;
100
+ }
101
+ /**
102
+ * A copy of this schema with what `ref` adds at its site applied: its
103
+ * `nullable` and the keywords next to it (`SiblingKeywords`) that
104
+ * this type takes, a sibling's value winning. A value that does not fit
105
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
106
+ * This schema does not change, and the copy shares its child schemas.
107
+ */
108
+ clone(ref) {
109
+ const nullable = this.nullable || ref?.nullable || undefined;
110
+ const copy = new OasUnknown({
111
+ ...toSiblingAnnotations(this, ref),
112
+ example: ref?.example ?? this.example,
113
+ nullable,
114
+ });
115
+ copy.stackTrail = this.stackTrail;
116
+ copy.not = this.not;
117
+ return copy;
118
+ }
81
119
  traverse(path) {
82
120
  return traverseSchema(this, path);
83
121
  }
@@ -159,6 +159,10 @@ export declare class OasVoid extends OasBase {
159
159
  constructor(fields?: VoidFields, context?: ParseContextType);
160
160
  static empty(): OasVoid;
161
161
  isRef(): this is OasRef<'schema'>;
162
+ /** Always `false`: this schema has no `readOnly`. */
163
+ isReadOnly(): boolean;
164
+ /** Always `false`: this schema has no `writeOnly`. */
165
+ isWriteOnly(): boolean;
162
166
  resolve(): OasVoid;
163
167
  resolveOnce(): OasVoid;
164
168
  }
@@ -176,6 +176,14 @@ export class OasVoid extends OasBase {
176
176
  isRef() {
177
177
  return false;
178
178
  }
179
+ /** Always `false`: this schema has no `readOnly`. */
180
+ isReadOnly() {
181
+ return false;
182
+ }
183
+ /** Always `false`: this schema has no `writeOnly`. */
184
+ isWriteOnly() {
185
+ return false;
186
+ }
179
187
  resolve() {
180
188
  return this;
181
189
  }
@@ -122,8 +122,8 @@ export declare class OasWebhook extends OasBase {
122
122
  /**
123
123
  * Resolve the inbound parameters (e.g. the signature/headers a handler
124
124
  * receives), optionally filtered by location. Mirrors
125
- * {@link OasOperation.toParams}; the parameters carry the same shape, only
126
- * their direction is inbound.
125
+ * {@link OasOperation.toParams}, path item parameters included; the
126
+ * parameters carry the same shape, only their direction is inbound.
127
127
  */
128
128
  toParams(filter?: OasParameterLocation[]): OasParameter[];
129
129
  /**
@@ -1,6 +1,7 @@
1
1
  import "../../_dnt.polyfills.js";
2
2
  import { toPrimaryResponseCode } from '../response/toPrimaryResponseCode.js';
3
3
  import { OasBase } from '../../types/OasBase.js';
4
+ import { toEffectiveParameters, toResolvedParameters } from '../operation/toEffectiveParameters.js';
4
5
  /**
5
6
  * Represents an OpenAPI 3.1 webhook — a third OAS subject, peer to
6
7
  * {@link OasOperation} and the schema/model subjects.
@@ -168,13 +169,11 @@ export class OasWebhook extends OasBase {
168
169
  /**
169
170
  * Resolve the inbound parameters (e.g. the signature/headers a handler
170
171
  * receives), optionally filtered by location. Mirrors
171
- * {@link OasOperation.toParams}; the parameters carry the same shape, only
172
- * their direction is inbound.
172
+ * {@link OasOperation.toParams}, path item parameters included; the
173
+ * parameters carry the same shape, only their direction is inbound.
173
174
  */
174
175
  toParams(filter) {
175
- return (this.parameters
176
- ?.map(param => param.resolve())
177
- .filter(param => (filter?.length ? filter.includes(param.location) : true)) ?? []);
176
+ return toResolvedParameters(toEffectiveParameters({ own: this.parameters, shared: this.pathItem?.parameters })).filter(param => (filter?.length ? filter.includes(param.location) : true));
178
177
  }
179
178
  /**
180
179
  * The status code of the primary acknowledgement response — the lowest 2xx
@@ -0,0 +1,32 @@
1
+ import type { ParseContextType } from '../context/parseTypes.js';
2
+ import type { StackTrail } from '../context/StackTrail.js';
3
+ /** What the `allOf` merge reads of `client.json#settings.system`, and what it reports back. */
4
+ type AllOfSystem = {
5
+ allOf: 'strict' | 'latestWins';
6
+ not: 'strict' | 'unknown';
7
+ anyOf: 'union' | 'unknown';
8
+ /** The keywords a later member replaced under `latestWins`. */
9
+ replaced: Set<string>;
10
+ /** The keywords the merge read as any value: `anyOf` under `system.anyOf: unknown`. */
11
+ unknown: Set<string>;
12
+ };
13
+ /**
14
+ * The `system` settings for one merge: the `allOf` mode, `strict` when the
15
+ * settings leave it out, and an empty set for the keywords a later member
16
+ * replaces. Shared by the 3.0, 3.1 and 3.2 parsers.
17
+ */
18
+ export declare const toAllOfSystem: (context: ParseContextType) => AllOfSystem;
19
+ type LogAllOfContradictionsArgs = {
20
+ system: AllOfSystem;
21
+ /** The trail of the schema whose members were merged. */
22
+ stackTrail: StackTrail;
23
+ parent: unknown;
24
+ context: ParseContextType;
25
+ };
26
+ /**
27
+ * One warning for a schema whose `allOf` members contradicted, naming the
28
+ * keywords the later member kept (`system.allOf: latestWins`). Nothing when
29
+ * no keyword was replaced.
30
+ */
31
+ export declare const logAllOfContradictions: ({ system, stackTrail, parent, context }: LogAllOfContradictionsArgs) => void;
32
+ export {};
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The `system` settings for one merge: the `allOf` mode, `strict` when the
3
+ * settings leave it out, and an empty set for the keywords a later member
4
+ * replaces. Shared by the 3.0, 3.1 and 3.2 parsers.
5
+ */
6
+ export const toAllOfSystem = (context) => ({
7
+ // A test's mock context may have no `system`.
8
+ allOf: context.system?.allOf ?? 'strict',
9
+ not: context.system?.not ?? 'strict',
10
+ anyOf: context.system?.anyOf ?? 'union',
11
+ replaced: new Set(),
12
+ unknown: new Set()
13
+ });
14
+ /**
15
+ * One warning for a schema whose `allOf` members contradicted, naming the
16
+ * keywords the later member kept (`system.allOf: latestWins`). Nothing when
17
+ * no keyword was replaced.
18
+ */
19
+ export const logAllOfContradictions = ({ system, stackTrail, parent, context }) => {
20
+ if (system.replaced.size === 0) {
21
+ return;
22
+ }
23
+ context.logIssueNoKey({
24
+ level: 'warning',
25
+ message: `The allOf members contradict on ${[...system.replaced].join(', ')}; the later member's values are kept (system.allOf is latestWins).`,
26
+ parent,
27
+ stackTrail,
28
+ type: 'ALLOF_CONTRADICTION'
29
+ });
30
+ };
@@ -0,0 +1,68 @@
1
+ import type { OpenAPIV3 } from 'openapi-types';
2
+ import type { ParseContextType } from '../context/parseTypes.js';
3
+ import type { StackTrail } from '../context/StackTrail.js';
4
+ /** Whether one of the members of an `anyOf` is only `null`. */
5
+ export declare const hasNullMember: (members: readonly object[]) => boolean;
6
+ /** Follows a reference to the schema it names, as the parsers' `GetRefFn` does. */
7
+ type GetRefFn = (ref: OpenAPIV3.ReferenceObject) => OpenAPIV3.SchemaObject;
8
+ /** Arguments for {@link isUnknownAnyOf}. */
9
+ type IsUnknownAnyOfArgs = {
10
+ /** The `anyOf` members, as the document writes them. */
11
+ members: readonly (OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject)[];
12
+ /** `client.json` `system.anyOf`. A test's mock context may have none. */
13
+ setting: 'union' | 'unknown' | undefined;
14
+ getRef: GetRefFn;
15
+ };
16
+ /**
17
+ * Whether `system.anyOf: unknown` reads an `anyOf` as any value, as
18
+ * Cloudflare's `cf` reads it: when it has two or more members, not counting a
19
+ * `null` one, and one of them is not a single value.
20
+ *
21
+ * - An `anyOf` with one member is read as before, so `anyOf: [{ $ref }, {
22
+ * type: 'null' }]` stays a nullable reference.
23
+ * - An `anyOf` of single values stays a union (`string | number`): cf gives
24
+ * it one flag.
25
+ */
26
+ export declare const isUnknownAnyOf: ({ members, setting, getRef }: IsUnknownAnyOfArgs) => boolean;
27
+ /** Arguments for {@link withoutUnknownAnyOf}. */
28
+ type WithoutUnknownAnyOfArgs = {
29
+ schema: OpenAPIV3.SchemaObject;
30
+ /** `client.json` `system.anyOf`. */
31
+ setting: 'union' | 'unknown' | undefined;
32
+ getRef: GetRefFn;
33
+ };
34
+ /**
35
+ * `schema` with its other keywords and without an `anyOf` that
36
+ * `system.anyOf: unknown` reads as any value ({@link isUnknownAnyOf}), so the
37
+ * properties next to the `anyOf` stay. A `null` member makes it nullable. Any
38
+ * other schema is returned as it is.
39
+ */
40
+ export declare const withoutUnknownAnyOf: ({ schema, setting, getRef }: WithoutUnknownAnyOfArgs) => OpenAPIV3.SchemaObject;
41
+ /**
42
+ * Whether the keywords that are left when an `anyOf` is read as any value
43
+ * ({@link withoutUnknownAnyOf}) give the schema a shape of its own:
44
+ * `properties` next to the `anyOf` do. A `default`, an `example` or a
45
+ * `format` alone does not. The parser must not guess a type from them, as it
46
+ * does for a schema that has no type (`MISSING_STRING_TYPE`): the members
47
+ * were the type, and they are gone.
48
+ */
49
+ export declare const hasShapeKeyword: (schema: object) => boolean;
50
+ /** Arguments for {@link logUnknownAnyOf}. */
51
+ type LogUnknownAnyOfArgs = {
52
+ /** The trail of the schema whose `anyOf` was read as any value. */
53
+ stackTrail: StackTrail;
54
+ parent: unknown;
55
+ context: ParseContextType;
56
+ };
57
+ /** Arguments for {@link logMergedUnknownAnyOf}. */
58
+ type LogMergedUnknownAnyOfArgs = LogUnknownAnyOfArgs & {
59
+ /** The merge's `system`: `unknown` holds `anyOf` when the merge read one as any value. */
60
+ system: {
61
+ unknown: Set<string>;
62
+ };
63
+ };
64
+ /** One warning for a schema whose merge read an `anyOf` as any value. Nothing when it read none. */
65
+ export declare const logMergedUnknownAnyOf: ({ system, stackTrail, parent, context }: LogMergedUnknownAnyOfArgs) => void;
66
+ /** One warning for a schema whose `anyOf` was read as any value (`system.anyOf: unknown`). */
67
+ export declare const logUnknownAnyOf: ({ stackTrail, parent, context }: LogUnknownAnyOfArgs) => void;
68
+ export {};
@@ -0,0 +1,107 @@
1
+ import { isNullOnlyType } from './v3-2/schema/normalize-schema-shape.js';
2
+ /**
3
+ * Whether an `anyOf` member is only `null`: 3.0's `{ nullable: true, enum:
4
+ * [null] }`, or 3.1's `{ type: 'null' }` or `{ type: ['null'] }`, as the
5
+ * parsers read a null member.
6
+ */
7
+ const isNullMember = (member) => {
8
+ const fields = Object.fromEntries(Object.entries(member));
9
+ const values = fields.enum;
10
+ return (isNullOnlyType(fields.type) ||
11
+ (fields.nullable === true && Array.isArray(values) && values.length === 1 && values[0] === null));
12
+ };
13
+ /** Whether one of the members of an `anyOf` is only `null`. */
14
+ export const hasNullMember = (members) => members.some(isNullMember);
15
+ /** The types of a single value: a member of one of them is a scalar. */
16
+ const SCALAR_TYPES = ['string', 'number', 'integer', 'boolean'];
17
+ /** The JavaScript types of a scalar enum value. */
18
+ const SCALAR_VALUE_TYPES = ['string', 'number', 'boolean'];
19
+ /**
20
+ * Whether an `anyOf` member, followed through its references, is a single
21
+ * value: its `type` is a string, number, integer or boolean (besides `null`),
22
+ * or it has no `type` and an `enum` of such values.
23
+ */
24
+ const isScalarMember = (member) => {
25
+ const fields = Object.fromEntries(Object.entries(member));
26
+ const types = Array.isArray(fields.type) ? fields.type.filter(type => type !== 'null') : [fields.type];
27
+ if (fields.type !== undefined) {
28
+ return types.length > 0 && types.every(type => SCALAR_TYPES.includes(type));
29
+ }
30
+ return (Array.isArray(fields.enum) &&
31
+ fields.enum.every(value => value === null || SCALAR_VALUE_TYPES.includes(typeof value)));
32
+ };
33
+ /** Follows a member through its references, to the schema it names. Stops after 10 steps, at a cycle. */
34
+ const toMemberSchema = (member, getRef, steps = 0) => {
35
+ if (!('$ref' in member)) {
36
+ return member;
37
+ }
38
+ return steps < 10 ? toMemberSchema(getRef(member), getRef, steps + 1) : undefined;
39
+ };
40
+ /**
41
+ * Whether `system.anyOf: unknown` reads an `anyOf` as any value, as
42
+ * Cloudflare's `cf` reads it: when it has two or more members, not counting a
43
+ * `null` one, and one of them is not a single value.
44
+ *
45
+ * - An `anyOf` with one member is read as before, so `anyOf: [{ $ref }, {
46
+ * type: 'null' }]` stays a nullable reference.
47
+ * - An `anyOf` of single values stays a union (`string | number`): cf gives
48
+ * it one flag.
49
+ */
50
+ export const isUnknownAnyOf = ({ members, setting, getRef }) => {
51
+ if (setting !== 'unknown') {
52
+ return false;
53
+ }
54
+ const values = members.filter(member => !isNullMember(member)).map(member => toMemberSchema(member, getRef));
55
+ return values.length > 1 && !values.every(value => value !== undefined && isScalarMember(value));
56
+ };
57
+ /**
58
+ * `schema` with its other keywords and without an `anyOf` that
59
+ * `system.anyOf: unknown` reads as any value ({@link isUnknownAnyOf}), so the
60
+ * properties next to the `anyOf` stay. A `null` member makes it nullable. Any
61
+ * other schema is returned as it is.
62
+ */
63
+ export const withoutUnknownAnyOf = ({ schema, setting, getRef }) => {
64
+ const members = schema.anyOf ?? [];
65
+ if (!isUnknownAnyOf({ members, setting, getRef })) {
66
+ return schema;
67
+ }
68
+ const { anyOf: _anyOf, ...keywords } = schema;
69
+ return hasNullMember(members) ? { ...keywords, nullable: true } : keywords;
70
+ };
71
+ /** The keywords that give a schema its own shape, so it is more than any value. */
72
+ const SHAPE_KEYWORDS = [
73
+ 'type',
74
+ 'properties',
75
+ 'additionalProperties',
76
+ 'items',
77
+ 'enum',
78
+ 'const',
79
+ 'allOf',
80
+ 'oneOf',
81
+ '$ref'
82
+ ];
83
+ /**
84
+ * Whether the keywords that are left when an `anyOf` is read as any value
85
+ * ({@link withoutUnknownAnyOf}) give the schema a shape of its own:
86
+ * `properties` next to the `anyOf` do. A `default`, an `example` or a
87
+ * `format` alone does not. The parser must not guess a type from them, as it
88
+ * does for a schema that has no type (`MISSING_STRING_TYPE`): the members
89
+ * were the type, and they are gone.
90
+ */
91
+ export const hasShapeKeyword = (schema) => SHAPE_KEYWORDS.some(keyword => keyword in schema);
92
+ /** One warning for a schema whose merge read an `anyOf` as any value. Nothing when it read none. */
93
+ export const logMergedUnknownAnyOf = ({ system, stackTrail, parent, context }) => {
94
+ if (system.unknown.has('anyOf')) {
95
+ logUnknownAnyOf({ stackTrail, parent, context });
96
+ }
97
+ };
98
+ /** One warning for a schema whose `anyOf` was read as any value (`system.anyOf: unknown`). */
99
+ export const logUnknownAnyOf = ({ stackTrail, parent, context }) => {
100
+ context.logIssueNoKey({
101
+ level: 'warning',
102
+ message: 'The anyOf is read as any value (system.anyOf is unknown): the schema keeps its other keywords, without the anyOf members.',
103
+ parent,
104
+ stackTrail,
105
+ type: 'ANYOF_AS_UNKNOWN'
106
+ });
107
+ };
@@ -58,6 +58,12 @@ export type ToOperationsWithValidSecurityArgs<Item extends SecuredItem> = {
58
58
  * failed to parse or is not defined, or that has no `security` and
59
59
  * inherits an unusable root. Each dropped item logs one `INVALID_OPERATION`
60
60
  * error on its own trail. `security: []` inherits nothing and is kept.
61
+ *
62
+ * A kept item depends on each scheme its security names (its own, else the
63
+ * root's), as it would on a `$ref` to it, so it is registered as a consumer
64
+ * of the scheme. When the parser removes the scheme later (one that is a
65
+ * `$ref` that names nothing), the item goes with it, and so is never kept
66
+ * without its auth.
61
67
  */
62
68
  export declare const toOperationsWithValidSecurity: <Item extends SecuredItem>({ items, check }: ToOperationsWithValidSecurityArgs<Item>) => Item[];
63
69
  export {};
@@ -107,6 +107,12 @@ export const toSecurityCheck = ({ parse, declared, parsed, stackTrail, context }
107
107
  * failed to parse or is not defined, or that has no `security` and
108
108
  * inherits an unusable root. Each dropped item logs one `INVALID_OPERATION`
109
109
  * error on its own trail. `security: []` inherits nothing and is kept.
110
+ *
111
+ * A kept item depends on each scheme its security names (its own, else the
112
+ * root's), as it would on a `$ref` to it, so it is registered as a consumer
113
+ * of the scheme. When the parser removes the scheme later (one that is a
114
+ * `$ref` that names nothing), the item goes with it, and so is never kept
115
+ * without its auth.
110
116
  */
111
117
  export const toOperationsWithValidSecurity = ({ items, check }) => {
112
118
  return items.filter(item => {
@@ -114,6 +120,8 @@ export const toOperationsWithValidSecurity = ({ items, check }) => {
114
120
  ? toSchemeProblems(item.security, check).map(capitalize).join('. ') || undefined
115
121
  : check.rootProblem;
116
122
  if (message === undefined) {
123
+ const names = (item.security ?? check.rootSecurity ?? []).flatMap(({ requirement }) => Object.keys(requirement));
124
+ new Set(names).forEach(name => check.context.registerRef(item.stackTrail.clone(), `#/components/securitySchemes/${name}`));
117
125
  return true;
118
126
  }
119
127
  check.context.logIssueNoKey({
@@ -0,0 +1,28 @@
1
+ import type { OpenAPIV3 } from 'openapi-types';
2
+ import type { ParseContextType } from '../context/parseTypes.js';
3
+ import type { StackTrail } from '../context/StackTrail.js';
4
+ import type { OasSchema } from '../oas/schema/Schema.js';
5
+ import type { OasRef } from '../oas/ref/Ref.js';
6
+ import type { SiblingKeywords } from '../oas/schema/siblings.js';
7
+ type ToSiblingKeywordsArgs = {
8
+ /** The keywords next to the one member, without `allOf` and the use-site flags. */
9
+ keywords: OpenAPIV3.SchemaObject;
10
+ /** `keywords.properties`, parsed by the caller's version of the parser. */
11
+ properties: Record<string, OasSchema | OasRef<'schema'>> | undefined;
12
+ /** `keywords.additionalProperties`, parsed the same way. */
13
+ additionalProperties: boolean | OasSchema | OasRef<'schema'> | undefined;
14
+ /** The trail of the schema that holds the `allOf`. */
15
+ stackTrail: StackTrail;
16
+ context: ParseContextType;
17
+ };
18
+ /**
19
+ * The keywords next to a reference in a one-member `allOf`, read without the
20
+ * target's type (see `SiblingKeywords`): the reference stays lazy, so the
21
+ * target may not be parsed yet. The ones the target cannot take are left out
22
+ * at generate time (`OasRef.toSkippedSiblings`). An extension (`x-*`) is kept, as each
23
+ * version's `toSpecificationExtensionsV3` keeps one; a keyword that no schema
24
+ * has here is reported. `undefined` when no keyword is left. Shared by the
25
+ * 3.0, 3.1 and 3.2 parsers.
26
+ */
27
+ export declare const toSiblingKeywords: ({ keywords, properties, additionalProperties, stackTrail, context }: ToSiblingKeywordsArgs) => SiblingKeywords | undefined;
28
+ export {};