openapi-typesafe 1.0.0-rc.3 → 1.0.0-rc.4

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 (448) hide show
  1. package/CHANGELOG.md +1831 -0
  2. package/dist/adapters/node-file-system/file-claims.cjs +105 -0
  3. package/dist/adapters/node-file-system/file-claims.cjs.map +1 -0
  4. package/dist/adapters/node-file-system/file-claims.mjs +95 -0
  5. package/dist/adapters/node-file-system/file-claims.mjs.map +1 -0
  6. package/dist/adapters/node-file-system/file-identity.cjs +82 -0
  7. package/dist/adapters/node-file-system/file-identity.cjs.map +1 -0
  8. package/dist/adapters/node-file-system/file-identity.mjs +74 -0
  9. package/dist/adapters/node-file-system/file-identity.mjs.map +1 -0
  10. package/dist/adapters/node-file-system/node-file-system.cjs +90 -14
  11. package/dist/adapters/node-file-system/node-file-system.cjs.map +1 -1
  12. package/dist/adapters/node-file-system/node-file-system.mjs +90 -14
  13. package/dist/adapters/node-file-system/node-file-system.mjs.map +1 -1
  14. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs +75 -0
  15. package/dist/adapters/redocly-loader/bundled-mapping-copies.cjs.map +1 -0
  16. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs +72 -0
  17. package/dist/adapters/redocly-loader/bundled-mapping-copies.mjs.map +1 -0
  18. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs +1 -1
  19. package/dist/adapters/redocly-loader/bundled-ref-repair.cjs.map +1 -1
  20. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs +2 -2
  21. package/dist/adapters/redocly-loader/bundled-ref-repair.mjs.map +1 -1
  22. package/dist/adapters/redocly-loader/loaded-documents.cjs +28 -0
  23. package/dist/adapters/redocly-loader/loaded-documents.cjs.map +1 -0
  24. package/dist/adapters/redocly-loader/loaded-documents.mjs +21 -0
  25. package/dist/adapters/redocly-loader/loaded-documents.mjs.map +1 -0
  26. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +14 -15
  27. package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
  28. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +12 -13
  29. package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
  30. package/dist/adapters/redocly-loader/ref-access.cjs +31 -3
  31. package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
  32. package/dist/adapters/redocly-loader/ref-access.mjs +31 -3
  33. package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
  34. package/dist/adapters/redocly-loader/ref-holders.cjs +2 -2
  35. package/dist/adapters/redocly-loader/ref-holders.cjs.map +1 -1
  36. package/dist/adapters/redocly-loader/ref-holders.mjs +3 -3
  37. package/dist/adapters/redocly-loader/ref-holders.mjs.map +1 -1
  38. package/dist/adapters/redocly-loader/remote-body-limit.cjs +50 -0
  39. package/dist/adapters/redocly-loader/remote-body-limit.cjs.map +1 -0
  40. package/dist/adapters/redocly-loader/remote-body-limit.mjs +48 -0
  41. package/dist/adapters/redocly-loader/remote-body-limit.mjs.map +1 -0
  42. package/dist/adapters/redocly-loader/remote-fetch.cjs +35 -6
  43. package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
  44. package/dist/adapters/redocly-loader/remote-fetch.mjs +35 -6
  45. package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
  46. package/dist/adapters/redocly-loader/remote-node-limit.cjs +47 -0
  47. package/dist/adapters/redocly-loader/remote-node-limit.cjs.map +1 -0
  48. package/dist/adapters/redocly-loader/remote-node-limit.mjs +44 -0
  49. package/dist/adapters/redocly-loader/remote-node-limit.mjs.map +1 -0
  50. package/dist/adapters/redocly-loader/schema-load-errors.cjs +32 -8
  51. package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
  52. package/dist/adapters/redocly-loader/schema-load-errors.mjs +32 -9
  53. package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
  54. package/dist/adapters/redocly-loader/schema-source.cjs +11 -7
  55. package/dist/adapters/redocly-loader/schema-source.cjs.map +1 -1
  56. package/dist/adapters/redocly-loader/schema-source.mjs +12 -8
  57. package/dist/adapters/redocly-loader/schema-source.mjs.map +1 -1
  58. package/dist/adapters/redocly-loader/unsupported-keys.cjs +3 -5
  59. package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
  60. package/dist/adapters/redocly-loader/unsupported-keys.mjs +3 -5
  61. package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
  62. package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
  63. package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
  64. package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
  65. package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
  66. package/dist/api/default-ports.cjs +14 -2
  67. package/dist/api/default-ports.cjs.map +1 -1
  68. package/dist/api/default-ports.mjs +14 -2
  69. package/dist/api/default-ports.mjs.map +1 -1
  70. package/dist/api/discriminator-enum-parent.cjs +2 -2
  71. package/dist/api/discriminator-enum-parent.cjs.map +1 -1
  72. package/dist/api/discriminator-enum-parent.mjs +3 -3
  73. package/dist/api/discriminator-enum-parent.mjs.map +1 -1
  74. package/dist/api/discriminator-other-owners.cjs +5 -3
  75. package/dist/api/discriminator-other-owners.cjs.map +1 -1
  76. package/dist/api/discriminator-other-owners.mjs +5 -3
  77. package/dist/api/discriminator-other-owners.mjs.map +1 -1
  78. package/dist/api/discriminator-patch.cjs +5 -1
  79. package/dist/api/discriminator-patch.cjs.map +1 -1
  80. package/dist/api/discriminator-patch.mjs +5 -1
  81. package/dist/api/discriminator-patch.mjs.map +1 -1
  82. package/dist/api/discriminator-scan.cjs +15 -8
  83. package/dist/api/discriminator-scan.cjs.map +1 -1
  84. package/dist/api/discriminator-scan.mjs +15 -8
  85. package/dist/api/discriminator-scan.mjs.map +1 -1
  86. package/dist/api/document-run.cjs +2 -2
  87. package/dist/api/document-run.cjs.map +1 -1
  88. package/dist/api/document-run.mjs +2 -2
  89. package/dist/api/document-run.mjs.map +1 -1
  90. package/dist/api/legacy-utils.cjs.map +1 -1
  91. package/dist/api/legacy-utils.mjs.map +1 -1
  92. package/dist/api/openapi-ts.cjs +8 -4
  93. package/dist/api/openapi-ts.cjs.map +1 -1
  94. package/dist/api/openapi-ts.mjs +8 -5
  95. package/dist/api/openapi-ts.mjs.map +1 -1
  96. package/dist/api/schema-callbacks.cjs +36 -12
  97. package/dist/api/schema-callbacks.cjs.map +1 -1
  98. package/dist/api/schema-callbacks.mjs +36 -12
  99. package/dist/api/schema-callbacks.mjs.map +1 -1
  100. package/dist/api/transform-context.cjs +7 -3
  101. package/dist/api/transform-context.cjs.map +1 -1
  102. package/dist/api/transform-context.mjs +7 -3
  103. package/dist/api/transform-context.mjs.map +1 -1
  104. package/dist/api/transform-schema.cjs +40 -10
  105. package/dist/api/transform-schema.cjs.map +1 -1
  106. package/dist/api/transform-schema.mjs +41 -11
  107. package/dist/api/transform-schema.mjs.map +1 -1
  108. package/dist/application/print/text-writer.cjs +10 -3
  109. package/dist/application/print/text-writer.cjs.map +1 -1
  110. package/dist/application/print/text-writer.mjs +10 -3
  111. package/dist/application/print/text-writer.mjs.map +1 -1
  112. package/dist/application/stack-overflow.cjs +2 -1
  113. package/dist/application/stack-overflow.cjs.map +1 -1
  114. package/dist/application/stack-overflow.mjs +2 -1
  115. package/dist/application/stack-overflow.mjs.map +1 -1
  116. package/dist/application/transform/document/components.cjs +1 -1
  117. package/dist/application/transform/document/components.cjs.map +1 -1
  118. package/dist/application/transform/document/components.mjs +2 -2
  119. package/dist/application/transform/document/components.mjs.map +1 -1
  120. package/dist/application/transform/document/declared-type-names.cjs +23 -0
  121. package/dist/application/transform/document/declared-type-names.cjs.map +1 -0
  122. package/dist/application/transform/document/declared-type-names.mjs +20 -0
  123. package/dist/application/transform/document/declared-type-names.mjs.map +1 -0
  124. package/dist/application/transform/document/defs-root.cjs +1 -1
  125. package/dist/application/transform/document/defs-root.cjs.map +1 -1
  126. package/dist/application/transform/document/defs-root.mjs +2 -2
  127. package/dist/application/transform/document/defs-root.mjs.map +1 -1
  128. package/dist/application/transform/document/document.cjs +4 -1
  129. package/dist/application/transform/document/document.cjs.map +1 -1
  130. package/dist/application/transform/document/document.mjs +3 -2
  131. package/dist/application/transform/document/document.mjs.map +1 -1
  132. package/dist/application/transform/document/enum-names-given-back.cjs +62 -0
  133. package/dist/application/transform/document/enum-names-given-back.cjs.map +1 -0
  134. package/dist/application/transform/document/enum-names-given-back.mjs +58 -0
  135. package/dist/application/transform/document/enum-names-given-back.mjs.map +1 -0
  136. package/dist/application/transform/document/global-type-references.cjs +1 -0
  137. package/dist/application/transform/document/global-type-references.cjs.map +1 -1
  138. package/dist/application/transform/document/global-type-references.mjs +1 -1
  139. package/dist/application/transform/document/global-type-references.mjs.map +1 -1
  140. package/dist/application/transform/document/media-type.cjs +2 -2
  141. package/dist/application/transform/document/media-type.cjs.map +1 -1
  142. package/dist/application/transform/document/media-type.mjs +3 -3
  143. package/dist/application/transform/document/media-type.mjs.map +1 -1
  144. package/dist/application/transform/document/operation-keys-written.cjs +26 -0
  145. package/dist/application/transform/document/operation-keys-written.cjs.map +1 -0
  146. package/dist/application/transform/document/operation-keys-written.mjs +24 -0
  147. package/dist/application/transform/document/operation-keys-written.mjs.map +1 -0
  148. package/dist/application/transform/document/operation.cjs +1 -1
  149. package/dist/application/transform/document/operation.cjs.map +1 -1
  150. package/dist/application/transform/document/operation.mjs +2 -2
  151. package/dist/application/transform/document/operation.mjs.map +1 -1
  152. package/dist/application/transform/document/parameter-entries.cjs +34 -0
  153. package/dist/application/transform/document/parameter-entries.cjs.map +1 -0
  154. package/dist/application/transform/document/parameter-entries.mjs +30 -0
  155. package/dist/application/transform/document/parameter-entries.mjs.map +1 -0
  156. package/dist/application/transform/document/parameter.cjs +12 -4
  157. package/dist/application/transform/document/parameter.cjs.map +1 -1
  158. package/dist/application/transform/document/parameter.mjs +13 -5
  159. package/dist/application/transform/document/parameter.mjs.map +1 -1
  160. package/dist/application/transform/document/parameters.cjs +6 -29
  161. package/dist/application/transform/document/parameters.cjs.map +1 -1
  162. package/dist/application/transform/document/parameters.mjs +6 -29
  163. package/dist/application/transform/document/parameters.mjs.map +1 -1
  164. package/dist/application/transform/document/path-item.cjs +11 -14
  165. package/dist/application/transform/document/path-item.cjs.map +1 -1
  166. package/dist/application/transform/document/path-item.mjs +12 -16
  167. package/dist/application/transform/document/path-item.mjs.map +1 -1
  168. package/dist/application/transform/document/paths-enum.cjs +1 -0
  169. package/dist/application/transform/document/paths-enum.cjs.map +1 -1
  170. package/dist/application/transform/document/paths-enum.mjs +1 -1
  171. package/dist/application/transform/document/paths-enum.mjs.map +1 -1
  172. package/dist/application/transform/document/paths.cjs +5 -1
  173. package/dist/application/transform/document/paths.cjs.map +1 -1
  174. package/dist/application/transform/document/paths.mjs +6 -2
  175. package/dist/application/transform/document/paths.mjs.map +1 -1
  176. package/dist/application/transform/document/referenced-parameter.cjs +80 -0
  177. package/dist/application/transform/document/referenced-parameter.cjs.map +1 -0
  178. package/dist/application/transform/document/referenced-parameter.mjs +78 -0
  179. package/dist/application/transform/document/referenced-parameter.mjs.map +1 -0
  180. package/dist/application/transform/document/request-body.cjs +1 -1
  181. package/dist/application/transform/document/request-body.cjs.map +1 -1
  182. package/dist/application/transform/document/request-body.mjs +2 -2
  183. package/dist/application/transform/document/request-body.mjs.map +1 -1
  184. package/dist/application/transform/document/response.cjs +2 -2
  185. package/dist/application/transform/document/response.cjs.map +1 -1
  186. package/dist/application/transform/document/response.mjs +3 -3
  187. package/dist/application/transform/document/response.mjs.map +1 -1
  188. package/dist/application/transform/document/responses.cjs +1 -1
  189. package/dist/application/transform/document/responses.cjs.map +1 -1
  190. package/dist/application/transform/document/responses.mjs +2 -2
  191. package/dist/application/transform/document/responses.mjs.map +1 -1
  192. package/dist/application/transform/document/root-type-aliases.cjs +8 -23
  193. package/dist/application/transform/document/root-type-aliases.cjs.map +1 -1
  194. package/dist/application/transform/document/root-type-aliases.mjs +8 -24
  195. package/dist/application/transform/document/root-type-aliases.mjs.map +1 -1
  196. package/dist/application/transform/document/type-resolution.cjs +3 -1
  197. package/dist/application/transform/document/type-resolution.cjs.map +1 -1
  198. package/dist/application/transform/document/type-resolution.mjs +3 -1
  199. package/dist/application/transform/document/type-resolution.mjs.map +1 -1
  200. package/dist/application/transform/document/webhooks.cjs +1 -1
  201. package/dist/application/transform/document/webhooks.cjs.map +1 -1
  202. package/dist/application/transform/document/webhooks.mjs +2 -2
  203. package/dist/application/transform/document/webhooks.mjs.map +1 -1
  204. package/dist/application/transform/footer/document-footer.cjs +10 -2
  205. package/dist/application/transform/footer/document-footer.cjs.map +1 -1
  206. package/dist/application/transform/footer/document-footer.mjs +10 -2
  207. package/dist/application/transform/footer/document-footer.mjs.map +1 -1
  208. package/dist/application/transform/footer/enum-name-claims.cjs +48 -0
  209. package/dist/application/transform/footer/enum-name-claims.cjs.map +1 -0
  210. package/dist/application/transform/footer/enum-name-claims.mjs +46 -0
  211. package/dist/application/transform/footer/enum-name-claims.mjs.map +1 -0
  212. package/dist/application/transform/footer/operation-keys.cjs +23 -0
  213. package/dist/application/transform/footer/operation-keys.cjs.map +1 -0
  214. package/dist/application/transform/footer/operation-keys.mjs +21 -0
  215. package/dist/application/transform/footer/operation-keys.mjs.map +1 -0
  216. package/dist/application/transform/footer/type-evaluation.cjs +4 -4
  217. package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
  218. package/dist/application/transform/footer/type-evaluation.mjs +4 -4
  219. package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
  220. package/dist/application/transform/helper-types.cjs +1 -1
  221. package/dist/application/transform/helper-types.cjs.map +1 -1
  222. package/dist/application/transform/helper-types.mjs +1 -1
  223. package/dist/application/transform/helper-types.mjs.map +1 -1
  224. package/dist/application/transform/numbered-names.cjs +9 -0
  225. package/dist/application/transform/numbered-names.cjs.map +1 -1
  226. package/dist/application/transform/numbered-names.mjs +9 -1
  227. package/dist/application/transform/numbered-names.mjs.map +1 -1
  228. package/dist/application/transform/ref-pointer/generated-location.cjs +1 -1
  229. package/dist/application/transform/ref-pointer/generated-location.cjs.map +1 -1
  230. package/dist/application/transform/ref-pointer/generated-location.mjs +2 -2
  231. package/dist/application/transform/ref-pointer/generated-location.mjs.map +1 -1
  232. package/dist/application/transform/ref-type.cjs +2 -1
  233. package/dist/application/transform/ref-type.cjs.map +1 -1
  234. package/dist/application/transform/ref-type.mjs +2 -1
  235. package/dist/application/transform/ref-type.mjs.map +1 -1
  236. package/dist/application/transform/schema/composition-type.cjs +1 -1
  237. package/dist/application/transform/schema/composition-type.cjs.map +1 -1
  238. package/dist/application/transform/schema/composition-type.mjs +2 -2
  239. package/dist/application/transform/schema/composition-type.mjs.map +1 -1
  240. package/dist/application/transform/schema/enum-rule.cjs +1 -1
  241. package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
  242. package/dist/application/transform/schema/enum-rule.mjs +2 -2
  243. package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
  244. package/dist/application/transform/schema/object-type.cjs +3 -3
  245. package/dist/application/transform/schema/object-type.cjs.map +1 -1
  246. package/dist/application/transform/schema/object-type.mjs +4 -4
  247. package/dist/application/transform/schema/object-type.mjs.map +1 -1
  248. package/dist/application/transform/schema/ref-siblings.cjs +47 -0
  249. package/dist/application/transform/schema/ref-siblings.cjs.map +1 -0
  250. package/dist/application/transform/schema/ref-siblings.mjs +45 -0
  251. package/dist/application/transform/schema/ref-siblings.mjs.map +1 -0
  252. package/dist/application/transform/schema/schema-transform.cjs +4 -2
  253. package/dist/application/transform/schema/schema-transform.cjs.map +1 -1
  254. package/dist/application/transform/schema/schema-transform.mjs +4 -2
  255. package/dist/application/transform/schema/schema-transform.mjs.map +1 -1
  256. package/dist/application/transform/schema-comment.cjs +5 -1
  257. package/dist/application/transform/schema-comment.cjs.map +1 -1
  258. package/dist/application/transform/schema-comment.mjs +5 -1
  259. package/dist/application/transform/schema-comment.mjs.map +1 -1
  260. package/dist/cli/api-settings.cjs +62 -6
  261. package/dist/cli/api-settings.cjs.map +1 -1
  262. package/dist/cli/api-settings.mjs +60 -7
  263. package/dist/cli/api-settings.mjs.map +1 -1
  264. package/dist/cli/api-writes.cjs +72 -0
  265. package/dist/cli/api-writes.cjs.map +1 -0
  266. package/dist/cli/api-writes.mjs +69 -0
  267. package/dist/cli/api-writes.mjs.map +1 -0
  268. package/dist/cli/cli-errors.cjs +12 -1
  269. package/dist/cli/cli-errors.cjs.map +1 -1
  270. package/dist/cli/cli-errors.mjs +12 -1
  271. package/dist/cli/cli-errors.mjs.map +1 -1
  272. package/dist/cli/cli-output.cjs +106 -1
  273. package/dist/cli/cli-output.cjs.map +1 -1
  274. package/dist/cli/cli-output.mjs +99 -2
  275. package/dist/cli/cli-output.mjs.map +1 -1
  276. package/dist/cli/main.cjs +5 -1
  277. package/dist/cli/main.cjs.map +1 -1
  278. package/dist/cli/main.mjs +6 -2
  279. package/dist/cli/main.mjs.map +1 -1
  280. package/dist/cli/redocly-apis.cjs +82 -36
  281. package/dist/cli/redocly-apis.cjs.map +1 -1
  282. package/dist/cli/redocly-apis.mjs +85 -39
  283. package/dist/cli/redocly-apis.mjs.map +1 -1
  284. package/dist/cli/run-cli.cjs +13 -7
  285. package/dist/cli/run-cli.cjs.map +1 -1
  286. package/dist/cli/run-cli.mjs +14 -8
  287. package/dist/cli/run-cli.mjs.map +1 -1
  288. package/dist/domain/append-all.cjs +10 -0
  289. package/dist/domain/append-all.cjs.map +1 -0
  290. package/dist/domain/append-all.mjs +8 -0
  291. package/dist/domain/append-all.mjs.map +1 -0
  292. package/dist/domain/cause-secrets.cjs +37 -0
  293. package/dist/domain/cause-secrets.cjs.map +1 -0
  294. package/dist/domain/cause-secrets.mjs +35 -0
  295. package/dist/domain/cause-secrets.mjs.map +1 -0
  296. package/dist/domain/errors.cjs +9 -3
  297. package/dist/domain/errors.cjs.map +1 -1
  298. package/dist/domain/errors.mjs +9 -3
  299. package/dist/domain/errors.mjs.map +1 -1
  300. package/dist/domain/ir/identifier-text.cjs.map +1 -1
  301. package/dist/domain/ir/identifier-text.mjs +1 -1
  302. package/dist/domain/ir/identifier-text.mjs.map +1 -1
  303. package/dist/domain/ir/ir-shape.cjs +187 -0
  304. package/dist/domain/ir/ir-shape.cjs.map +1 -0
  305. package/dist/domain/ir/ir-shape.mjs +184 -0
  306. package/dist/domain/ir/ir-shape.mjs.map +1 -0
  307. package/dist/domain/ir/newer-identifier-ranges.cjs +182 -29
  308. package/dist/domain/ir/newer-identifier-ranges.cjs.map +1 -1
  309. package/dist/domain/ir/newer-identifier-ranges.mjs +182 -29
  310. package/dist/domain/ir/newer-identifier-ranges.mjs.map +1 -1
  311. package/dist/domain/openapi/alias-expansion.cjs +3 -1
  312. package/dist/domain/openapi/alias-expansion.cjs.map +1 -1
  313. package/dist/domain/openapi/alias-expansion.mjs +3 -1
  314. package/dist/domain/openapi/alias-expansion.mjs.map +1 -1
  315. package/dist/domain/openapi/discriminated-union.cjs +3 -3
  316. package/dist/domain/openapi/discriminated-union.cjs.map +1 -1
  317. package/dist/domain/openapi/discriminated-union.mjs +4 -4
  318. package/dist/domain/openapi/discriminated-union.mjs.map +1 -1
  319. package/dist/domain/openapi/discriminator-conflicts.cjs +10 -6
  320. package/dist/domain/openapi/discriminator-conflicts.cjs.map +1 -1
  321. package/dist/domain/openapi/discriminator-conflicts.mjs +11 -7
  322. package/dist/domain/openapi/discriminator-conflicts.mjs.map +1 -1
  323. package/dist/domain/openapi/json-pointer.cjs +43 -1
  324. package/dist/domain/openapi/json-pointer.cjs.map +1 -1
  325. package/dist/domain/openapi/json-pointer.mjs +40 -2
  326. package/dist/domain/openapi/json-pointer.mjs.map +1 -1
  327. package/dist/domain/openapi/schema-dialect.cjs +15 -0
  328. package/dist/domain/openapi/schema-dialect.cjs.map +1 -0
  329. package/dist/domain/openapi/schema-dialect.mjs +12 -0
  330. package/dist/domain/openapi/schema-dialect.mjs.map +1 -0
  331. package/dist/domain/openapi/unsupported-features.cjs +1 -1
  332. package/dist/domain/openapi/unsupported-features.cjs.map +1 -1
  333. package/dist/domain/openapi/unsupported-features.mjs +2 -2
  334. package/dist/domain/openapi/unsupported-features.mjs.map +1 -1
  335. package/dist/domain/output-fixes.cjs +14 -0
  336. package/dist/domain/output-fixes.cjs.map +1 -1
  337. package/dist/domain/output-fixes.mjs +14 -0
  338. package/dist/domain/output-fixes.mjs.map +1 -1
  339. package/dist/domain/url-secrets.cjs +48 -0
  340. package/dist/domain/url-secrets.cjs.map +1 -0
  341. package/dist/domain/url-secrets.mjs +45 -0
  342. package/dist/domain/url-secrets.mjs.map +1 -0
  343. package/dist/index.d.cts +22 -4
  344. package/dist/index.d.mts +22 -4
  345. package/dist/index.d.ts +22 -4
  346. package/package.json +4 -5
  347. package/src/adapters/node-file-system/file-claims.ts +138 -0
  348. package/src/adapters/node-file-system/file-identity.ts +137 -0
  349. package/src/adapters/node-file-system/node-file-system.ts +145 -18
  350. package/src/adapters/redocly-loader/bundled-mapping-copies.ts +95 -0
  351. package/src/adapters/redocly-loader/bundled-ref-repair.ts +2 -2
  352. package/src/adapters/redocly-loader/loaded-documents.ts +46 -0
  353. package/src/adapters/redocly-loader/redocly-schema-loader.ts +18 -24
  354. package/src/adapters/redocly-loader/ref-access.ts +37 -3
  355. package/src/adapters/redocly-loader/ref-holders.ts +3 -3
  356. package/src/adapters/redocly-loader/remote-body-limit.ts +66 -0
  357. package/src/adapters/redocly-loader/remote-fetch.ts +74 -11
  358. package/src/adapters/redocly-loader/remote-node-limit.ts +62 -0
  359. package/src/adapters/redocly-loader/schema-load-errors.ts +52 -13
  360. package/src/adapters/redocly-loader/schema-source.ts +20 -8
  361. package/src/adapters/redocly-loader/unsupported-keys.ts +3 -7
  362. package/src/adapters/terminal-logger/terminal-logger.ts +10 -5
  363. package/src/api/default-ports.ts +33 -4
  364. package/src/api/discriminator-enum-parent.ts +3 -3
  365. package/src/api/discriminator-other-owners.ts +5 -3
  366. package/src/api/discriminator-patch.ts +5 -1
  367. package/src/api/discriminator-scan.ts +16 -8
  368. package/src/api/document-run.ts +4 -3
  369. package/src/api/legacy-utils.ts +5 -1
  370. package/src/api/openapi-ts.ts +20 -5
  371. package/src/api/run-context.ts +3 -0
  372. package/src/api/schema-callbacks.ts +60 -17
  373. package/src/api/transform-context.ts +7 -3
  374. package/src/api/transform-schema.ts +64 -12
  375. package/src/application/ports/file-system.ts +39 -0
  376. package/src/application/ports/schema-loader.ts +11 -1
  377. package/src/application/print/text-writer.ts +10 -3
  378. package/src/application/stack-overflow.ts +9 -5
  379. package/src/application/transform/document/components.ts +2 -2
  380. package/src/application/transform/document/declared-type-names.ts +36 -0
  381. package/src/application/transform/document/defs-root.ts +2 -2
  382. package/src/application/transform/document/document.ts +4 -3
  383. package/src/application/transform/document/enum-names-given-back.ts +91 -0
  384. package/src/application/transform/document/global-type-references.ts +1 -1
  385. package/src/application/transform/document/media-type.ts +4 -3
  386. package/src/application/transform/document/operation-keys-written.ts +27 -0
  387. package/src/application/transform/document/operation.ts +2 -2
  388. package/src/application/transform/document/parameter-entries.ts +70 -0
  389. package/src/application/transform/document/parameter.ts +21 -9
  390. package/src/application/transform/document/parameters.ts +11 -56
  391. package/src/application/transform/document/path-item.ts +13 -31
  392. package/src/application/transform/document/paths-enum.ts +1 -1
  393. package/src/application/transform/document/paths.ts +6 -2
  394. package/src/application/transform/document/referenced-parameter.ts +146 -0
  395. package/src/application/transform/document/request-body.ts +2 -2
  396. package/src/application/transform/document/response.ts +3 -3
  397. package/src/application/transform/document/responses.ts +2 -2
  398. package/src/application/transform/document/root-type-aliases.ts +17 -38
  399. package/src/application/transform/document/type-resolution.ts +2 -1
  400. package/src/application/transform/document/webhooks.ts +2 -2
  401. package/src/application/transform/footer/document-footer.ts +18 -1
  402. package/src/application/transform/footer/enum-name-claims.ts +62 -0
  403. package/src/application/transform/footer/operation-keys.ts +28 -0
  404. package/src/application/transform/footer/type-evaluation.ts +4 -4
  405. package/src/application/transform/helper-types.ts +6 -5
  406. package/src/application/transform/numbered-names.ts +15 -0
  407. package/src/application/transform/ref-pointer/generated-location.ts +2 -2
  408. package/src/application/transform/ref-type.ts +2 -1
  409. package/src/application/transform/schema/composition-type.ts +2 -2
  410. package/src/application/transform/schema/enum-rule.ts +6 -2
  411. package/src/application/transform/schema/object-type.ts +4 -4
  412. package/src/application/transform/schema/ref-siblings.ts +76 -0
  413. package/src/application/transform/schema/schema-context.ts +3 -0
  414. package/src/application/transform/schema/schema-transform.ts +4 -2
  415. package/src/application/transform/schema-comment.ts +5 -1
  416. package/src/application/transform/transform-context.ts +5 -0
  417. package/src/cli/api-settings.ts +82 -7
  418. package/src/cli/api-writes.ts +117 -0
  419. package/src/cli/cli-dependencies.ts +21 -4
  420. package/src/cli/cli-errors.ts +20 -1
  421. package/src/cli/cli-output.ts +186 -7
  422. package/src/cli/main.ts +6 -3
  423. package/src/cli/redocly-apis.ts +153 -48
  424. package/src/cli/run-cli.ts +37 -8
  425. package/src/domain/append-all.ts +10 -0
  426. package/src/domain/cause-secrets.ts +52 -0
  427. package/src/domain/errors.ts +14 -5
  428. package/src/domain/ir/identifier-text.ts +6 -5
  429. package/src/domain/ir/ir-shape.ts +299 -0
  430. package/src/domain/ir/newer-identifier-ranges.ts +183 -30
  431. package/src/domain/openapi/alias-expansion.ts +4 -1
  432. package/src/domain/openapi/discriminated-union.ts +6 -4
  433. package/src/domain/openapi/discriminator-conflicts.ts +21 -7
  434. package/src/domain/openapi/document-object.ts +2 -0
  435. package/src/domain/openapi/json-pointer.ts +96 -7
  436. package/src/domain/openapi/schema-dialect.ts +22 -0
  437. package/src/domain/openapi/unsupported-features.ts +2 -2
  438. package/src/domain/output-fixes.ts +21 -2
  439. package/src/domain/url-secrets.ts +72 -0
  440. package/src/types/generator-options.ts +1 -1
  441. package/dist/cli/main.d.cts +0 -2
  442. package/dist/cli/main.d.mts +0 -2
  443. package/dist/cli/main.d.ts +0 -2
  444. package/dist/domain/url-credentials.cjs +0 -10
  445. package/dist/domain/url-credentials.cjs.map +0 -1
  446. package/dist/domain/url-credentials.mjs +0 -8
  447. package/dist/domain/url-credentials.mjs.map +0 -1
  448. package/src/domain/url-credentials.ts +0 -18
