@redocly/openapi-core 1.0.0-beta.99 → 1.0.0-rc.2

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 (382) hide show
  1. package/README.md +6 -6
  2. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +0 -1
  3. package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
  4. package/lib/benchmark/benches/resolve-with-no-external.bench.js +1 -1
  5. package/lib/benchmark/utils.d.ts +2 -2
  6. package/lib/benchmark/utils.js +2 -2
  7. package/lib/bundle.d.ts +10 -15
  8. package/lib/bundle.js +32 -12
  9. package/lib/config/all.d.ts +2 -2
  10. package/lib/config/all.js +16 -6
  11. package/lib/config/builtIn.d.ts +2 -2
  12. package/lib/config/builtIn.js +2 -2
  13. package/lib/config/config-resolvers.d.ts +5 -5
  14. package/lib/config/config-resolvers.js +121 -66
  15. package/lib/config/config.d.ts +12 -18
  16. package/lib/config/config.js +42 -26
  17. package/lib/config/load.d.ts +16 -3
  18. package/lib/config/load.js +36 -14
  19. package/lib/config/minimal.d.ts +2 -2
  20. package/lib/config/minimal.js +10 -6
  21. package/lib/config/recommended.d.ts +2 -2
  22. package/lib/config/recommended.js +10 -6
  23. package/lib/config/rules.d.ts +7 -4
  24. package/lib/config/rules.js +5 -4
  25. package/lib/config/types.d.ts +72 -23
  26. package/lib/config/types.js +13 -0
  27. package/lib/config/utils.d.ts +6 -5
  28. package/lib/config/utils.js +110 -32
  29. package/lib/decorators/common/filters/filter-helper.d.ts +3 -0
  30. package/lib/decorators/common/filters/filter-helper.js +67 -0
  31. package/lib/decorators/common/filters/filter-in.d.ts +2 -0
  32. package/lib/decorators/common/filters/filter-in.js +17 -0
  33. package/lib/decorators/common/filters/filter-out.d.ts +2 -0
  34. package/lib/decorators/common/filters/filter-out.js +17 -0
  35. package/lib/decorators/common/info-override.d.ts +2 -0
  36. package/lib/decorators/common/info-override.js +28 -0
  37. package/lib/decorators/common/media-type-examples-override.d.ts +2 -0
  38. package/lib/decorators/common/media-type-examples-override.js +53 -0
  39. package/lib/decorators/common/registry-dependencies.js +2 -2
  40. package/lib/decorators/common/remove-x-internal.js +2 -2
  41. package/lib/decorators/oas2/index.d.ts +3 -0
  42. package/lib/decorators/oas2/index.js +7 -1
  43. package/lib/decorators/oas3/index.d.ts +4 -0
  44. package/lib/decorators/oas3/index.js +9 -1
  45. package/lib/env.d.ts +3 -0
  46. package/lib/env.js +8 -0
  47. package/lib/format/codeframes.js +16 -10
  48. package/lib/format/format.d.ts +1 -1
  49. package/lib/format/format.js +64 -32
  50. package/lib/index.d.ts +6 -6
  51. package/lib/index.js +7 -2
  52. package/lib/js-yaml/index.js +2 -6
  53. package/lib/lint.d.ts +4 -2
  54. package/lib/lint.js +36 -11
  55. package/lib/logger.d.ts +10 -0
  56. package/lib/logger.js +31 -0
  57. package/lib/output.d.ts +3 -0
  58. package/lib/output.js +9 -0
  59. package/lib/redocly/index.js +10 -9
  60. package/lib/redocly/registry-api-types.d.ts +28 -28
  61. package/lib/redocly/registry-api.d.ts +3 -3
  62. package/lib/redocly/registry-api.js +10 -2
  63. package/lib/ref-utils.d.ts +1 -0
  64. package/lib/ref-utils.js +7 -2
  65. package/lib/resolve.d.ts +1 -1
  66. package/lib/resolve.js +33 -3
  67. package/lib/rules/ajv.d.ts +2 -2
  68. package/lib/rules/ajv.js +12 -12
  69. package/lib/rules/common/assertions/asserts.d.ts +29 -4
  70. package/lib/rules/common/assertions/asserts.js +227 -97
  71. package/lib/rules/common/assertions/index.d.ts +27 -2
  72. package/lib/rules/common/assertions/index.js +9 -37
  73. package/lib/rules/common/assertions/utils.d.ts +16 -8
  74. package/lib/rules/common/assertions/utils.js +160 -76
  75. package/lib/rules/common/info-license-url.d.ts +1 -1
  76. package/lib/rules/common/info-license-url.js +5 -10
  77. package/lib/rules/common/info-license.d.ts +2 -0
  78. package/lib/rules/common/info-license.js +17 -0
  79. package/lib/rules/common/no-ambiguous-paths.js +1 -1
  80. package/lib/rules/common/no-enum-type-mismatch.js +1 -3
  81. package/lib/rules/common/no-identical-paths.js +4 -4
  82. package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
  83. package/lib/rules/common/no-invalid-schema-examples.js +3 -3
  84. package/lib/rules/common/operation-2xx-response.js +15 -9
  85. package/lib/rules/common/operation-4xx-response.js +15 -9
  86. package/lib/rules/common/operation-operationId.js +2 -2
  87. package/lib/rules/common/operation-tag-defined.js +1 -1
  88. package/lib/rules/common/path-not-include-query.js +2 -2
  89. package/lib/rules/common/path-params-defined.js +7 -2
  90. package/lib/rules/common/paths-kebab-case.js +4 -1
  91. package/lib/rules/common/required-string-property-missing-min-length.d.ts +2 -0
  92. package/lib/rules/common/required-string-property-missing-min-length.js +37 -0
  93. package/lib/rules/common/response-contains-header.js +2 -2
  94. package/lib/rules/common/scalar-property-missing-example.js +2 -1
  95. package/lib/rules/common/security-defined.d.ts +2 -0
  96. package/lib/rules/common/{operation-security-defined.js → security-defined.js} +25 -6
  97. package/lib/rules/common/spec-strict-refs.d.ts +2 -0
  98. package/lib/rules/common/spec-strict-refs.js +30 -0
  99. package/lib/rules/common/spec.js +41 -18
  100. package/lib/rules/common/tags-alphabetical.js +1 -1
  101. package/lib/rules/oas2/index.d.ts +3 -2
  102. package/lib/rules/oas2/index.js +10 -8
  103. package/lib/rules/oas2/remove-unused-components.js +6 -6
  104. package/lib/rules/oas2/request-mime-type.d.ts +1 -1
  105. package/lib/rules/oas2/request-mime-type.js +1 -1
  106. package/lib/rules/oas2/response-mime-type.d.ts +1 -1
  107. package/lib/rules/oas2/response-mime-type.js +1 -1
  108. package/lib/rules/oas3/component-name-unique.d.ts +2 -0
  109. package/lib/rules/oas3/component-name-unique.js +124 -0
  110. package/lib/rules/oas3/index.js +18 -10
  111. package/lib/rules/oas3/no-empty-servers.js +2 -2
  112. package/lib/rules/oas3/no-invalid-media-type-examples.js +2 -2
  113. package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -0
  114. package/lib/rules/oas3/{no-servers-empty-enum.js → no-server-variables-empty-enum.js} +5 -5
  115. package/lib/rules/oas3/no-unused-components.js +2 -2
  116. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +5 -0
  117. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +36 -0
  118. package/lib/rules/oas3/remove-unused-components.js +6 -6
  119. package/lib/rules/oas3/request-mime-type.d.ts +1 -1
  120. package/lib/rules/oas3/request-mime-type.js +1 -1
  121. package/lib/rules/oas3/response-mime-type.d.ts +1 -1
  122. package/lib/rules/oas3/response-mime-type.js +1 -1
  123. package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -0
  124. package/lib/rules/oas3/spec-components-invalid-map-name.js +62 -0
  125. package/lib/rules/other/stats.d.ts +2 -2
  126. package/lib/rules/other/stats.js +45 -16
  127. package/lib/rules/utils.d.ts +5 -2
  128. package/lib/rules/utils.js +54 -6
  129. package/lib/types/config-external-schemas.d.ts +2193 -0
  130. package/lib/types/config-external-schemas.js +805 -0
  131. package/lib/types/index.d.ts +3 -2
  132. package/lib/types/index.js +9 -1
  133. package/lib/types/oas2.js +91 -15
  134. package/lib/types/oas3.js +125 -46
  135. package/lib/types/oas3_1.js +23 -19
  136. package/lib/types/redocly-yaml.js +406 -60
  137. package/lib/utils.d.ts +15 -4
  138. package/lib/utils.js +72 -8
  139. package/lib/visitors.d.ts +20 -16
  140. package/lib/visitors.js +28 -3
  141. package/lib/walk.d.ts +11 -19
  142. package/lib/walk.js +74 -53
  143. package/package.json +5 -6
  144. package/__tests__/utils.ts +0 -86
  145. package/lib/rules/common/info-description.d.ts +0 -2
  146. package/lib/rules/common/info-description.js +0 -12
  147. package/lib/rules/common/license-url.d.ts +0 -2
  148. package/lib/rules/common/license-url.js +0 -12
  149. package/lib/rules/common/operation-security-defined.d.ts +0 -2
  150. package/lib/rules/oas3/no-servers-empty-enum.d.ts +0 -2
  151. package/src/__tests__/__snapshots__/bundle.test.ts.snap +0 -255
  152. package/src/__tests__/bundle.test.ts +0 -156
  153. package/src/__tests__/codeframes.test.ts +0 -531
  154. package/src/__tests__/fixtures/extension.js +0 -24
  155. package/src/__tests__/fixtures/refs/definitions.yaml +0 -3
  156. package/src/__tests__/fixtures/refs/examples.yaml +0 -8
  157. package/src/__tests__/fixtures/refs/external-request-body.yaml +0 -13
  158. package/src/__tests__/fixtures/refs/externalref.yaml +0 -35
  159. package/src/__tests__/fixtures/refs/hosted.yaml +0 -35
  160. package/src/__tests__/fixtures/refs/openapi-with-external-refs-conflicting-names.yaml +0 -21
  161. package/src/__tests__/fixtures/refs/openapi-with-external-refs.yaml +0 -33
  162. package/src/__tests__/fixtures/refs/openapi-with-url-refs.yaml +0 -18
  163. package/src/__tests__/fixtures/refs/param-b.yaml +0 -1
  164. package/src/__tests__/fixtures/refs/param-c.yaml +0 -1
  165. package/src/__tests__/fixtures/refs/rename.yaml +0 -1
  166. package/src/__tests__/fixtures/refs/requestBody.yaml +0 -9
  167. package/src/__tests__/fixtures/refs/schema-a.yaml +0 -1
  168. package/src/__tests__/fixtures/refs/simple.yaml +0 -1
  169. package/src/__tests__/fixtures/refs/vendor.schema.yaml +0 -20
  170. package/src/__tests__/fixtures/resolve/External.yaml +0 -10
  171. package/src/__tests__/fixtures/resolve/External2.yaml +0 -4
  172. package/src/__tests__/fixtures/resolve/description.md +0 -3
  173. package/src/__tests__/fixtures/resolve/externalInfo.yaml +0 -4
  174. package/src/__tests__/fixtures/resolve/externalLicense.yaml +0 -1
  175. package/src/__tests__/fixtures/resolve/openapi-with-back.yaml +0 -13
  176. package/src/__tests__/fixtures/resolve/openapi-with-md-description.yaml +0 -5
  177. package/src/__tests__/fixtures/resolve/openapi.yaml +0 -28
  178. package/src/__tests__/fixtures/resolve/schemas/type-a.yaml +0 -10
  179. package/src/__tests__/fixtures/resolve/schemas/type-b.yaml +0 -6
  180. package/src/__tests__/fixtures/resolve/transitive/a.yaml +0 -1
  181. package/src/__tests__/fixtures/resolve/transitive/components.yaml +0 -5
  182. package/src/__tests__/fixtures/resolve/transitive/schemas.yaml +0 -3
  183. package/src/__tests__/js-yaml.test.ts +0 -71
  184. package/src/__tests__/lint.test.ts +0 -195
  185. package/src/__tests__/login.test.ts +0 -17
  186. package/src/__tests__/normalizeVisitors.test.ts +0 -151
  187. package/src/__tests__/ref-utils.test.ts +0 -120
  188. package/src/__tests__/resolve-http.test.ts +0 -77
  189. package/src/__tests__/resolve.test.ts +0 -405
  190. package/src/__tests__/utils.test.ts +0 -85
  191. package/src/__tests__/walk.test.ts +0 -1485
  192. package/src/benchmark/benches/lint-with-many-rules.bench.ts +0 -35
  193. package/src/benchmark/benches/lint-with-nested-rule.bench.ts +0 -39
  194. package/src/benchmark/benches/lint-with-no-rules.bench.ts +0 -20
  195. package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +0 -36
  196. package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +0 -32
  197. package/src/benchmark/benches/rebilly.yaml +0 -32267
  198. package/src/benchmark/benches/recommended-oas3.bench.ts +0 -22
  199. package/src/benchmark/benches/resolve-with-no-external.bench.ts +0 -23
  200. package/src/benchmark/benchmark.js +0 -307
  201. package/src/benchmark/colors.js +0 -29
  202. package/src/benchmark/fork.js +0 -83
  203. package/src/benchmark/utils.ts +0 -36
  204. package/src/bundle.ts +0 -386
  205. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +0 -157
  206. package/src/config/__tests__/config-resolvers.test.ts +0 -429
  207. package/src/config/__tests__/config.test.ts +0 -244
  208. package/src/config/__tests__/fixtures/plugin-config.yaml +0 -3
  209. package/src/config/__tests__/fixtures/plugin.js +0 -56
  210. package/src/config/__tests__/fixtures/resolve-config/api/nested-config.yaml +0 -12
  211. package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +0 -67
  212. package/src/config/__tests__/fixtures/resolve-config/local-config-with-circular.yaml +0 -8
  213. package/src/config/__tests__/fixtures/resolve-config/local-config-with-file.yaml +0 -19
  214. package/src/config/__tests__/fixtures/resolve-config/local-config.yaml +0 -10
  215. package/src/config/__tests__/fixtures/resolve-config/plugin.js +0 -66
  216. package/src/config/__tests__/fixtures/resolve-remote-configs/nested-remote-config.yaml +0 -4
  217. package/src/config/__tests__/fixtures/resolve-remote-configs/remote-config.yaml +0 -5
  218. package/src/config/__tests__/load.test.ts +0 -83
  219. package/src/config/__tests__/resolve-plugins.test.ts +0 -27
  220. package/src/config/all.ts +0 -66
  221. package/src/config/builtIn.ts +0 -37
  222. package/src/config/config-resolvers.ts +0 -359
  223. package/src/config/config.ts +0 -312
  224. package/src/config/index.ts +0 -7
  225. package/src/config/load.ts +0 -84
  226. package/src/config/minimal.ts +0 -58
  227. package/src/config/recommended.ts +0 -58
  228. package/src/config/rules.ts +0 -46
  229. package/src/config/types.ts +0 -168
  230. package/src/config/utils.ts +0 -208
  231. package/src/decorators/__tests__/remove-x-internal.test.ts +0 -316
  232. package/src/decorators/common/info-description-override.ts +0 -24
  233. package/src/decorators/common/operation-description-override.ts +0 -30
  234. package/src/decorators/common/registry-dependencies.ts +0 -25
  235. package/src/decorators/common/remove-x-internal.ts +0 -59
  236. package/src/decorators/common/tag-description-override.ts +0 -25
  237. package/src/decorators/oas2/index.ts +0 -14
  238. package/src/decorators/oas3/index.ts +0 -14
  239. package/src/format/codeframes.ts +0 -210
  240. package/src/format/format.ts +0 -339
  241. package/src/index.ts +0 -68
  242. package/src/js-yaml/index.ts +0 -18
  243. package/src/lint.ts +0 -125
  244. package/src/oas-types.ts +0 -62
  245. package/src/redocly/__tests__/redocly-client.test.ts +0 -140
  246. package/src/redocly/index.ts +0 -182
  247. package/src/redocly/redocly-client-types.ts +0 -10
  248. package/src/redocly/registry-api-types.ts +0 -32
  249. package/src/redocly/registry-api.ts +0 -134
  250. package/src/ref-utils.ts +0 -80
  251. package/src/resolve.ts +0 -378
  252. package/src/rules/__tests__/fixtures/invalid-yaml.yaml +0 -1
  253. package/src/rules/__tests__/fixtures/ref.yaml +0 -1
  254. package/src/rules/__tests__/no-unresolved-refs.test.ts +0 -168
  255. package/src/rules/ajv.ts +0 -103
  256. package/src/rules/common/__tests__/info-description.test.ts +0 -102
  257. package/src/rules/common/__tests__/info-license.test.ts +0 -62
  258. package/src/rules/common/__tests__/license-url.test.ts +0 -63
  259. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +0 -96
  260. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +0 -209
  261. package/src/rules/common/__tests__/no-identical-paths.test.ts +0 -58
  262. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +0 -85
  263. package/src/rules/common/__tests__/operation-2xx-response.test.ts +0 -91
  264. package/src/rules/common/__tests__/operation-4xx-response.test.ts +0 -107
  265. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +0 -76
  266. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +0 -45
  267. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +0 -167
  268. package/src/rules/common/__tests__/operation-security-defined.test.ts +0 -69
  269. package/src/rules/common/__tests__/operation-singular-tag.test.ts +0 -72
  270. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +0 -95
  271. package/src/rules/common/__tests__/path-not-include-query.test.ts +0 -64
  272. package/src/rules/common/__tests__/path-params-defined.test.ts +0 -133
  273. package/src/rules/common/__tests__/paths-kebab-case.test.ts +0 -108
  274. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +0 -207
  275. package/src/rules/common/__tests__/spec.test.ts +0 -62
  276. package/src/rules/common/__tests__/tag-description.test.ts +0 -65
  277. package/src/rules/common/__tests__/tags-alphabetical.test.ts +0 -64
  278. package/src/rules/common/assertions/__tests__/asserts.test.ts +0 -231
  279. package/src/rules/common/assertions/__tests__/index.test.ts +0 -65
  280. package/src/rules/common/assertions/__tests__/utils.test.ts +0 -89
  281. package/src/rules/common/assertions/asserts.ts +0 -137
  282. package/src/rules/common/assertions/index.ts +0 -75
  283. package/src/rules/common/assertions/utils.ts +0 -167
  284. package/src/rules/common/info-contact.ts +0 -15
  285. package/src/rules/common/info-description.ts +0 -10
  286. package/src/rules/common/info-license-url.ts +0 -15
  287. package/src/rules/common/license-url.ts +0 -10
  288. package/src/rules/common/no-ambiguous-paths.ts +0 -50
  289. package/src/rules/common/no-enum-type-mismatch.ts +0 -49
  290. package/src/rules/common/no-http-verbs-in-paths.ts +0 -36
  291. package/src/rules/common/no-identical-paths.ts +0 -24
  292. package/src/rules/common/no-invalid-parameter-examples.ts +0 -36
  293. package/src/rules/common/no-invalid-schema-examples.ts +0 -27
  294. package/src/rules/common/no-path-trailing-slash.ts +0 -15
  295. package/src/rules/common/operation-2xx-response.ts +0 -16
  296. package/src/rules/common/operation-4xx-response.ts +0 -17
  297. package/src/rules/common/operation-description.ts +0 -13
  298. package/src/rules/common/operation-operationId-unique.ts +0 -21
  299. package/src/rules/common/operation-operationId-url-safe.ts +0 -19
  300. package/src/rules/common/operation-operationId.ts +0 -17
  301. package/src/rules/common/operation-parameters-unique.ts +0 -48
  302. package/src/rules/common/operation-security-defined.ts +0 -45
  303. package/src/rules/common/operation-singular-tag.ts +0 -17
  304. package/src/rules/common/operation-summary.ts +0 -13
  305. package/src/rules/common/operation-tag-defined.ts +0 -26
  306. package/src/rules/common/parameter-description.ts +0 -22
  307. package/src/rules/common/path-declaration-must-exist.ts +0 -15
  308. package/src/rules/common/path-excludes-patterns.ts +0 -23
  309. package/src/rules/common/path-http-verbs-order.ts +0 -30
  310. package/src/rules/common/path-not-include-query.ts +0 -17
  311. package/src/rules/common/path-params-defined.ts +0 -58
  312. package/src/rules/common/path-segment-plural.ts +0 -31
  313. package/src/rules/common/paths-kebab-case.ts +0 -16
  314. package/src/rules/common/response-contains-header.ts +0 -30
  315. package/src/rules/common/scalar-property-missing-example.ts +0 -55
  316. package/src/rules/common/spec.ts +0 -143
  317. package/src/rules/common/tag-description.ts +0 -10
  318. package/src/rules/common/tags-alphabetical.ts +0 -20
  319. package/src/rules/no-unresolved-refs.ts +0 -51
  320. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +0 -110
  321. package/src/rules/oas2/__tests__/response-contains-header.test.ts +0 -174
  322. package/src/rules/oas2/__tests__/response-contains-property.test.ts +0 -155
  323. package/src/rules/oas2/__tests__/spec/fixtures/description.md +0 -1
  324. package/src/rules/oas2/__tests__/spec/info.test.ts +0 -355
  325. package/src/rules/oas2/__tests__/spec/operation.test.ts +0 -123
  326. package/src/rules/oas2/__tests__/spec/paths.test.ts +0 -245
  327. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +0 -31
  328. package/src/rules/oas2/__tests__/spec/utils.ts +0 -32
  329. package/src/rules/oas2/boolean-parameter-prefixes.ts +0 -26
  330. package/src/rules/oas2/index.ts +0 -89
  331. package/src/rules/oas2/remove-unused-components.ts +0 -76
  332. package/src/rules/oas2/request-mime-type.ts +0 -17
  333. package/src/rules/oas2/response-contains-property.ts +0 -36
  334. package/src/rules/oas2/response-mime-type.ts +0 -17
  335. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +0 -111
  336. package/src/rules/oas3/__tests__/fixtures/common.yaml +0 -11
  337. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +0 -205
  338. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +0 -65
  339. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +0 -392
  340. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +0 -60
  341. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +0 -79
  342. package/src/rules/oas3/__tests__/no-unused-components.test.ts +0 -131
  343. package/src/rules/oas3/__tests__/response-contains-header.test.ts +0 -273
  344. package/src/rules/oas3/__tests__/response-contains-property.test.ts +0 -403
  345. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +0 -41
  346. package/src/rules/oas3/__tests__/spec/fixtures/description.md +0 -1
  347. package/src/rules/oas3/__tests__/spec/info.test.ts +0 -391
  348. package/src/rules/oas3/__tests__/spec/operation.test.ts +0 -253
  349. package/src/rules/oas3/__tests__/spec/paths.test.ts +0 -284
  350. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +0 -77
  351. package/src/rules/oas3/__tests__/spec/servers.test.ts +0 -499
  352. package/src/rules/oas3/__tests__/spec/spec.test.ts +0 -288
  353. package/src/rules/oas3/__tests__/spec/utils.ts +0 -32
  354. package/src/rules/oas3/boolean-parameter-prefixes.ts +0 -28
  355. package/src/rules/oas3/index.ts +0 -105
  356. package/src/rules/oas3/no-empty-servers.ts +0 -22
  357. package/src/rules/oas3/no-example-value-and-externalValue.ts +0 -14
  358. package/src/rules/oas3/no-invalid-media-type-examples.ts +0 -41
  359. package/src/rules/oas3/no-server-example.com.ts +0 -14
  360. package/src/rules/oas3/no-server-trailing-slash.ts +0 -15
  361. package/src/rules/oas3/no-servers-empty-enum.ts +0 -67
  362. package/src/rules/oas3/no-undefined-server-variable.ts +0 -30
  363. package/src/rules/oas3/no-unused-components.ts +0 -75
  364. package/src/rules/oas3/remove-unused-components.ts +0 -84
  365. package/src/rules/oas3/request-mime-type.ts +0 -31
  366. package/src/rules/oas3/response-contains-property.ts +0 -38
  367. package/src/rules/oas3/response-mime-type.ts +0 -31
  368. package/src/rules/other/stats.ts +0 -44
  369. package/src/rules/utils.ts +0 -123
  370. package/src/types/index.ts +0 -138
  371. package/src/types/oas2.ts +0 -397
  372. package/src/types/oas3.ts +0 -515
  373. package/src/types/oas3_1.ts +0 -253
  374. package/src/types/redocly-yaml.ts +0 -647
  375. package/src/typings/common.ts +0 -9
  376. package/src/typings/openapi.ts +0 -298
  377. package/src/typings/swagger.ts +0 -236
  378. package/src/utils.ts +0 -193
  379. package/src/visitors.ts +0 -448
  380. package/src/walk.ts +0 -416
  381. package/tsconfig.json +0 -8
  382. package/tsconfig.tsbuildinfo +0 -1
