@redocly/openapi-core 1.2.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/benchmark/benches/lint-with-many-rules.bench.js +4 -4
  3. package/lib/benchmark/benches/lint-with-nested-rule.bench.js +4 -4
  4. package/lib/benchmark/benches/lint-with-no-rules.bench.js +4 -4
  5. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +4 -4
  6. package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +4 -4
  7. package/lib/benchmark/benches/recommended-oas3.bench.js +4 -4
  8. package/lib/benchmark/benches/resolve-with-no-external.bench.js +3 -3
  9. package/lib/benchmark/utils.js +3 -3
  10. package/lib/bundle.d.ts +4 -4
  11. package/lib/bundle.js +23 -23
  12. package/lib/config/all.d.ts +2 -2
  13. package/lib/config/all.js +44 -8
  14. package/lib/config/builtIn.js +2 -0
  15. package/lib/config/config-resolvers.js +25 -25
  16. package/lib/config/config.js +9 -9
  17. package/lib/config/index.js +5 -1
  18. package/lib/config/load.d.ts +1 -1
  19. package/lib/config/load.js +9 -6
  20. package/lib/config/minimal.d.ts +2 -2
  21. package/lib/config/minimal.js +34 -3
  22. package/lib/config/recommended-strict.d.ts +3 -0
  23. package/lib/config/recommended-strict.js +92 -0
  24. package/lib/config/recommended.d.ts +2 -2
  25. package/lib/config/recommended.js +34 -3
  26. package/lib/config/rules.d.ts +1 -1
  27. package/lib/config/types.d.ts +47 -46
  28. package/lib/config/types.js +2 -2
  29. package/lib/config/utils.d.ts +2 -0
  30. package/lib/config/utils.js +30 -15
  31. package/lib/decorators/common/filters/filter-helper.js +4 -4
  32. package/lib/decorators/common/filters/filter-in.js +2 -2
  33. package/lib/decorators/common/filters/filter-out.js +2 -2
  34. package/lib/decorators/common/info-description-override.js +1 -1
  35. package/lib/decorators/common/media-type-examples-override.js +3 -3
  36. package/lib/decorators/common/operation-description-override.js +1 -1
  37. package/lib/decorators/common/registry-dependencies.js +1 -1
  38. package/lib/decorators/common/remove-x-internal.js +4 -4
  39. package/lib/decorators/common/tag-description-override.js +1 -1
  40. package/lib/format/codeframes.d.ts +6 -6
  41. package/lib/format/format.d.ts +2 -2
  42. package/lib/format/format.js +12 -12
  43. package/lib/js-yaml/index.d.ts +2 -2
  44. package/lib/js-yaml/index.js +2 -2
  45. package/lib/lint.js +18 -18
  46. package/lib/oas-types.d.ts +12 -10
  47. package/lib/oas-types.js +2 -2
  48. package/lib/redocly/index.js +10 -10
  49. package/lib/redocly/registry-api.js +2 -2
  50. package/lib/resolve.d.ts +4 -4
  51. package/lib/resolve.js +18 -18
  52. package/lib/rules/ajv.js +1 -1
  53. package/lib/rules/async2/index.d.ts +2 -11
  54. package/lib/rules/common/assertions/asserts.d.ts +3 -3
  55. package/lib/rules/common/assertions/asserts.js +21 -21
  56. package/lib/rules/common/assertions/index.d.ts +4 -4
  57. package/lib/rules/common/assertions/index.js +3 -3
  58. package/lib/rules/common/assertions/utils.d.ts +4 -4
  59. package/lib/rules/common/assertions/utils.js +3 -3
  60. package/lib/rules/common/info-contact.js +1 -1
  61. package/lib/rules/common/info-license-url.js +1 -1
  62. package/lib/rules/common/info-license.js +1 -1
  63. package/lib/rules/common/no-enum-type-mismatch.js +3 -3
  64. package/lib/rules/common/no-http-verbs-in-paths.js +2 -2
  65. package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
  66. package/lib/rules/common/no-invalid-schema-examples.js +3 -3
  67. package/lib/rules/common/operation-2xx-response.js +2 -2
  68. package/lib/rules/common/operation-4xx-response.js +2 -2
  69. package/lib/rules/common/operation-description.js +1 -1
  70. package/lib/rules/common/operation-operationId.js +1 -1
  71. package/lib/rules/common/operation-summary.js +1 -1
  72. package/lib/rules/common/path-segment-plural.js +1 -1
  73. package/lib/rules/common/response-contains-header.js +2 -2
  74. package/lib/rules/common/spec-strict-refs.js +1 -1
  75. package/lib/rules/common/spec.js +11 -11
  76. package/lib/rules/common/tag-description.js +1 -1
  77. package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +1 -1
  78. package/lib/rules/oas2/index.d.ts +2 -46
  79. package/lib/rules/oas2/remove-unused-components.js +1 -1
  80. package/lib/rules/oas2/request-mime-type.js +2 -2
  81. package/lib/rules/oas2/response-contains-property.js +2 -2
  82. package/lib/rules/oas2/response-mime-type.js +2 -2
  83. package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +1 -1
  84. package/lib/rules/oas3/index.d.ts +1 -1
  85. package/lib/rules/oas3/index.js +1 -1
  86. package/lib/rules/oas3/no-invalid-media-type-examples.js +3 -3
  87. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +3 -3
  88. package/lib/rules/oas3/remove-unused-components.js +2 -2
  89. package/lib/rules/oas3/request-mime-type.js +3 -3
  90. package/lib/rules/oas3/response-contains-property.js +2 -2
  91. package/lib/rules/oas3/response-mime-type.js +3 -3
  92. package/lib/rules/utils.js +3 -3
  93. package/lib/types/asyncapi.js +21 -21
  94. package/lib/types/index.d.ts +8 -8
  95. package/lib/types/oas2.js +14 -14
  96. package/lib/types/oas3.js +27 -27
  97. package/lib/types/oas3_1.js +6 -6
  98. package/lib/types/redocly-yaml.d.ts +11 -0
  99. package/lib/types/redocly-yaml.js +71 -53
  100. package/lib/types/theme-config.js +1 -1
  101. package/lib/typings/common.d.ts +2 -2
  102. package/lib/typings/openapi.d.ts +6 -6
  103. package/lib/typings/swagger.d.ts +3 -3
  104. package/lib/utils.d.ts +5 -5
  105. package/lib/utils.js +3 -3
  106. package/lib/visitors.d.ts +40 -40
  107. package/lib/walk.d.ts +14 -15
  108. package/lib/walk.js +11 -11
  109. package/package.json +2 -2
  110. package/src/__tests__/lint.test.ts +40 -40
  111. package/src/__tests__/normalizeVisitors.test.ts +23 -5
  112. package/src/__tests__/ref-utils.test.ts +7 -7
  113. package/src/__tests__/resolve-http.test.ts +10 -10
  114. package/src/__tests__/resolve.test.ts +39 -39
  115. package/src/__tests__/walk.test.ts +48 -48
  116. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +95 -32
  117. package/src/config/__tests__/__snapshots__/config.test.ts.snap +81 -81
  118. package/src/config/__tests__/config-resolvers.test.ts +30 -1
  119. package/src/config/__tests__/config.test.ts +88 -88
  120. package/src/config/__tests__/load.test.ts +12 -8
  121. package/src/config/__tests__/utils.test.ts +18 -18
  122. package/src/config/all.ts +46 -9
  123. package/src/config/builtIn.ts +2 -0
  124. package/src/config/load.ts +4 -1
  125. package/src/config/minimal.ts +36 -4
  126. package/src/config/recommended-strict.ts +93 -0
  127. package/src/config/recommended.ts +36 -4
  128. package/src/config/types.ts +22 -8
  129. package/src/config/utils.ts +17 -0
  130. package/src/decorators/common/media-type-examples-override.ts +2 -2
  131. package/src/lint.ts +3 -3
  132. package/src/oas-types.ts +26 -3
  133. package/src/rules/__tests__/no-unresolved-refs.test.ts +26 -26
  134. package/src/rules/async2/__tests__/channels-kebab-case.test.ts +12 -12
  135. package/src/rules/async2/__tests__/no-channel-trailing-slash.test.ts +7 -7
  136. package/src/rules/async2/index.ts +2 -1
  137. package/src/rules/common/__tests__/info-license.test.ts +6 -6
  138. package/src/rules/common/__tests__/license-url.test.ts +6 -6
  139. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +13 -13
  140. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +18 -18
  141. package/src/rules/common/__tests__/no-identical-paths.test.ts +5 -5
  142. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +12 -12
  143. package/src/rules/common/__tests__/operation-2xx-response.test.ts +18 -18
  144. package/src/rules/common/__tests__/operation-4xx-response.test.ts +23 -23
  145. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +6 -6
  146. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +5 -5
  147. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +16 -16
  148. package/src/rules/common/__tests__/operation-singular-tag.test.ts +6 -6
  149. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +10 -10
  150. package/src/rules/common/__tests__/path-not-include-query.test.ts +6 -6
  151. package/src/rules/common/__tests__/path-params-defined.test.ts +21 -21
  152. package/src/rules/common/__tests__/paths-kebab-case.test.ts +11 -11
  153. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +18 -18
  154. package/src/rules/common/__tests__/security-defined.test.ts +21 -21
  155. package/src/rules/common/__tests__/spec-strict-refs.test.ts +9 -9
  156. package/src/rules/common/__tests__/spec.test.ts +102 -102
  157. package/src/rules/common/__tests__/tag-description.test.ts +6 -6
  158. package/src/rules/common/__tests__/tags-alphabetical.test.ts +12 -12
  159. package/src/rules/common/assertions/__tests__/index.test.ts +15 -15
  160. package/src/rules/common/assertions/__tests__/utils.test.ts +9 -9
  161. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +7 -7
  162. package/src/rules/oas2/__tests__/response-contains-header.test.ts +13 -13
  163. package/src/rules/oas2/__tests__/response-contains-property.test.ts +8 -8
  164. package/src/rules/oas2/__tests__/spec/info.test.ts +21 -21
  165. package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
  166. package/src/rules/oas2/__tests__/spec/paths.test.ts +12 -12
  167. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +1 -1
  168. package/src/rules/oas2/index.ts +3 -1
  169. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +7 -7
  170. package/src/rules/oas3/__tests__/component-name-unique.test.ts +186 -186
  171. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +18 -18
  172. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +6 -6
  173. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +36 -36
  174. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +11 -11
  175. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +7 -7
  176. package/src/rules/oas3/__tests__/no-unused-components.test.ts +31 -31
  177. package/src/rules/oas3/__tests__/operation-4xx-problem-details-rfc7807.test.ts +15 -15
  178. package/src/rules/oas3/__tests__/response-contains-header.test.ts +26 -26
  179. package/src/rules/oas3/__tests__/response-contains-property.test.ts +27 -27
  180. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
  181. package/src/rules/oas3/__tests__/spec/info.test.ts +21 -21
  182. package/src/rules/oas3/__tests__/spec/operation.test.ts +10 -10
  183. package/src/rules/oas3/__tests__/spec/paths.test.ts +13 -13
  184. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +2 -2
  185. package/src/rules/oas3/__tests__/spec/servers.test.ts +25 -25
  186. package/src/rules/oas3/__tests__/spec/spec.test.ts +56 -56
  187. package/src/rules/oas3/__tests__/spec-components-invalid-map-name.test.ts +28 -28
  188. package/src/rules/oas3/index.ts +3 -3
  189. package/src/types/redocly-yaml.ts +75 -40
  190. package/src/visitors.ts +3 -3
  191. package/src/walk.ts +23 -10
  192. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @redocly/openapi-core
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `recommended-strict` ruleset which uses the same rules as `recommended` but with the severity level set to `error` for all rules.
8
+
9
+ ## 1.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Added the possibility to configure the linting severity level of the configuration file for all CLI commands.
14
+ Redocly CLI will exit with an error if there are any issues with the configuration file, and the severity is set to `error`.
15
+
3
16
  ## 1.2.1