@@ -1,19 +1,22 @@
1
1
  import { irKeyword } from "../../../domain/ir/constructors.js";
2
2
  import type { IrType } from "../../../domain/ir/nodes.js";
3
- import { createRef } from "../../../domain/openapi/json-pointer.js";
3
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
4
4
  import {
5
5
  type ParameterObject,
6
6
  QUERYSTRING_LOCATION,
7
7
  } from "../../../domain/openapi/parameter-object.js";
8
+ import { FIX } from "../../../domain/output-fixes.js";
8
9
  import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
9
10
  import { transformSchema } from "../schema/schema-transform.js";
10
11
  import { contentEntryType } from "./media-type.js";
11
12
 
12
13
  /**
13
- * An `in: querystring` parameter (OpenAPI 3.2): the whole query string, typed by the schema of its
14
- * one `content` media type (ADR-020). Without one it is `string`, the query string as text.
14
+ * A parameter typed by the schema of its one `content` media type. An `in: querystring` parameter
15
+ * (OpenAPI 3.2) is the whole query string (ADR-020); without a media type it is `string`, the
16
+ * query string as text. With the `parameter-content` fix, any other parameter with `content`
17
+ * (OpenAPI 3.0 and later, for a JSON value in a query parameter) is typed the same way.
15
18
  */