@@ -11,10 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  return t;
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.getUniquePlugins = exports.getResolveConfig = exports.transformConfig = exports.getMergedConfig = exports.mergeExtends = exports.prefixRules = exports.transformApiDefinitionsToApis = exports.parsePresetName = void 0;
15
- const colorette_1 = require("colorette");
14
+ exports.getUniquePlugins = exports.getResolveConfig = exports.transformConfig = exports.checkForDeprecatedFields = exports.getMergedConfig = exports.mergeExtends = exports.prefixRules = exports.transformApiDefinitionsToApis = exports.parsePresetName = void 0;
16
15
  const utils_1 = require("../utils");
17
16
  const config_1 = require("./config");
17
+ const logger_1 = require("../logger");
18
18
  function parsePresetName(presetName) {
19
19
  if (presetName.indexOf('/') > -1) {
20
20
  const [pluginId, configName] = presetName.split('/');
@@ -25,14 +25,59 @@ function parsePresetName(presetName) {
25
25
  }
26
26
  }
27
27
  exports.parsePresetName = parsePresetName;
28
- function transformApiDefinitionsToApis(apiDefinitions = {}) {
29
- let apis = {};
28
+ function transformApiDefinitionsToApis(apiDefinitions) {
29
+ if (!apiDefinitions)
30
+ return undefined;
31
+ const apis = {};
30
32
  for (const [apiName, apiPath] of Object.entries(apiDefinitions)) {
31
33
  apis[apiName] = { root: apiPath };
32
34
  }
33
35
  return apis;
34
36
  }
35
37
  exports.transformApiDefinitionsToApis = transformApiDefinitionsToApis;
38
+ function extractFlatConfig(_a) {
39
+ var _b;
40
+ var { plugins, extends: _extends, rules, oas2Rules, oas3_0Rules, oas3_1Rules, preprocessors, oas2Preprocessors, oas3_0Preprocessors, oas3_1Preprocessors, decorators, oas2Decorators, oas3_0Decorators, oas3_1Decorators } = _a, rawConfigRest = __rest(_a, ["plugins", "extends", "rules", "oas2Rules", "oas3_0Rules", "oas3_1Rules", "preprocessors", "oas2Preprocessors", "oas3_0Preprocessors", "oas3_1Preprocessors", "decorators", "oas2Decorators", "oas3_0Decorators", "oas3_1Decorators"]);
41
+ const styleguideConfig = {
42
+ plugins,
43
+ extends: _extends,
44
+ rules,
45
+ oas2Rules,
46
+ oas3_0Rules,
47
+ oas3_1Rules,
48
+ preprocessors,
49
+ oas2Preprocessors,
50
+ oas3_0Preprocessors,
51
+ oas3_1Preprocessors,
52
+ decorators,
53
+ oas2Decorators,
54
+ oas3_0Decorators,
55
+ oas3_1Decorators,
56
+ doNotResolveExamples: (_b = rawConfigRest.resolve) === null || _b === void 0 ? void 0 : _b.doNotResolveExamples,
57
+ };
58
+ if ((rawConfigRest.lint && rawConfigRest.styleguide) ||
59
+ (Object.values(styleguideConfig).some(utils_1.isDefined) &&
60
+ (rawConfigRest.lint || rawConfigRest.styleguide))) {
61
+ throw new Error(`Do not use 'lint', 'styleguide' and flat syntax together. \nSee more about the configuration in the docs: https://redocly.com/docs/cli/configuration/ \n`);
62
+ }
63
+ return {
64
+ styleguideConfig: Object.values(styleguideConfig).some(utils_1.isDefined)
65
+ ? styleguideConfig
66
+ : undefined,
67
+ rawConfigRest,
68
+ };
69
+ }
70
+ function transformApis(legacyApis) {
71
+ if (!legacyApis)
72
+ return undefined;
73
+ const apis = {};
74
+ for (let _a of Object.entries(legacyApis)) {
75
+ const [apiName, _b] = _a, { lint } = _b, apiContent = __rest(_b, ["lint"]);
76
+ const { styleguideConfig, rawConfigRest } = extractFlatConfig(apiContent);
77
+ apis[apiName] = Object.assign({ styleguide: styleguideConfig || lint }, rawConfigRest);
78
+ }
79
+ return apis;
80
+ }
36
81
  function prefixRules(rules, prefix) {
37
82
  if (!prefix)
38
83
  return rules;
@@ -61,9 +106,9 @@ function mergeExtends(rulesConfList) {
61
106
  pluginPaths: [],
62
107
  extendPaths: [],
63
108
  };
64
- for (let rulesConf of rulesConfList) {
109
+ for (const rulesConf of rulesConfList) {
65
110
  if (rulesConf.extends) {
66
- throw new Error(`\`extends\` is not supported in shared configs yet: ${JSON.stringify(rulesConf, null, 2)}.`);
111
+ throw new Error(`'extends' is not supported in shared configs yet: ${JSON.stringify(rulesConf, null, 2)}.`);
67
112
  }
68
113
  Object.assign(result.rules, rulesConf.rules);
69
114
  Object.assign(result.oas2Rules, rulesConf.oas2Rules);
@@ -93,46 +138,79 @@ function mergeExtends(rulesConfList) {
93
138
  return result;
94
139
  }
95
140
  exports.mergeExtends = mergeExtends;
96
- function getMergedConfig(config, entrypointAlias) {
97
- var _a, _b, _c, _d, _e, _f;
141
+ function getMergedConfig(config, apiName) {
142
+ var _a, _b, _c, _d, _e, _f, _g, _h;
98
143
  const extendPaths = [
99
- ...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.lint) === null || _a === void 0 ? void 0 : _a.extendPaths; }),
100
- (_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.lint) === null || _b === void 0 ? void 0 : _b.extendPaths,
144
+ ...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.styleguide) === null || _a === void 0 ? void 0 : _a.extendPaths; }),
145
+ (_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.styleguide) === null || _b === void 0 ? void 0 : _b.extendPaths,
101
146
  ]
102
147
  .flat()
103
- .filter(Boolean);
148
+ .filter(utils_1.isTruthy);
104
149
  const pluginPaths = [
105
- ...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.lint) === null || _a === void 0 ? void 0 : _a.pluginPaths; }),
106
- (_d = (_c = config.rawConfig) === null || _c === void 0 ? void 0 : _c.lint) === null || _d === void 0 ? void 0 : _d.pluginPaths,
150
+ ...Object.values(config.apis).map((api) => { var _a; return (_a = api === null || api === void 0 ? void 0 : api.styleguide) === null || _a === void 0 ? void 0 : _a.pluginPaths; }),
151
+ (_d = (_c = config.rawConfig) === null || _c === void 0 ? void 0 : _c.styleguide) === null || _d === void 0 ? void 0 : _d.pluginPaths,
107
152
  ]