4
17
 
5
18
  ### Patch Changes
@@ -8,8 +8,8 @@ const resolve_1 = require("../../resolve");
8
8
  const utils_1 = require("../utils");
9
9
  exports.name = 'Validate with 50 top-level rules';
10
10
  exports.count = 10;
11
- const rebillyDefinitionRef = path_1.resolve(path_1.join(__dirname, 'rebilly.yaml'));
12
- const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
11
+ const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml'));
12
+ const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
13
  const ruleset = {};
14
14
  for (let i = 0; i < 50; i++) {
15
15
  ruleset['rule-' + i] = () => {
@@ -23,9 +23,9 @@ for (let i = 0; i < 50; i++) {
23
23
  };
24
24
  };
25
25
  }
26
- const config = utils_1.makeConfigForRuleset(ruleset);
26
+ const config = (0, utils_1.makeConfigForRuleset)(ruleset);
27
27
  function measureAsync() {
28
- return lint_1.lintDocument({
28
+ return (0, lint_1.lintDocument)({
29
29
  externalRefResolver: new resolve_1.BaseResolver(),
30
30
  document: rebillyDocument,
31
31
  config,
@@ -8,8 +8,8 @@ const resolve_1 = require("../../resolve");
8
8
  const utils_1 = require("../utils");
9
9
  exports.name = 'Validate with single nested rule';
10
10
  exports.count = 10;
11
- const rebillyDefinitionRef = path_1.resolve(path_1.join(__dirname, 'rebilly.yaml'));
12
- const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
11
+ const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml'));
12
+ const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
13
  const visitor = {
14
14
  test: () => {
15
15
  let count = 0;
@@ -29,9 +29,9 @@ const visitor = {
29
29
  };
30
30
  },
31
31
  };
32
- const config = utils_1.makeConfigForRuleset(visitor);
32
+ const config = (0, utils_1.makeConfigForRuleset)(visitor);
33
33
  function measureAsync() {
34
- return lint_1.lintDocument({
34
+ return (0, lint_1.lintDocument)({
35
35
  externalRefResolver: new resolve_1.BaseResolver(),
36
36
  document: rebillyDocument,
37
37
  config,
@@ -8,11 +8,11 @@ const resolve_1 = require("../../resolve");
8
8
  const utils_1 = require("../utils");
9
9
  exports.name = 'Validate with no rules';
10
10
  exports.count = 10;
11
- const rebillyDefinitionRef = path_1.resolve(path_1.join(__dirname, 'rebilly.yaml'));
12
- const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
- const config = utils_1.makeConfigForRuleset({});
11
+ const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml'));
12
+ const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
+ const config = (0, utils_1.makeConfigForRuleset)({});
14
14
  function measureAsync() {
15
- return lint_1.lintDocument({
15
+ return (0, lint_1.lintDocument)({
16
16
  externalRefResolver: new resolve_1.BaseResolver(),
17
17
  document: rebillyDocument,
18
18
  config,
@@ -8,9 +8,9 @@ const resolve_1 = require("../../resolve");
8
8
  const utils_1 = require("../utils");
9
9
  exports.name = 'Validate with single top-level rule and report';
10
10
  exports.count = 10;
11
- const rebillyDefinitionRef = path_1.resolve(path_1.join(__dirname, 'rebilly.yaml'));
12
- const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
- const config = utils_1.makeConfigForRuleset({
11
+ const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml'));
12
+ const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
+ const config = (0, utils_1.makeConfigForRuleset)({
14
14
  test: () => {
15
15
  return {
16
16
  Schema(schema, ctx) {
@@ -24,7 +24,7 @@ const config = utils_1.makeConfigForRuleset({
24
24
  },
25
25
  });
26
26
  function measureAsync() {
27
- return lint_1.lintDocument({
27
+ return (0, lint_1.lintDocument)({
28
28
  externalRefResolver: new resolve_1.BaseResolver(),
29
29
  document: rebillyDocument,
30
30
  config,
@@ -8,9 +8,9 @@ const resolve_1 = require("../../resolve");
8
8
  const utils_1 = require("../utils");
9
9
  exports.name = 'Validate with single top-level rule';
10
10
  exports.count = 10;
11
- const rebillyDefinitionRef = path_1.resolve(path_1.join(__dirname, 'rebilly.yaml'));
12
- const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
- const config = utils_1.makeConfigForRuleset({
11
+ const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml'));
12
+ const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
+ const config = (0, utils_1.makeConfigForRuleset)({
14
14
  test: () => {
15
15
  let count = 0;
16
16
  return {
@@ -23,7 +23,7 @@ const config = utils_1.makeConfigForRuleset({
23
23
  },
24
24
  });
25
25
  function measureAsync() {
26
- return lint_1.lintDocument({
26
+ return (0, lint_1.lintDocument)({
27
27
  externalRefResolver: new resolve_1.BaseResolver(),
28
28
  document: rebillyDocument,
29
29
  config,
@@ -9,13 +9,13 @@ const resolve_1 = require("../../resolve");
9
9
  const utils_1 = require("../utils");
10
10
  exports.name = 'Validate with recommended rules';
11
11
  exports.count = 10;
12
- const rebillyDefinitionRef = path_1.resolve(path_1.join(__dirname, 'rebilly.yaml'));
13
- const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
12
+ const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml'));
13
+ const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
14
14
  function measureAsync() {
15
- return lint_1.lintDocument({
15
+ return (0, lint_1.lintDocument)({
16
16
  externalRefResolver: new resolve_1.BaseResolver(),
17
17
  document: rebillyDocument,
18
- config: new config_1.StyleguideConfig(config_1.resolvePreset('recommended', [config_1.defaultPlugin])),
18
+ config: new config_1.StyleguideConfig((0, config_1.resolvePreset)('recommended', [config_1.defaultPlugin])),
19
19
  });
20
20
  }
21
21
  exports.measureAsync = measureAsync;
@@ -10,13 +10,13 @@ const types_1 = require("../../types");
10
10
  exports.name = 'Resolve with no external refs';
11
11
  exports.count = 10;
12
12
  const rebillyDefinitionRef = path.resolve(path.join(__dirname, 'rebilly.yaml'));
13
- const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
13
+ const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef);
14
14
  const externalRefResolver = new resolve_1.BaseResolver();
15
15
  function measureAsync() {
16
- return resolve_1.resolveDocument({
16
+ return (0, resolve_1.resolveDocument)({
17
17
  rootDocument: rebillyDocument,
18
18
  externalRefResolver,
19
- rootType: types_1.normalizeTypes(oas3_1.Oas3Types).Root,
19
+ rootType: (0, types_1.normalizeTypes)(oas3_1.Oas3Types).Root,
20
20
  });
21
21
  }
22
22
  exports.measureAsync = measureAsync;
@@ -7,7 +7,7 @@ const config_1 = require("../config");
7
7
  function parseYamlToDocument(body, absoluteRef = '') {
8
8
  return {
9
9
  source: new resolve_1.Source(absoluteRef, body),
10
- parsed: js_yaml_1.parseYaml(body, { filename: absoluteRef }),
10
+ parsed: (0, js_yaml_1.parseYaml)(body, { filename: absoluteRef }),
11
11
  };
12
12
  }
13
13
  exports.parseYamlToDocument = parseYamlToDocument;
@@ -18,14 +18,14 @@ function makeConfigForRuleset(rules, plugin) {
18
18
  rulesConf[`${ruleId}/${name}`] = 'error';
19
19
  });
20
20
  const extendConfigs = [
21
- config_1.resolvePlugins([
21
+ (0, config_1.resolvePlugins)([
22
22
  Object.assign(Object.assign({}, plugin), { id: ruleId, rules: { oas3: rules } }),
23
23
  ]),
24
24
  ];
25
25
  if (rules) {
26
26
  extendConfigs.push({ rules });
27
27
  }
28
- const styleguide = config_1.mergeExtends(extendConfigs);
28
+ const styleguide = (0, config_1.mergeExtends)(extendConfigs);
29
29
  return new config_1.StyleguideConfig(styleguide);
30
30
  }
31
31
  exports.makeConfigForRuleset = makeConfigForRuleset;
package/lib/bundle.d.ts CHANGED
@@ -4,13 +4,13 @@ import { NormalizedNodeType, NodeType } from './types';
4
4
  import { NormalizedProblem } from './walk';
5
5
  import { SpecMajorVersion } from './oas-types';
6
6
  import type { Config, StyleguideConfig } from './config';
7
- export declare type Oas3RuleSet = Record<string, Oas3Rule>;
7
+ export type Oas3RuleSet = Record<string, Oas3Rule>;
8
8
  export declare enum OasVersion {
9
9
  Version2 = "oas2",
10
10
  Version3_0 = "oas3_0",
11
11
  Version3_1 = "oas3_1"
12
12
  }
13
- export declare type BundleOptions = {
13
+ export type BundleOptions = {
14
14
  externalRefResolver?: BaseResolver;
15
15
  config: Config;
16
16
  dereference?: boolean;
@@ -27,7 +27,7 @@ export declare function bundleFromString(opts: {
27
27
  source: string;
28
28
  absoluteRef?: string;
29
29
  } & BundleOptions): Promise<BundleResult>;
30
- export declare type BundleResult = {
30
+ export type BundleResult = {
31
31
  bundle: Document;
32
32
  problems: NormalizedProblem[];
33
33
  fileDependencies: Set<string>;
@@ -45,4 +45,4 @@ export declare function bundleDocument(opts: {
45
45
  removeUnusedComponents?: boolean;
46
46
  keepUrlRefs?: boolean;
47
47
  }): Promise<BundleResult>;
48
- export declare function mapTypeToComponent(typeName: string, version: SpecMajorVersion): "responses" | "parameters" | "examples" | "headers" | "schemas" | "requestBodies" | "securitySchemes" | "links" | "callbacks" | "definitions" | null;
48
+ export declare function mapTypeToComponent(typeName: string, version: SpecMajorVersion): "responses" | "links" | "parameters" | "examples" | "headers" | "schemas" | "requestBodies" | "securitySchemes" | "callbacks" | "definitions" | null;
package/lib/bundle.js CHANGED
@@ -28,7 +28,7 @@ var OasVersion;
28
28
  OasVersion["Version2"] = "oas2";
29
29
  OasVersion["Version3_0"] = "oas3_0";
30
30
  OasVersion["Version3_1"] = "oas3_1";
31
- })(OasVersion = exports.OasVersion || (exports.OasVersion = {}));
31
+ })(OasVersion || (exports.OasVersion = OasVersion = {}));
32
32
  function bundle(opts) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
34
  const { ref, doc, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve), base = null, } = opts;
@@ -46,7 +46,7 @@ exports.bundle = bundle;
46
46
  function bundleFromString(opts) {
47
47
  return __awaiter(this, void 0, void 0, function* () {
48
48
  const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
49
- const document = resolve_1.makeDocumentFromString(source, absoluteRef || '/');
49
+ const document = (0, resolve_1.makeDocumentFromString)(source, absoluteRef || '/');
50
50
  return bundleDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
51
51
  });
52
52
  }
@@ -54,12 +54,12 @@ exports.bundleFromString = bundleFromString;
54
54
  function bundleDocument(opts) {
55
55
  return __awaiter(this, void 0, void 0, function* () {
56
56
  const { document, config, customTypes, externalRefResolver, dereference = false, skipRedoclyRegistryRefs = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts;
57
- const specVersion = oas_types_1.detectSpec(document.parsed);
58
- const specMajorVersion = oas_types_1.getMajorSpecVersion(specVersion);
57
+ const specVersion = (0, oas_types_1.detectSpec)(document.parsed);
58
+ const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion);
59
59
  const rules = config.getRulesForOasVersion(specMajorVersion);
60
- const types = types_1.normalizeTypes(config.extendTypes(customTypes !== null && customTypes !== void 0 ? customTypes : oas_types_1.getTypes(specVersion), specVersion), config);
61
- const preprocessors = rules_1.initRules(rules, config, 'preprocessors', specVersion);
62
- const decorators = rules_1.initRules(rules, config, 'decorators', specVersion);
60
+ const types = (0, types_1.normalizeTypes)(config.extendTypes(customTypes !== null && customTypes !== void 0 ? customTypes : (0, oas_types_1.getTypes)(specVersion), specVersion), config);
61
+ const preprocessors = (0, rules_1.initRules)(rules, config, 'preprocessors', specVersion);
62
+ const decorators = (0, rules_1.initRules)(rules, config, 'decorators', specVersion);
63
63
  const ctx = {
64
64
  problems: [],
65
65
  oasVersion: specVersion,
@@ -71,31 +71,31 @@ function bundleDocument(opts) {
71
71
  severity: 'error',
72
72
  ruleId: 'remove-unused-components',
73
73
  visitor: specMajorVersion === oas_types_1.SpecMajorVersion.OAS2
74
- ? remove_unused_components_1.RemoveUnusedComponents({})
75
- : remove_unused_components_2.RemoveUnusedComponents({}),
74
+ ? (0, remove_unused_components_1.RemoveUnusedComponents)({})
75
+ : (0, remove_unused_components_2.RemoveUnusedComponents)({}),
76
76
  });
77
77
  }
78
- let resolvedRefMap = yield resolve_1.resolveDocument({
78
+ let resolvedRefMap = yield (0, resolve_1.resolveDocument)({
79
79
  rootDocument: document,
80
80
  rootType: types.Root,
81
81
  externalRefResolver,
82
82
  });
83
83
  if (preprocessors.length > 0) {
84
84
  // Make additional pass to resolve refs defined in preprocessors.
85
- walk_1.walkDocument({
85
+ (0, walk_1.walkDocument)({
86
86
  document,
87
87
  rootType: types.Root,
88
- normalizedVisitors: visitors_1.normalizeVisitors(preprocessors, types),
88
+ normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types),
89
89
  resolvedRefMap,
90
90
  ctx,
91
91
  });
92
- resolvedRefMap = yield resolve_1.resolveDocument({
92
+ resolvedRefMap = yield (0, resolve_1.resolveDocument)({
93
93
  rootDocument: document,
94
94
  rootType: types.Root,
95
95
  externalRefResolver,
96
96
  });
97
97
  }
98
- const bundleVisitor = visitors_1.normalizeVisitors([
98
+ const bundleVisitor = (0, visitors_1.normalizeVisitors)([
99
99
  {
100
100
  severity: 'error',
101
101
  ruleId: 'bundler',
@@ -103,7 +103,7 @@ function bundleDocument(opts) {
103
103
  },
104
104
  ...decorators,
105
105
  ], types);
106
- walk_1.walkDocument({
106
+ (0, walk_1.walkDocument)({
107
107
  document,
108
108
  rootType: types.Root,
109
109
  normalizedVisitors: bundleVisitor,
@@ -177,7 +177,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
177
177
  ref: {
178
178
  leave(node, ctx, resolved) {
179
179
  if (!resolved.location || resolved.node === undefined) {
180
- no_unresolved_refs_1.reportUnresolvedRef(resolved, ctx.report, ctx.location);
180
+ (0, no_unresolved_refs_1.reportUnresolvedRef)(resolved, ctx.report, ctx.location);
181
181
  return;
182
182
  }
183
183
  if (resolved.location.source === rootDocument.source &&
@@ -187,10 +187,10 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
187
187
  return;
188
188
  }
189
189
  // do not bundle registry URL before push, otherwise we can't record dependencies
190
- if (skipRedoclyRegistryRefs && redocly_1.isRedoclyRegistryURL(node.$ref)) {
190
+ if (skipRedoclyRegistryRefs && (0, redocly_1.isRedoclyRegistryURL)(node.$ref)) {
191
191
  return;
192
192
  }
193
- if (keepUrlRefs && ref_utils_1.isAbsoluteUrl(node.$ref)) {
193
+ if (keepUrlRefs && (0, ref_utils_1.isAbsoluteUrl)(node.$ref)) {
194
194
  return;
195
195
  }
196
196
  const componentType = mapTypeToComponent(ctx.type.name, version);
@@ -228,7 +228,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
228
228
  const $ref = mapping[name];
229
229
  const resolved = ctx.resolve({ $ref });
230
230
  if (!resolved.location || resolved.node === undefined) {
231
- no_unresolved_refs_1.reportUnresolvedRef(resolved, ctx.report, ctx.location.child(name));
231
+ (0, no_unresolved_refs_1.reportUnresolvedRef)(resolved, ctx.report, ctx.location.child(name));
232
232
  return;
233
233
  }
234
234
  const componentType = mapTypeToComponent('Schema', version);
@@ -243,7 +243,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
243
243
  };
244
244
  }
245
245
  function resolveBundledComponent(node, resolved, ctx) {
246
- const newRefId = resolve_1.makeRefId(ctx.location.source.absoluteRef, node.$ref);
246
+ const newRefId = (0, resolve_1.makeRefId)(ctx.location.source.absoluteRef, node.$ref);
247
247
  resolvedRefMap.set(newRefId, {
248
248
  document: rootDocument,
249
249
  isRemote: false,
@@ -253,7 +253,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
253
253
  });
254
254
  }
255
255
  function replaceRef(ref, resolved, ctx) {
256
- if (!utils_1.isPlainObject(resolved.node)) {
256
+ if (!(0, utils_1.isPlainObject)(resolved.node)) {
257
257
  ctx.parent[ctx.key] = resolved.node;
258
258
  }
259
259
  else {
@@ -278,7 +278,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
278
278
  }
279
279
  function isEqualOrEqualRef(node, target, ctx) {
280
280
  var _a;
281
- if (ref_utils_1.isRef(node) &&
281
+ if ((0, ref_utils_1.isRef)(node) &&
282
282
  ((_a = ctx.resolve(node, rootLocation.absolutePointer).location) === null || _a === void 0 ? void 0 : _a.absolutePointer) ===
283
283
  target.location.absolutePointer) {
284
284
  return true;
@@ -298,7 +298,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
298
298
  return name;
299
299
  }
300
300
  }
301
- name = ref_utils_1.refBaseName(fileRef) + (name ? `_${name}` : '');
301
+ name = (0, ref_utils_1.refBaseName)(fileRef) + (name ? `_${name}` : '');
302
302
  if (!componentsGroup[name] || isEqualOrEqualRef(componentsGroup[name], target, ctx)) {
303
303
  return name;
304
304
  }
@@ -1,3 +1,3 @@
1
1
  import type { PluginStyleguideConfig } from './types';
2
- declare const _default: PluginStyleguideConfig;
3
- export default _default;
2
+ declare const all: PluginStyleguideConfig<'built-in'>;
3
+ export default all;
package/lib/config/all.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
3
+ const all = {
4
4
  rules: {
5
5
  'info-contact': 'error',
6
6
  'info-license': 'error',
@@ -28,13 +28,24 @@ exports.default = {
28
28
  'operation-singular-tag': 'error',
29
29
  'no-unresolved-refs': 'error',
30
30
  'no-enum-type-mismatch': 'error',
31
- 'boolean-parameter-prefixes': 'error',
32
31
  'paths-kebab-case': 'error',
33
32
  'no-http-verbs-in-paths': 'error',
34
33
  'path-excludes-patterns': {
35
34
  severity: 'error',
36
35
  patterns: [],
37
36
  },
37
+ spec: 'error',
38
+ 'no-invalid-schema-examples': 'error',
39
+ 'no-invalid-parameter-examples': 'error',
40
+ 'scalar-property-missing-example': 'error',
41
+ 'spec-strict-refs': 'error',
42
+ 'path-http-verbs-order': 'error',
43
+ 'path-params-defined': 'error',
44
+ 'required-string-property-missing-min-length': 'error',
45
+ 'response-contains-header': 'error',
46
+ },
47
+ oas2Rules: {
48
+ 'boolean-parameter-prefixes': 'error',
38
49
  'request-mime-type': {
39
50
  severity: 'error',
40
51
  allowedValues: ['application/json'],
@@ -43,12 +54,7 @@ exports.default = {
43
54
  severity: 'error',
44
55
  allowedValues: ['application/json'],
45
56
  },
46
- spec: 'error',
47
- 'no-invalid-schema-examples': 'error',
48
- 'no-invalid-parameter-examples': 'error',
49
- 'scalar-property-missing-example': 'error',
50
- 'spec-strict-refs': 'error',
51
- 'component-name-unique': 'error',
57
+ 'response-contains-property': 'error',
52
58
  },
53
59
  oas3_0Rules: {
54
60
  'no-invalid-media-type-examples': 'error',
@@ -60,8 +66,21 @@ exports.default = {
60
66
  'no-undefined-server-variable': 'error',
61
67
  'no-server-variables-empty-enum': 'error',
62
68
  'operation-4xx-problem-details-rfc7807': 'error',
69
+ 'boolean-parameter-prefixes': 'error',
70
+ 'request-mime-type': {
71
+ severity: 'error',
72
+ allowedValues: ['application/json'],
73
+ },
74
+ 'response-mime-type': {
75
+ severity: 'error',
76
+ allowedValues: ['application/json'],
77
+ },
78
+ 'component-name-unique': 'error',
79
+ 'response-contains-property': 'error',
80
+ 'spec-components-invalid-map-name': 'error',
63
81
  },
64
82
  oas3_1Rules: {
83
+ 'no-invalid-media-type-examples': 'error',
65
84
  'no-server-example.com': 'error',
66
85
  'no-server-trailing-slash': 'error',
67
86
  'no-empty-servers': 'error',
@@ -70,5 +89,22 @@ exports.default = {
70
89
  'no-undefined-server-variable': 'error',
71
90
  'no-server-variables-empty-enum': 'error',
72
91
  'operation-4xx-problem-details-rfc7807': 'error',
92
+ 'boolean-parameter-prefixes': 'error',
93
+ 'request-mime-type': {
94
+ severity: 'error',
95
+ allowedValues: ['application/json'],
96
+ },
97
+ 'response-mime-type': {
98
+ severity: 'error',
99
+ allowedValues: ['application/json'],
100
+ },
101
+ 'component-name-unique': 'error',
102
+ 'response-contains-property': 'error',
103
+ 'spec-components-invalid-map-name': 'error',
104
+ },
105
+ async2Rules: {
106
+ 'channels-kebab-case': 'error',
107
+ 'no-channel-trailing-slash': 'error',
73
108
  },
74
109
  };
110
+ exports.default = all;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultPlugin = exports.builtInConfigs = void 0;
4
4
  const recommended_1 = require("./recommended");
5
+ const recommended_strict_1 = require("./recommended-strict");
5
6
  const all_1 = require("./all");
6
7
  const minimal_1 = require("./minimal");
7
8
  const oas3_1 = require("../rules/oas3");
@@ -13,6 +14,7 @@ const oas3_3 = require("../decorators/oas3");
13
14
  const oas2_3 = require("../decorators/oas2");
14
15
  exports.builtInConfigs = {
15
16
  recommended: recommended_1.default,
17
+ 'recommended-strict': recommended_strict_1.default,
16
18
  minimal: minimal_1.default,
17
19
  all: all_1.default,
18
20
  'redocly-registry': {