16
- function querystringType(
19
+ function contentParameterType(
17
20
  parameter: ParameterObject,
18
21
  location: SchemaLocation,
19
22
  context: SchemaContext,
@@ -22,22 +25,31 @@ function querystringType(
22
25
  if (mediaType === undefined || entry === undefined) {
23
26
  return irKeyword("string");
24
27
  }
25
- const path = createRef([location.path, "content", mediaType]);
28
+ const path = appendPointer(location.path, ["content", mediaType]);
26
29
  return contentEntryType(entry, { ...location, path }, context);
27
30
  }
28
31
 
32
+ function isTypedByContent(parameter: ParameterObject, context: SchemaContext): boolean {
33
+ if (parameter.in === QUERYSTRING_LOCATION) {
34
+ return true;
35
+ }
36
+ const hasContent = parameter.schema === undefined && parameter.content !== undefined;
37
+ return hasContent && context.options.fixes.has(FIX.PARAMETER_CONTENT);
38
+ }
39
+
29
40
  /**
30
41
  * A parameter's type (OpenAPI 3.2 §4.8.12). Without a schema it is `string`, not `unknown`:
31
- * query, path, header and cookie values all arrive as text. `content` is read only for
32
- * `in: querystring`; other parameters with `content` keep their pre-3.2 type.
42
+ * query, path, header and cookie values all arrive as text. `content` is read for
43
+ * `in: querystring`, and with the `parameter-content` fix for every parameter; without the fix
44
+ * other parameters with `content` keep the original's `string`.
33
45
  */
34
46
  export function parameterType(
35
47
  parameter: ParameterObject,
36
48
  location: SchemaLocation,
37
49
  context: SchemaContext,
38
50
  ): IrType {
39
- if (parameter.in === QUERYSTRING_LOCATION) {
40
- return querystringType(parameter, location, context);
51
+ if (isTypedByContent(parameter, context)) {
52
+ return contentParameterType(parameter, location, context);
41
53
  }
42
54
  return parameter.schema
43
55
  ? transformSchema(parameter.schema, location, context)
@@ -7,7 +7,7 @@ import {
7
7
  } from "../../../domain/ir/constructors.js";
8
8
  import type { IrPropertyName, IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
9
9
  import { toPropertyName } from "../../../domain/ir/property-name.js";
10
- import { createRef } from "../../../domain/openapi/json-pointer.js";
10
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
11
11
  import {
12
12
  PARAMETER_LOCATIONS,
13
13
  type ParameterLocation,
@@ -15,36 +15,23 @@ import {
15
15
  type ParameterOrReference,
16
16
  QUERYSTRING_LOCATION,
17
17
  } from "../../../domain/openapi/parameter-object.js";
18
- import type { SchemaObject } from "../../../domain/openapi/schema-object.js";
19
18
  import { FIX } from "../../../domain/output-fixes.js";
20
- import { refType } from "../ref-type.js";
21
19
  import type { SchemaLocation } from "../schema/schema-context.js";
22
20
  import { withSchemaComment } from "../schema-comment.js";
23
21
  import type { TransformContext } from "../transform-context.js";
24
22
  import { isExplodedQueryObject } from "./exploded-query.js";
25
23
  import { parameterType } from "./parameter.js";
24
+ import {
25
+ type ParameterEntry,
26
+ parameterEntries,
27
+ type ResolvedEntry,
28
+ resolveParameter,
29
+ } from "./parameter-entries.js";
30
+ import { referencedParameterType } from "./referenced-parameter.js";
26
31
 
27
32
  /** `[^{}]` keeps the scan linear: `[^}]` retried from every `{` of a long run of them. */
28
33
  const PATH_TEMPLATE_RE = /\{([^{}]+)\}/g;
29
34
 
30
- /** A parameter as written in the document, and the object its `$ref` points to. */
31
- interface ParameterEntry {
32
- readonly original: ParameterOrReference;
33
- readonly resolved: ParameterObject | undefined;
34
- }
35
-
36
- /** An entry whose `$ref` resolved, so its location and name are known. */
37
- type ResolvedEntry = ParameterEntry & { readonly resolved: ParameterObject };
38
-
39
- function resolveParameter(
40
- parameter: ParameterOrReference,
41
- context: TransformContext,
42
- ): ParameterObject | undefined {
43
- return "$ref" in parameter
44
- ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)
45
- : parameter;
46
- }
47
-
48
35
  /** Required string parameters for every `{name}` in a path template. */
49
36
  function pathTemplateParameters(path: string): ParameterObject[] {
50
37
  return (path.match(PATH_TEMPLATE_RE) ?? []).map((match) => ({
@@ -67,7 +54,7 @@ function withPathTemplateParameters(
67
54
  }
68
55
  for (const parameter of pathTemplateParameters(location.path)) {
69
56
  const isDefined = result.some((candidate) => {
70
- const resolved = resolveParameter(candidate, context);
57
+ const resolved = resolveParameter(candidate, context.refs);
71
58
  return resolved?.in === "path" && resolved.name === parameter.name;
72
59
  });
73
60
  if (!isDefined) {
@@ -77,31 +64,6 @@ function withPathTemplateParameters(
77
64
  return result;
78
65
  }
79
66
 
80
- function isDeprecatedParameter(parameter: ParameterObject | undefined): boolean {
81
- const schema = parameter?.schema as SchemaObject | undefined;
82
- return Boolean(parameter?.deprecated || schema?.deprecated);
83
- }
84
-
85
- /** Resolved parameters, sorted for `--alphabetize`, without deprecated ones if excluded. */
86
- function parameterEntries(
87
- parameters: readonly ParameterOrReference[],
88
- context: TransformContext,
89
- ): ParameterEntry[] {
90
- const entries = parameters.map((original) => ({
91
- original,
92
- resolved: resolveParameter(original, context),
93
- }));
94
- if (context.options.alphabetize) {
95
- // Unlike map keys, the original sorts parameters with the default locale's `localeCompare`.
96
- entries.sort((left, right) =>
97
- (left.resolved?.name ?? "").localeCompare(right.resolved?.name ?? ""),
98
- );
99
- }
100
- return context.options.excludeDeprecated
101
- ? entries.filter(({ resolved }) => !isDeprecatedParameter(resolved))
102
- : entries;
103
- }
104
-
105
67
  /** The original quotes a name that is not text (a missing name prints as `"undefined"`). */
106
68
  function parameterName(name: unknown): IrPropertyName {
107
69
  return typeof name === "string" || typeof name === "number"
@@ -109,21 +71,14 @@ function parameterName(name: unknown): IrPropertyName {
109
71
  : { kind: "string", value: String(name) };
110
72
  }
111
73
 
112
- function referencedParameterType(ref: string, resolved: ParameterObject): IrType {
113
- // A `$ref` that resolves to another `$ref` is not a parameter object yet: index it as a path.
114
- const isParameter = !(resolved as { $ref?: unknown }).$ref;
115
- const parameter = isParameter ? { in: resolved.in, name: resolved.name } : null;
116
- return refType(ref, { parameter });
117
- }
118
-
119
74
  function entryType(
120
75
  { original, resolved }: ResolvedEntry,
121
76
  location: SchemaLocation,
122
77
  context: TransformContext,
123
78
  ): IrType {
124
- const path = createRef([location.path, "parameters", resolved.in, resolved.name]);
79
+ const path = appendPointer(location.path, ["parameters", resolved.in, resolved.name]);
125
80
  return "$ref" in original
126
- ? referencedParameterType(original.$ref, resolved)
81
+ ? referencedParameterType(original.$ref, resolved, context)
127
82
  : parameterType(resolved, { ...location, path }, context);
128
83
  }
129
84
 
@@ -1,12 +1,8 @@
1
1
  import { irKeyword, irObject, irProperty } from "../../../domain/ir/constructors.js";
2
2
  import type { IrMember, IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
3
3
  import { toPropertyName } from "../../../domain/ir/property-name.js";
4
- import { createRef } from "../../../domain/openapi/json-pointer.js";
4
+ import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
5
5
  import type { OperationObject } from "../../../domain/openapi/operation-object.js";
6
- import type {
7
- ParameterObject,
8
- ParameterOrReference,
9
- } from "../../../domain/openapi/parameter-object.js";
10
6
  import {
11
7
  ADDITIONAL_OPERATIONS_KEY,
12
8
  HTTP_METHODS,
@@ -21,11 +17,17 @@ import type { SchemaLocation } from "../schema/schema-context.js";
21
17
  import type { TransformContext } from "../transform-context.js";
22
18
  import { documentMember } from "./document-member.js";
23
19
  import { operationMembers } from "./operation.js";
20
+ import { mergedParameters } from "./parameter-entries.js";
24
21
  import { parametersMember } from "./parameters.js";
25
22
 
26
23
  /** Redocly reads `#` in an operation ID as a pointer, so it is replaced (upstream issue #1542). */
27
24
  const HASH_RE = /#/g;
28
25
 
26
+ /** The `operations` key an `operationId` asks for, before a repeated one gets a number. */
27
+ export function operationKeyOf(operationId: string): string {
28
+ return operationId.replace(HASH_RE, "/");
29
+ }
30
+
29
31
  /** Whether the method has an operation, not removed by `--exclude-deprecated`. */
30
32
  function isIncluded(
31
33
  operation: OperationEntry | undefined,
@@ -41,26 +43,6 @@ function isIncluded(
41
43
  return !(context.options.excludeDeprecated && resolved?.deprecated);
42
44
  }
43
45
 
44
- /**
45
- * Path item parameters followed by the operation's, keyed by location and name, so an operation
46
- * parameter replaces the path item parameter it redefines (upstream issue #1798).
47
- */
48
- function mergedParameters(
49
- pathItem: PathItemObject,
50
- operation: OperationObject,
51
- context: TransformContext,
52
- ): ParameterOrReference[] {
53
- const byKey = new Map<string, ParameterOrReference>();
54
- for (const parameter of [...(pathItem.parameters ?? []), ...(operation.parameters ?? [])]) {
55
- const resolved =
56
- "$ref" in parameter
57
- ? (context.refs.resolve(parameter.$ref) as ParameterObject | undefined)
58
- : parameter;
59
- byKey.set(`${resolved?.in}-${resolved?.name}`, parameter);
60
- }
61
- return [...byKey.values()];
62
- }
63
-
64
46
  /**
65
47
  * An operation with an `operationId` goes into the `operations` interface and is referenced from
66
48
  * the path item; others are written inline.
@@ -71,17 +53,17 @@ function operationType(
71
53
  location: SchemaLocation,
72
54
  context: TransformContext,
73
55
  ): IrType {
74
- const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context) };
56
+ const merged = { ...operation, parameters: mergedParameters(pathItem, operation, context.refs) };
75
57
  if (!operation.operationId) {
76
58
  return irObject(operationMembers(merged, location, context));
77
59
  }
78
- const operationId = operation.operationId.replace(HASH_RE, "/");
60
+ const operationId = context.footer.operationKey(operationKeyOf(operation.operationId));
79
61
  context.footer.addOperation(() =>
80
62
  irProperty(toPropertyName(operationId), irObject(operationMembers(merged, location, context)), {
81
63
  isReadonly: context.options.immutable,
82
64
  }),
83
65
  );
84
- return refType(createRef(["operations", operationId]));
66
+ return refType(appendPointer(ROOT_POINTER, ["operations", operationId]));
85
67
  }
86
68
 
87
69
  /** An included operation, the member name it gets and its location below the path item. */
@@ -116,7 +98,7 @@ function methodMember(
116
98
  const isReadonly = context.options.immutable;
117
99
  return irProperty(toPropertyName(method), irKeyword("never"), { isOptional: true, isReadonly });
118
100
  }
119
- const path = createRef([location.path, method]);
101
+ const path = appendPointer(location.path, [method]);
120
102
  return operationMember({ name: method, operation, path }, pathItem, location, context);
121
103
  }
122
104
 
@@ -133,7 +115,7 @@ function additionalOperationsMember(
133
115
  const members = entries
134
116
  .filter(([, operation]) => isIncluded(operation, context))
135
117
  .map(([method, operation]) => {
136
- const path = createRef([location.path, ADDITIONAL_OPERATIONS_KEY, method]);
118
+ const path = appendPointer(location.path, [ADDITIONAL_OPERATIONS_KEY, method]);
137
119
  return operationMember({ name: method, operation, path }, pathItem, location, context);
138
120
  });
139
121
  return members.length > 0
@@ -152,7 +134,7 @@ export function pathItemType(
152
134
  location: SchemaLocation,
153
135
  context: TransformContext,
154
136
  ): IrType {
155
- const parametersLocation = { ...location, path: createRef([location.path, "parameters"]) };
137
+ const parametersLocation = { ...location, path: appendPointer(location.path, ["parameters"]) };
156
138
  const members: IrMember[] = [
157
139
  parametersMember(pathItem.parameters ?? [], parametersLocation, context),
158
140
  ...HTTP_METHODS.map((method) => methodMember(method, pathItem, location, context)),
@@ -15,7 +15,7 @@ import type { EnumMemberMetadata } from "../schema/schema-context.js";
15
15
  const PARAMETER_SEGMENT_RE = /^(?:{(.+)}|:(.+))$/;
16
16
  /** Characters not allowed in an enum key, or a `{param}` / `:param` part (first match only). */
17
17
  const INVALID_KEY_PART_RE = /{.*}|:.*|[^a-zA-Z\d_]+/;
18
- const API_PATHS_NAME = "ApiPaths";
18
+ export const API_PATHS_NAME = "ApiPaths";
19
19
  const METHODS: ReadonlySet<string> = new Set<PathItemMethod>([...HTTP_METHODS, QUERY_METHOD]);
20
20
 
21
21
  /** The members of the `ApiPaths` enum (`--make-paths-enum`). */
@@ -2,7 +2,7 @@ import { irIntersection, irObject, irProperty, irRaw } from "../../../domain/ir/
2
2
  import type { IrMember, IrType } from "../../../domain/ir/nodes.js";
3
3
  import { toPropertyName } from "../../../domain/ir/property-name.js";
4
4
  import { escapeTemplateText } from "../../../domain/ir/raw-text-escapes.js";
5
- import { createRef } from "../../../domain/openapi/json-pointer.js";
5
+ import { appendPointer, ROOT_POINTER } from "../../../domain/openapi/json-pointer.js";
6
6
  import type { OperationObject } from "../../../domain/openapi/operation-object.js";
7
7
  import type {
8
8
  ParameterObject,
@@ -145,7 +145,11 @@ function pathItemMember(
145
145
  context: TransformContext,
146
146
  ): PathMember {
147
147
  const isReadonly = context.options.immutable;
148
- const type = pathItemType(pathItem, { path: createRef(["paths", url]) }, context);
148
+ const type = pathItemType(
149
+ pathItem,
150
+ { path: appendPointer(ROOT_POINTER, ["paths", url]) },
151
+ context,
152
+ );
149
153
  const parts =
150
154
  context.options.pathParamsAsTypes && url.includes("{")
151
155
  ? pathTemplateParts(url, pathItem, context)
@@ -0,0 +1,146 @@
1
+ import { irReference } from "../../../domain/ir/constructors.js";
2
+ import type { IrType } from "../../../domain/ir/nodes.js";
3
+ import {
4
+ appendPointer,
5
+ parseRefPointer,
6
+ ROOT_POINTER,
7
+ } from "../../../domain/openapi/json-pointer.js";
8
+ import type { OperationObject } from "../../../domain/openapi/operation-object.js";
9
+ import {
10
+ type ParameterObject,
11
+ type ParameterOrReference,
12
+ QUERYSTRING_LOCATION,
13
+ } from "../../../domain/openapi/parameter-object.js";
14
+ import {
15
+ ADDITIONAL_OPERATIONS_KEY,
16
+ HTTP_METHODS,
17
+ type PathItemObject,
18
+ QUERY_METHOD,
19
+ } from "../../../domain/openapi/path-item-object.js";
20
+ import { indexBy, refType } from "../ref-type.js";
21
+ import type { RefResolver } from "../schema/schema-context.js";
22
+ import type { TransformContext } from "../transform-context.js";
23
+ import { mergedParameters, type ParameterEntry, parameterEntries } from "./parameter-entries.js";
24
+
25
+ /**
26
+ * The type of a parameter `$ref`. The original indexed the parameter's location and name
27
+ * (`refType`): `#/paths/~1a/get/parameters/0` gave
28
+ * `paths["/a"]["get"]["parameters"]["query"]["q"]`.
29
+ * Where the generated type differs, that does not compile, and only there it changes:
30
+ *
31
+ * - A location whose parameters are all optional is an optional member (`query?:`), so indexing it
32
+ * fails (TS2339); it is wrapped in `NonNullable` before the name is indexed.
33
+ * - An OpenAPI 3.2 `in: querystring` parameter is the whole `query` member (ADR-020), not a member
34
+ * `querystring`, so the pointer reads `["query"]`.
35
+ *
36
+ * A `$ref` to a component parameter, or into a list the generator types elsewhere (a `$ref` path
37
+ * item or operation, a callback), keeps the original type.
38
+ */
39
+
40
+ const INDEX_RE = /^\d+$/;
41
+ const OPERATION_KEYS: ReadonlySet<string> = new Set([...HTTP_METHODS, QUERY_METHOD]);
42
+
43
+ /** A `parameters/N` pointer, split into its root and the segments of the list's owner. */
44
+ interface ParameterListPointer {
45
+ readonly root: string;
46
+ readonly owner: readonly string[];
47
+ }
48
+
49
+ function listPointerOf(ref: string): ParameterListPointer | null {
50
+ if (!ref.startsWith(`${ROOT_POINTER}/`)) {
51
+ return null;
52
+ }
53
+ const [root, ...segments] = parseRefPointer(ref);
54
+ const [list, position] = segments.slice(-2);
55
+ const isList = list === "parameters" && position !== undefined && INDEX_RE.test(position);
56
+ return root !== undefined && isList ? { root, owner: segments.slice(0, -2) } : null;
57
+ }
58
+
59
+ function pointerTo(root: string, segments: readonly string[]): string {
60
+ return appendPointer(ROOT_POINTER, [root, ...segments]);
61
+ }
62
+
63
+ /** Whether the segments name a path item that `pathItemType` types in place. */
64
+ function isPathItemAt(root: string, segments: readonly string[]): boolean {
65
+ const isNamedRoot = root === "paths" || root === "webhooks";
66
+ return (
67
+ (isNamedRoot && segments.length === 1) ||
68
+ (root === "components" && segments[0] === "pathItems" && segments.length === 2)
69
+ );
70
+ }
71
+
72
+ /** The segments of the path item that holds the operation at `owner`, or null. */
73
+ function pathItemOfOperation(root: string, owner: readonly string[]): readonly string[] | null {
74
+ const method = owner.at(-1) ?? "";
75
+ if (OPERATION_KEYS.has(method) && isPathItemAt(root, owner.slice(0, -1))) {
76
+ return owner.slice(0, -1);
77
+ }
78
+ const isAdditional = owner.at(-2) === ADDITIONAL_OPERATIONS_KEY;
79
+ return isAdditional && isPathItemAt(root, owner.slice(0, -2)) ? owner.slice(0, -2) : null;
80
+ }
81
+
82
+ function documentNode<T>(refs: RefResolver, root: string, segments: readonly string[]): T | null {
83
+ const node = refs.resolve(pointerTo(root, segments));
84
+ const isTypedHere = typeof node === "object" && node !== null && !("$ref" in node);
85
+ return isTypedHere ? (node as T) : null;
86
+ }
87
+
88
+ /** The parameters the generator types at the list's owner; null where it types them elsewhere. */
89
+ function typedParameters(
90
+ pointer: ParameterListPointer,
91
+ refs: RefResolver,
92
+ ): readonly ParameterOrReference[] | null {
93
+ const { root, owner } = pointer;
94
+ if (isPathItemAt(root, owner)) {
95
+ return documentNode<PathItemObject>(refs, root, owner)?.parameters ?? null;
96
+ }
97
+ const pathItemSegments = pathItemOfOperation(root, owner);
98
+ const pathItem = pathItemSegments && documentNode<PathItemObject>(refs, root, pathItemSegments);
99
+ const operation = pathItem && documentNode<OperationObject>(refs, root, owner);
100
+ return pathItem && operation ? mergedParameters(pathItem, operation, refs) : null;
101
+ }
102
+
103
+ /** A location member is optional when none of its parameters is required (`locationParts`). */
104
+ function isLocationOptional(entries: readonly ParameterEntry[], location: string): boolean {
105
+ return entries
106
+ .filter((entry) => entry.resolved?.in === location)
107
+ .every((entry) => location !== "path" && !entry.resolved?.required);
108
+ }
109
+
110
+ /** The corrected type, or null where the original type compiles or no correction applies. */
111
+ function correctedType(
112
+ listType: IrType,
113
+ entries: readonly ParameterEntry[],
114
+ parameter: ParameterObject,
115
+ ): IrType | null {
116
+ if (parameter.in === QUERYSTRING_LOCATION) {
117
+ // Next to `in: query` parameters it is not in the generated types (QUERYSTRING_NEXT_TO_QUERY).
118
+ const isTyped = !entries.some((entry) => entry.resolved?.in === "query");
119
+ return isTyped ? indexBy(listType, "query") : null;
120
+ }
121
+ if (!isLocationOptional(entries, parameter.in)) {
122
+ return null;
123
+ }
124
+ const location = irReference("NonNullable", [indexBy(listType, parameter.in)]);
125
+ return indexBy(location, parameter.name);
126
+ }
127
+
128
+ /** The type of a parameter `$ref` whose target resolved to `resolved`; see the module comment. */
129
+ export function referencedParameterType(
130
+ ref: string,
131
+ resolved: ParameterObject,
132
+ context: TransformContext,
133
+ ): IrType {
134
+ // A `$ref` that resolves to another `$ref` is not a parameter object yet: index it as a path.
135
+ if ((resolved as { $ref?: unknown }).$ref) {
136
+ return refType(ref, { parameter: null });
137
+ }
138
+ const original = refType(ref, { parameter: { in: resolved.in, name: resolved.name } });
139
+ const pointer = listPointerOf(ref);
140
+ const parameters = pointer && typedParameters(pointer, context.refs);
141
+ if (pointer === null || parameters === null) {
142
+ return original;
143
+ }
144
+ const listType = refType(pointerTo(pointer.root, [...pointer.owner, "parameters"]));
145
+ return correctedType(listType, parameterEntries(parameters, context), resolved) ?? original;
146
+ }
@@ -1,7 +1,7 @@
1
1
  import { irKeyword, irObject, irProperty } from "../../../domain/ir/constructors.js";
2
2
  import type { IrMember, IrType } from "../../../domain/ir/nodes.js";
3
3
  import { toPropertyName } from "../../../domain/ir/property-name.js";
4
- import { createRef } from "../../../domain/openapi/json-pointer.js";
4
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
5
5
  import type { RequestBodyObject } from "../../../domain/openapi/request-body-object.js";
6
6
  import { documentEntries } from "../document-entries.js";
7
7
  import type { SchemaContext, SchemaLocation } from "../schema/schema-context.js";
@@ -18,7 +18,7 @@ function contentMembers(
18
18
  ): IrMember[] {
19
19
  const entries = documentEntries(requestBody.content ?? {}, context.options);
20
20
  return entries.map(([contentType, entry]) => {
21
- const path = createRef([location.path, "content", contentType]);
21
+ const path = appendPointer(location.path, ["content", contentType]);
22
22
  const type = contentEntryType(entry, { ...location, path }, context);
23
23
  return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
24
24
  });
@@ -6,7 +6,7 @@ import {
6
6
  } from "../../../domain/ir/constructors.js";
7
7
  import type { IrMember, IrPropertySignature, IrType } from "../../../domain/ir/nodes.js";
8
8
  import { toPropertyName } from "../../../domain/ir/property-name.js";
9
- import { createRef } from "../../../domain/openapi/json-pointer.js";
9
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
10
10
  import {
11
11
  isMediaTypeComponentRef,
12
12
  type MediaTypeObject,
@@ -34,7 +34,7 @@ function headerMember(
34
34
  ? refType(header.$ref)
35
35
  : headerType(
36
36
  header,
37
- { ...location, path: createRef([location.path, "headers", name]) },
37
+ { ...location, path: appendPointer(location.path, ["headers", name]) },
38
38
  context,
39
39
  );
40
40
  return documentMember(name, type, header, {
@@ -79,7 +79,7 @@ function contentMember(
79
79
  ): IrPropertySignature {
80
80
  const entries = documentEntries(response.content ?? {}, context.options);
81
81
  const members = entries.map(([contentType, entry]) => {
82
- const path = createRef([location.path, "content", contentType]);
82
+ const path = appendPointer(location.path, ["content", contentType]);
83
83
  const type = mediaTypeEntryType(entry, { ...location, path }, context);
84
84
  return documentMember(contentType, type, entry, { isReadonly: context.options.immutable });
85
85
  });
@@ -1,6 +1,6 @@
1
1
  import { irKeyword, irObject } from "../../../domain/ir/constructors.js";
2
2
  import type { IrType } from "../../../domain/ir/nodes.js";
3
- import { createRef } from "../../../domain/openapi/json-pointer.js";
3
+ import { appendPointer } from "../../../domain/openapi/json-pointer.js";
4
4
  import type { ResponsesObject } from "../../../domain/openapi/response-object.js";
5
5
  import { documentEntries } from "../document-entries.js";
6
6
  import { refType } from "../ref-type.js";
@@ -20,7 +20,7 @@ export function responsesType(
20
20
  ? refType(response.$ref)
21
21
  : responseType(
22
22
  response,
23
- { ...location, path: createRef([location.path, "responses", code]) },
23
+ { ...location, path: appendPointer(location.path, ["responses", code]) },
24
24
  context,
25
25
  );
26
26
  return documentMember(code, type, response, { isReadonly: context.options.immutable });
@@ -2,6 +2,8 @@ import { irRaw } from "../../../domain/ir/constructors.js";
2
2
  import type { IrDeclaration, IrTypeAliasDeclaration } from "../../../domain/ir/nodes.js";
3
3
  import { escapeSingleQuotedText } from "../../../domain/ir/raw-text-escapes.js";
4
4
  import type { ComponentKind } from "../../../domain/openapi/components-object.js";
5
+ import { freeNumberedName } from "../numbered-names.js";
6
+ import { typeNamesDeclaredBy } from "./declared-type-names.js";
5
7
  import { globalTypeReferences } from "./global-type-references.js";
6
8
 
7
9
  /** The `--root-types` aliases: `export type Pet = components['schemas']['Pet'];`. */
@@ -25,7 +27,8 @@ export function rootTypeAlias(
25
27
  };
26
28
  }
27
29
 
28
- function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {
30
+ /** Whether the declaration is a `--root-types` alias, which gives way to every other name. */
31
+ export function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAliasDeclaration {
29
32
  return (
30
33
  declaration.kind === "typeAlias" &&
31
34
  declaration.type.kind === "raw" &&
@@ -33,23 +36,6 @@ function isRootTypeAlias(declaration: IrDeclaration): declaration is IrTypeAlias
33
36
  );
34
37
  }
35
38
 
36
- /**
37
- * The type names the footer declares that an alias must not take: enums, and helper types such as
38
- * `WithRequired`. Value declarations (`--enum-values` arrays) live in another namespace.
39
- */
40
- function footerTypeNames(declarations: readonly IrDeclaration[]): Set<string> {
41
- return new Set(
42
- declarations.flatMap((declaration) => {
43
- if (declaration.kind === "enum") {
44
- return [declaration.name];
45
- }
46
- return declaration.kind === "rawDeclaration" && declaration.name !== undefined
47
- ? [declaration.name]
48
- : [];
49
- }),
50
- );
51
- }
52
-
53
39
  function declaredNames(declarations: readonly IrDeclaration[]): Set<string> {
54
40
  return new Set(
55
41
  declarations.flatMap((declaration) =>
@@ -58,21 +44,15 @@ function declaredNames(declarations: readonly IrDeclaration[]): Set<string> {
58
44
  );
59
45
  }
60
46
 
61
- function freeName(name: string, taken: ReadonlySet<string>): string {
62
- let candidate = `${name}_2`;
63
- for (let counter = 3; taken.has(candidate); counter++) {
64
- candidate = `${name}_${counter}`;
65
- }
66
- return candidate;
67
- }
68
-
69
47
  /**
70
- * Rename each root alias whose name an enum or a helper type of the footer also declares, or that
71
- * shadows a TypeScript global type the output refers to (`Record` in `Record<string, never>`), to
72
- * the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses for its own conflicts). The
73
- * footer and the globals keep their names, because the generated types refer to them. Before, the
74
- * output did not compile (enums: upstream #2099, #2341, #2206; helpers: a schema named
75
- * `WithRequired`, roadmap R11; globals: TS2315). Other declarations are returned unchanged.
48
+ * Rename each root alias whose name another declaration of the output also takes (an enum, a
49
+ * helper type, the `--make-paths-enum` enum `ApiPaths`, a root interface, `--read-write-markers`
50
+ * or `inject` types), or that shadows a TypeScript global type the output refers to (`Record` in
51
+ * `Record<string, never>`), to the next free `Name_2`, `Name_3`, … (the suffix `--root-types` uses
52
+ * for its own conflicts). The others and the globals keep their names, because the generated
53
+ * types refer to them. Before, the output did not compile (enums: upstream #2099, #2341, #2206;
54
+ * helpers: a schema named `WithRequired`, roadmap R11; globals: TS2315; `ApiPaths`: TS2567).
55
+ * Other declarations are returned unchanged.
76
56
  *
77
57
  * With the `root-type-numbering` fix (ADR-021, roadmap R13, backlog 30) the body also holds the
78
58
  * aliases a later schema of one exported name took the name from, after the other aliases and
@@ -85,11 +65,10 @@ export function renameTakenAliases<T extends IrDeclaration>(
85
65
  footer: readonly IrDeclaration[],
86
66
  closing: readonly IrDeclaration[] = [],
87
67
  ): T[] {
88
- const reserved = footerTypeNames(footer);
89
- for (const name of globalTypeReferences([...body, ...footer, ...closing])) {
90
- reserved.add(name);
91
- }
92
- const taken = declaredNames([...body, ...footer, ...closing]);
68
+ const all = [...body, ...footer, ...closing];
69
+ const others = all.filter((declaration) => !isRootTypeAlias(declaration));
70
+ const reserved = new Set([...typeNamesDeclaredBy(others), ...globalTypeReferences(all)]);
71
+ const taken = new Set([...declaredNames(all), ...typeNamesDeclaredBy(all)]);
93
72
  const aliasNames = new Set<string>();
94
73
  return body.map((declaration) => {
95
74
  if (!isRootTypeAlias(declaration)) {
@@ -100,7 +79,7 @@ export function renameTakenAliases<T extends IrDeclaration>(
100
79
  if (!isRepeated && !reserved.has(declaration.name)) {
101
80
  return declaration;
102
81
  }
103
- const name = freeName(declaration.name, taken);
82
+ const name = freeNumberedName(declaration.name, taken);
104
83
  taken.add(name);
105
84
  return { ...declaration, name };
106
85
  });
@@ -1,3 +1,4 @@
1
+ import { appendAll } from "../../../domain/append-all.js";
1
2
  import type {
2
3
  IrIndexSignature,
3
4
  IrMember,
@@ -156,7 +157,7 @@ export class TypeResolution {
156
157
  if (objects === null) {
157
158
  return null;
158
159
  }
159
- parts.push(...objects);
160
+ appendAll(parts, objects);
160
161
  }
161
162
  return parts;
162
163
  }