108
153
  .flat()
109
- .filter(Boolean);
110
- return entrypointAlias
111
- ? new config_1.Config(Object.assign(Object.assign({}, config.rawConfig), { lint: Object.assign(Object.assign({}, (config.apis[entrypointAlias]
112
- ? config.apis[entrypointAlias].lint
113
- : config.rawConfig.lint)), { extendPaths,
114
- pluginPaths }), 'features.openapi': Object.assign(Object.assign({}, config['features.openapi']), (_e = config.apis[entrypointAlias]) === null || _e === void 0 ? void 0 : _e['features.openapi']), 'features.mockServer': Object.assign(Object.assign({}, config['features.mockServer']), (_f = config.apis[entrypointAlias]) === null || _f === void 0 ? void 0 : _f['features.mockServer']) }), config.configFile)
154
+ .filter(utils_1.isTruthy);
155
+ return apiName
156
+ ? new config_1.Config(Object.assign(Object.assign({}, config.rawConfig), { styleguide: Object.assign(Object.assign({}, (config.apis[apiName]
157
+ ? config.apis[apiName].styleguide
158
+ : config.rawConfig.styleguide)), { extendPaths,
159
+ pluginPaths }), theme: Object.assign(Object.assign({}, config.rawConfig.theme), (_e = config.apis[apiName]) === null || _e === void 0 ? void 0 : _e.theme), files: [...config.files, ...((_h = (_g = (_f = config.apis) === null || _f === void 0 ? void 0 : _f[apiName]) === null || _g === void 0 ? void 0 : _g.files) !== null && _h !== void 0 ? _h : [])] }), config.configFile)
115
160
  : config;
116
161
  }
117
162
  exports.getMergedConfig = getMergedConfig;
118
- function transformConfig(rawConfig) {
119
- if (rawConfig.apis && rawConfig.apiDefinitions) {
120
- throw new Error("Do not use 'apiDefinitions' field. Use 'apis' instead.\n");
163
+ function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject) {
164
+ const isDeprecatedFieldInApis = rawConfig.apis &&
165
+ Object.values(rawConfig.apis).some((api) => api[deprecatedField]);
166
+ if (rawConfig[deprecatedField] && updatedField === null) {
167
+ utils_1.showWarningForDeprecatedField(deprecatedField);
121
168
  }
122
- if (rawConfig['features.openapi'] &&
123
- rawConfig.referenceDocs) {
124
- throw new Error("Do not use 'referenceDocs' field. Use 'features.openapi' instead.\n");
169
+ if (rawConfig[deprecatedField] && updatedField && rawConfig[updatedField]) {
170
+ utils_1.showErrorForDeprecatedField(deprecatedField, updatedField);
125
171
  }
126
- const _a = rawConfig, { apiDefinitions, referenceDocs } = _a, rest = __rest(_a, ["apiDefinitions", "referenceDocs"]);
127
- if (apiDefinitions) {
128
- process.stderr.write(`The ${colorette_1.yellow('apiDefinitions')} field is deprecated. Use ${colorette_1.green('apis')} instead. Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties\n`);
172
+ if (rawConfig[deprecatedField] && updatedObject && rawConfig[updatedObject]) {
173
+ utils_1.showErrorForDeprecatedField(deprecatedField, updatedField, updatedObject);
129
174
  }
130
- if (referenceDocs) {
131
- process.stderr.write(`The ${colorette_1.yellow('referenceDocs')} field is deprecated. Use ${colorette_1.green('features.openapi')} instead. Read more about this change: https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties\n`);
175
+ if (rawConfig[deprecatedField] || isDeprecatedFieldInApis) {
176
+ utils_1.showWarningForDeprecatedField(deprecatedField, updatedField, updatedObject);
132
177
  }
133
- return Object.assign({ 'features.openapi': referenceDocs, apis: transformApiDefinitionsToApis(apiDefinitions) }, rest);
178
+ }
179
+ exports.checkForDeprecatedFields = checkForDeprecatedFields;
180
+ function transformConfig(rawConfig) {
181
+ var _a, _b;
182
+ const migratedFields = [
183
+ ['apiDefinitions', 'apis', undefined],
184
+ ['referenceDocs', 'openapi', 'theme'],
185
+ ['lint', undefined, undefined],
186
+ ['styleguide', undefined, undefined],
187
+ ['features.openapi', 'openapi', 'theme'],
188
+ ];
189
+ for (const [deprecatedField, updatedField, updatedObject] of migratedFields) {
190
+ checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject);
191
+ }
192
+ const { apis, apiDefinitions, referenceDocs, lint } = rawConfig, rest = __rest(rawConfig, ["apis", "apiDefinitions", "referenceDocs", "lint"]);
193
+ const { styleguideConfig, rawConfigRest } = extractFlatConfig(rest);
194
+ const transformedConfig = Object.assign({ theme: {
195
+ openapi: Object.assign(Object.assign(Object.assign({}, referenceDocs), rawConfig['features.openapi']), (_a = rawConfig.theme) === null || _a === void 0 ? void 0 : _a.openapi),
196
+ mockServer: Object.assign(Object.assign({}, rawConfig['features.mockServer']), (_b = rawConfig.theme) === null || _b === void 0 ? void 0 : _b.mockServer),
197
+ }, apis: transformApis(apis) || transformApiDefinitionsToApis(apiDefinitions), styleguide: styleguideConfig || lint }, rawConfigRest);
198
+ showDeprecationMessages(transformedConfig);
199
+ return transformedConfig;
134
200
  }
135
201
  exports.transformConfig = transformConfig;
202
+ function showDeprecationMessages(config) {
203
+ var _a, _b;
204
+ let allRules = Object.assign({}, (_a = config.styleguide) === null || _a === void 0 ? void 0 : _a.rules);
205
+ for (const api of Object.values(config.apis || {})) {
206
+ allRules = Object.assign(Object.assign({}, allRules), (_b = api === null || api === void 0 ? void 0 : api.styleguide) === null || _b === void 0 ? void 0 : _b.rules);
207
+ }
208
+ for (const ruleKey of Object.keys(allRules)) {
209
+ if (ruleKey.startsWith('assert/')) {
210
+ logger_1.logger.warn(`\nThe 'assert/' syntax in ${ruleKey} is deprecated. Update your configuration to use 'rule/' instead. Examples and more information: https://redocly.com/docs/cli/rules/configurable-rules/\n`);
211
+ }
212
+ }
213
+ }
136
214
  function getResolveConfig(resolve) {
137
215
  var _a, _b;
138
216
  return {
@@ -152,7 +230,7 @@ function getUniquePlugins(plugins) {
152
230
  seen.add(p.id);
153
231
  }
154
232
  else if (p.id) {
155
- process.stderr.write(`Duplicate plugin id "${colorette_1.yellow(p.id)}".\n`);
233
+ logger_1.logger.warn(`Duplicate plugin id "${logger_1.colorize.red(p.id)}".\n`);
156
234
  }
157
235
  }
158
236
  return results;
@@ -0,0 +1,3 @@
1
+ import { UserContext } from '../../../walk';
2
+ export declare function filter(node: any, ctx: UserContext, criteria: (item: any) => boolean): void;
3
+ export declare function checkIfMatchByStrategy(nodeValue: any, decoratorValue: any, strategy: 'all' | 'any'): boolean;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIfMatchByStrategy = exports.filter = void 0;
4
+ const ref_utils_1 = require("../../../ref-utils");
5
+ const utils_1 = require("../../../utils");
6
+ function filter(node, ctx, criteria) {
7
+ const { parent, key } = ctx;
8
+ let didDelete = false;
9
+ if (Array.isArray(node)) {
10
+ for (let i = 0; i < node.length; i++) {
11
+ if (ref_utils_1.isRef(node[i])) {
12
+ const resolved = ctx.resolve(node[i]);
13
+ if (criteria(resolved.node)) {
14
+ node.splice(i, 1);
15
+ didDelete = true;
16
+ i--;
17
+ }
18
+ }
19
+ if (criteria(node[i])) {
20
+ node.splice(i, 1);
21
+ didDelete = true;
22
+ i--;
23
+ }
24
+ }
25
+ }
26
+ else if (utils_1.isPlainObject(node)) {
27
+ for (const key of Object.keys(node)) {
28
+ node = node;
29
+ if (ref_utils_1.isRef(node[key])) {
30
+ const resolved = ctx.resolve(node[key]);
31
+ if (criteria(resolved.node)) {
32
+ delete node[key];
33
+ didDelete = true;
34
+ }
35
+ }
36
+ if (criteria(node[key])) {
37
+ delete node[key];
38
+ didDelete = true;
39
+ }
40
+ }
41
+ }
42
+ if (didDelete && (utils_1.isEmptyObject(node) || utils_1.isEmptyArray(node))) {
43
+ delete parent[key];
44
+ }
45
+ }
46
+ exports.filter = filter;
47
+ function checkIfMatchByStrategy(nodeValue, decoratorValue, strategy) {
48
+ if (nodeValue === undefined || decoratorValue === undefined) {
49
+ return false;
50
+ }
51
+ if (!Array.isArray(decoratorValue) && !Array.isArray(nodeValue)) {
52
+ return nodeValue === decoratorValue;
53
+ }
54
+ decoratorValue = toArrayIfNeeded(decoratorValue);
55
+ nodeValue = toArrayIfNeeded(nodeValue);
56
+ if (strategy === 'any') {
57
+ return decoratorValue.some((item) => nodeValue.includes(item));
58
+ }
59
+ if (strategy === 'all') {
60
+ return decoratorValue.every((item) => nodeValue.includes(item));
61
+ }
62
+ return false;
63
+ }
64
+ exports.checkIfMatchByStrategy = checkIfMatchByStrategy;
65
+ function toArrayIfNeeded(value) {
66
+ return Array.isArray(value) ? value : [value];
67
+ }
@@ -0,0 +1,2 @@
1
+ import { Oas2Decorator, Oas3Decorator } from '../../../visitors';
2
+ export declare const FilterIn: Oas3Decorator | Oas2Decorator;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterIn = void 0;
4
+ const filter_helper_1 = require("./filter-helper");
5
+ const DEFAULT_STRATEGY = 'any';
6
+ const FilterIn = ({ property, value, matchStrategy }) => {
7
+ const strategy = matchStrategy || DEFAULT_STRATEGY;
8
+ const filterInCriteria = (item) => (item === null || item === void 0 ? void 0 : item[property]) && !filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
9
+ return {
10
+ any: {
11
+ enter: (node, ctx) => {
12
+ filter_helper_1.filter(node, ctx, filterInCriteria);
13
+ },
14
+ },
15
+ };
16
+ };
17
+ exports.FilterIn = FilterIn;
@@ -0,0 +1,2 @@
1
+ import { Oas2Decorator, Oas3Decorator } from '../../../visitors';
2
+ export declare const FilterOut: Oas3Decorator | Oas2Decorator;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterOut = void 0;
4
+ const filter_helper_1 = require("./filter-helper");
5
+ const DEFAULT_STRATEGY = 'any';
6
+ const FilterOut = ({ property, value, matchStrategy }) => {
7
+ const strategy = matchStrategy || DEFAULT_STRATEGY;
8
+ const filterOutCriteria = (item) => filter_helper_1.checkIfMatchByStrategy(item === null || item === void 0 ? void 0 : item[property], value, strategy);
9
+ return {
10
+ any: {
11
+ enter: (node, ctx) => {
12
+ filter_helper_1.filter(node, ctx, filterOutCriteria);
13
+ },
14
+ },
15
+ };
16
+ };
17
+ exports.FilterOut = FilterOut;
@@ -0,0 +1,2 @@
1
+ import { Oas3Decorator, Oas2Decorator } from '../../visitors';
2
+ export declare const InfoOverride: Oas3Decorator | Oas2Decorator;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.InfoOverride = void 0;
15
+ const InfoOverride = (newInfo) => {
16
+ return {
17
+ Info: {
18
+ leave(info) {
19
+ if (typeof newInfo !== 'object' || Array.isArray(newInfo) || newInfo === null) {
20
+ throw new Error(`"info-override" decorator should be called with an object`);
21
+ }
22
+ const { severity: _ } = newInfo, rest = __rest(newInfo, ["severity"]);
23
+ Object.assign(info, rest);
24
+ },
25
+ },
26
+ };
27
+ };
28
+ exports.InfoOverride = InfoOverride;
@@ -0,0 +1,2 @@
1
+ import { Oas3Decorator } from '../../visitors';
2
+ export declare const MediaTypeExamplesOverride: Oas3Decorator;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MediaTypeExamplesOverride = void 0;
4
+ const utils_1 = require("../../utils");
5
+ const ref_utils_1 = require("../../ref-utils");
6
+ const MediaTypeExamplesOverride = ({ operationIds }) => {
7
+ return {
8
+ Operation: {
9
+ enter(operation, ctx) {
10
+ const operationId = operation.operationId;
11
+ if (!operationId) {
12
+ return;
13
+ }
14
+ const properties = operationIds[operationId];
15
+ if (!properties) {
16
+ return;
17
+ }
18
+ if (properties.responses && operation.responses) {
19
+ for (const responseCode of Object.keys(properties.responses)) {
20
+ const resolvedResponse = checkAndResolveRef(operation.responses[responseCode], ctx.resolve);
21
+ if (!resolvedResponse) {
22
+ continue;
23
+ }
24
+ resolvedResponse.content = resolvedResponse.content ? resolvedResponse.content : {};
25
+ Object.keys(properties.responses[responseCode]).forEach((mimeType) => {
26
+ resolvedResponse.content[mimeType] = Object.assign(Object.assign({}, resolvedResponse.content[mimeType]), { examples: utils_1.yamlAndJsonSyncReader(properties.responses[responseCode][mimeType]) });
27
+ });
28
+ operation.responses[responseCode] = resolvedResponse;
29
+ }
30
+ }
31
+ if (properties.request && operation.requestBody) {
32
+ const resolvedRequest = checkAndResolveRef(operation.requestBody, ctx.resolve);
33
+ if (!resolvedRequest) {
34
+ return;
35
+ }
36
+ resolvedRequest.content = resolvedRequest.content ? resolvedRequest.content : {};
37
+ Object.keys(properties.request).forEach((mimeType) => {
38
+ resolvedRequest.content[mimeType] = Object.assign(Object.assign({}, resolvedRequest.content[mimeType]), { examples: utils_1.yamlAndJsonSyncReader(properties.request[mimeType]) });
39
+ });
40
+ operation.requestBody = resolvedRequest;
41
+ }
42
+ },
43
+ },
44
+ };
45
+ };
46
+ exports.MediaTypeExamplesOverride = MediaTypeExamplesOverride;
47
+ function checkAndResolveRef(node, resolver) {
48
+ if (!ref_utils_1.isRef(node)) {
49
+ return node;
50
+ }
51
+ const resolved = resolver(node);
52
+ return resolved.error ? undefined : JSON.parse(JSON.stringify(resolved.node));
53
+ }
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegistryDependencies = void 0;
4
4
  const redocly_1 = require("../../redocly");
5
5
  const RegistryDependencies = () => {
6
- let registryDependencies = new Set();
6
+ const registryDependencies = new Set();
7
7
  return {
8
- DefinitionRoot: {
8
+ Root: {
9
9
  leave(_, ctx) {
10
10
  const data = ctx.getVisitorData();
11
11
  data.links = Array.from(registryDependencies);
@@ -51,8 +51,8 @@ const RemoveXInternal = ({ internalFlagProperty }) => {
51
51
  any: {
52
52
  enter: (node, ctx) => {
53
53
  removeInternal(node, ctx);
54
- }
55
- }
54
+ },
55
+ },
56
56
  };
57
57
  };
58
58
  exports.RemoveXInternal = RemoveXInternal;
@@ -4,5 +4,8 @@ export declare const decorators: {
4
4
  'operation-description-override': Oas2Decorator;
5
5
  'tag-description-override': Oas2Decorator;
6
6
  'info-description-override': Oas2Decorator;
7
+ 'info-override': Oas2Decorator;
7
8
  'remove-x-internal': Oas2Decorator;
9
+ 'filter-in': Oas2Decorator;
10
+ 'filter-out': Oas2Decorator;
8
11
  };
@@ -5,11 +5,17 @@ const registry_dependencies_1 = require("../common/registry-dependencies");
5
5
  const operation_description_override_1 = require("../common/operation-description-override");
6
6
  const tag_description_override_1 = require("../common/tag-description-override");
7
7
  const info_description_override_1 = require("../common/info-description-override");
8
+ const info_override_1 = require("../common/info-override");
8
9
  const remove_x_internal_1 = require("../common/remove-x-internal");
10
+ const filter_in_1 = require("../common/filters/filter-in");
11
+ const filter_out_1 = require("../common/filters/filter-out");
9
12
  exports.decorators = {
10
13
  'registry-dependencies': registry_dependencies_1.RegistryDependencies,
11
14
  'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
12
15
  'tag-description-override': tag_description_override_1.TagDescriptionOverride,
13
16
  'info-description-override': info_description_override_1.InfoDescriptionOverride,
14
- 'remove-x-internal': remove_x_internal_1.RemoveXInternal
17
+ 'info-override': info_override_1.InfoOverride,
18
+ 'remove-x-internal': remove_x_internal_1.RemoveXInternal,
19
+ 'filter-in': filter_in_1.FilterIn,
20
+ 'filter-out': filter_out_1.FilterOut,
15
21
  };
@@ -4,5 +4,9 @@ export declare const decorators: {
4
4
  'operation-description-override': Oas3Decorator;
5
5
  'tag-description-override': Oas3Decorator;
6
6
  'info-description-override': Oas3Decorator;
7
+ 'info-override': Oas3Decorator;
7
8
  'remove-x-internal': Oas3Decorator;
9
+ 'filter-in': Oas3Decorator;
10
+ 'filter-out': Oas3Decorator;
11
+ 'media-type-examples-override': Oas3Decorator;
8
12
  };
@@ -5,11 +5,19 @@ const registry_dependencies_1 = require("../common/registry-dependencies");
5
5
  const operation_description_override_1 = require("../common/operation-description-override");
6
6
  const tag_description_override_1 = require("../common/tag-description-override");
7
7
  const info_description_override_1 = require("../common/info-description-override");
8
+ const info_override_1 = require("../common/info-override");
8
9
  const remove_x_internal_1 = require("../common/remove-x-internal");
10
+ const filter_in_1 = require("../common/filters/filter-in");
11
+ const filter_out_1 = require("../common/filters/filter-out");
12
+ const media_type_examples_override_1 = require("../common/media-type-examples-override");
9
13
  exports.decorators = {
10
14
  'registry-dependencies': registry_dependencies_1.RegistryDependencies,
11
15
  'operation-description-override': operation_description_override_1.OperationDescriptionOverride,
12
16
  'tag-description-override': tag_description_override_1.TagDescriptionOverride,
13
17
  'info-description-override': info_description_override_1.InfoDescriptionOverride,
14
- 'remove-x-internal': remove_x_internal_1.RemoveXInternal
18
+ 'info-override': info_override_1.InfoOverride,
19
+ 'remove-x-internal': remove_x_internal_1.RemoveXInternal,
20
+ 'filter-in': filter_in_1.FilterIn,
21
+ 'filter-out': filter_out_1.FilterOut,
22
+ 'media-type-examples-override': media_type_examples_override_1.MediaTypeExamplesOverride,
15
23
  };
package/lib/env.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /// <reference types="node" />
2
+ export declare const isBrowser: boolean;
3
+ export declare const env: NodeJS.ProcessEnv;
package/lib/env.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.env = exports.isBrowser = void 0;
4
+ exports.isBrowser =
5
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
+ // @ts-ignore
7
+ typeof window !== 'undefined' || typeof self !== 'undefined' || typeof process === 'undefined'; // main and worker thread
8
+ exports.env = exports.isBrowser ? {} : process.env || {};
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAstNodeByPointer = exports.getLineColLocation = exports.getCodeframe = void 0;
4
- const colorette_1 = require("colorette");
5
4
  const yamlAst = require("yaml-ast-parser");
6
5
  const ref_utils_1 = require("../ref-utils");
6
+ const logger_1 = require("../logger");
7
7
  const MAX_LINE_LENGTH = 150;
8
8
  const MAX_CODEFRAME_LINES = 3;
9
9
  // TODO: temporary
@@ -11,7 +11,7 @@ function parsePointer(pointer) {
11
11
  return pointer.substr(2).split('/').map(ref_utils_1.unescapePointer);
12
12
  }
13
13
  function getCodeframe(location, color) {
14
- colorette_1.options.enabled = color;
14
+ logger_1.colorOptions.enabled = color;
15
15
  const { start, end = { line: start.line, col: start.col + 1 }, source } = location;
16
16
  const lines = source.getLines();
17
17
  const startLineNum = start.line;
@@ -28,16 +28,22 @@ function getCodeframe(location, color) {
28
28
  const line = lines[i - 1] || '';
29
29
  if (line !== '')
30
30
  currentPad = padSize(line);
31
- let startIdx = i === startLineNum ? start.col - 1 : currentPad;
32
- let endIdx = i === endLineNum ? end.col - 1 : line.length;
33
- prefixedLines.push([`${i}`, markLine(line, startIdx, endIdx, colorette_1.red)]);
31
+ const startIdx = i === startLineNum ? start.col - 1 : currentPad;
32
+ const endIdx = i === endLineNum ? end.col - 1 : line.length;
33
+ prefixedLines.push([`${i}`, markLine(line, startIdx, endIdx, logger_1.colorize.red)]);
34
34
  if (!color)
35
35
  prefixedLines.push(['', underlineLine(line, startIdx, endIdx)]);
36
36
  }
37
37
  if (skipLines > 0) {
38
- prefixedLines.push([`…`, `${whitespace(currentPad)}${colorette_1.gray(`< ${skipLines} more lines >`)}`]);
38
+ prefixedLines.push([
39
+ `…`,
40
+ `${whitespace(currentPad)}${logger_1.colorize.gray(`< ${skipLines} more lines >`)}`,
41
+ ]);
39
42
  // print last line
40
- prefixedLines.push([`${endLineNum}`, markLine(lines[endLineNum - 1], -1, end.col - 1, colorette_1.red)]);
43
+ prefixedLines.push([
44
+ `${endLineNum}`,
45
+ markLine(lines[endLineNum - 1], -1, end.col - 1, logger_1.colorize.red),
46
+ ]);
41
47
  if (!color)
42
48
  prefixedLines.push(['', underlineLine(lines[endLineNum - 1], -1, end.col - 1)]);
43
49
  }
@@ -48,7 +54,7 @@ function getCodeframe(location, color) {
48
54
  [`${endLineNum + 1}`, markLine(lines[endLineNum - 1 + 1])],
49
55
  [`${endLineNum + 2}`, markLine(lines[endLineNum - 1 + 2])],
50
56
  ]);
51
- function markLine(line, startIdx = -1, endIdx = +Infinity, variant = colorette_1.gray) {
57
+ function markLine(line, startIdx = -1, endIdx = +Infinity, variant = logger_1.colorize.gray) {
52
58
  if (!color)
53
59
  return line;
54
60
  if (!line)
@@ -66,14 +72,14 @@ function printPrefixedLines(lines) {
66
72
  const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length));
67
73
  const dedentLen = Math.min(...existingLines.map(([_, line]) => (line === '' ? Infinity : padSize(line))));
68
74
  return existingLines
69
- .map(([prefix, line]) => colorette_1.gray(leftPad(padLen, prefix) + ' |') +
75
+ .map(([prefix, line]) => logger_1.colorize.gray(leftPad(padLen, prefix) + ' |') +
70
76
  (line ? ' ' + limitLineLength(line.substring(dedentLen)) : ''))
71
77
  .join('\n');
72
78
  }
73
79
  function limitLineLength(line, maxLen = MAX_LINE_LENGTH) {
74
80
  const overflowLen = line.length - maxLen;
75
81
  if (overflowLen > 0) {
76
- const charsMoreText = colorette_1.gray(`...<${overflowLen} chars>`);
82
+ const charsMoreText = logger_1.colorize.gray(`...<${overflowLen} chars>`);
77
83
  return line.substring(0, maxLen - charsMoreText.length) + charsMoreText;
78
84
  }
79
85
  else {
@@ -4,7 +4,7 @@ export declare type Totals = {
4
4
  warnings: number;
5
5
  ignored: number;
6
6
  };
7
- export declare type OutputFormat = 'codeframe' | 'stylish' | 'json' | 'checkstyle' | 'codeclimate';
7
+ export declare type OutputFormat = 'codeframe' | 'stylish' | 'json' | 'checkstyle' | 'codeclimate' | 'summary';
8
8
  export declare function getTotals(problems: (NormalizedProblem & {
9
9
  ignored?: boolean;
10
10
  })[]): Totals;