@redocly/openapi-core 1.0.0-beta.104 → 1.0.0-beta.107

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 (203) hide show
  1. package/README.md +4 -4
  2. package/__tests__/utils.ts +8 -6
  3. package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
  4. package/lib/benchmark/utils.d.ts +2 -2
  5. package/lib/benchmark/utils.js +2 -2
  6. package/lib/bundle.d.ts +2 -2
  7. package/lib/bundle.js +2 -2
  8. package/lib/config/all.d.ts +2 -2
  9. package/lib/config/all.js +1 -1
  10. package/lib/config/builtIn.d.ts +2 -2
  11. package/lib/config/builtIn.js +2 -2
  12. package/lib/config/config-resolvers.d.ts +5 -5
  13. package/lib/config/config-resolvers.js +39 -36
  14. package/lib/config/config.d.ts +6 -5
  15. package/lib/config/config.js +27 -20
  16. package/lib/config/load.js +6 -7
  17. package/lib/config/minimal.d.ts +2 -2
  18. package/lib/config/minimal.js +3 -2
  19. package/lib/config/recommended.d.ts +2 -2
  20. package/lib/config/recommended.js +3 -2
  21. package/lib/config/rules.d.ts +2 -2
  22. package/lib/config/rules.js +1 -1
  23. package/lib/config/types.d.ts +23 -19
  24. package/lib/config/utils.d.ts +5 -5
  25. package/lib/config/utils.js +43 -26
  26. package/lib/decorators/common/remove-x-internal.js +2 -2
  27. package/lib/format/format.js +1 -1
  28. package/lib/index.d.ts +2 -2
  29. package/lib/index.js +3 -2
  30. package/lib/js-yaml/index.js +1 -6
  31. package/lib/lint.d.ts +2 -2
  32. package/lib/lint.js +16 -6
  33. package/lib/redocly/registry-api.d.ts +1 -1
  34. package/lib/redocly/registry-api.js +2 -2
  35. package/lib/rules/ajv.d.ts +1 -1
  36. package/lib/rules/ajv.js +6 -6
  37. package/lib/rules/common/info-license-url.d.ts +1 -1
  38. package/lib/rules/common/info-license-url.js +5 -10
  39. package/lib/rules/common/info-license.d.ts +2 -0
  40. package/lib/rules/common/info-license.js +17 -0
  41. package/lib/rules/common/no-enum-type-mismatch.js +1 -3
  42. package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
  43. package/lib/rules/common/no-invalid-schema-examples.js +3 -3
  44. package/lib/rules/common/operation-operationId.js +1 -1
  45. package/lib/rules/common/path-not-include-query.js +1 -1
  46. package/lib/rules/common/paths-kebab-case.js +4 -1
  47. package/lib/rules/common/spec.js +1 -1
  48. package/lib/rules/oas2/index.js +4 -4
  49. package/lib/rules/oas2/remove-unused-components.js +3 -3
  50. package/lib/rules/oas3/index.js +4 -4
  51. package/lib/rules/oas3/no-empty-servers.js +1 -1
  52. package/lib/rules/oas3/no-invalid-media-type-examples.js +2 -2
  53. package/lib/rules/oas3/remove-unused-components.js +2 -2
  54. package/lib/rules/other/stats.js +43 -14
  55. package/lib/rules/utils.d.ts +3 -2
  56. package/lib/rules/utils.js +19 -4
  57. package/lib/types/index.d.ts +2 -2
  58. package/lib/types/redocly-yaml.js +8 -7
  59. package/lib/utils.d.ts +5 -2
  60. package/lib/utils.js +20 -2
  61. package/lib/walk.d.ts +2 -1
  62. package/lib/walk.js +6 -3
  63. package/package.json +2 -2
  64. package/src/__tests__/__snapshots__/bundle.test.ts.snap +141 -0
  65. package/src/__tests__/bundle.test.ts +68 -34
  66. package/src/__tests__/codeframes.test.ts +13 -14
  67. package/src/__tests__/fixtures/.redocly.lint-ignore.yaml +5 -0
  68. package/src/__tests__/js-yaml.test.ts +6 -4
  69. package/src/__tests__/lint.test.ts +127 -12
  70. package/src/__tests__/login.test.ts +2 -2
  71. package/src/__tests__/normalizeVisitors.test.ts +4 -4
  72. package/src/__tests__/ref-utils.test.ts +13 -13
  73. package/src/__tests__/resolve-http.test.ts +1 -1
  74. package/src/__tests__/resolve.test.ts +14 -11
  75. package/src/__tests__/utils.test.ts +42 -1
  76. package/src/__tests__/walk.test.ts +48 -56
  77. package/src/benchmark/benches/lint-with-many-rules.bench.ts +1 -1
  78. package/src/benchmark/benches/lint-with-nested-rule.bench.ts +1 -1
  79. package/src/benchmark/benches/lint-with-no-rules.bench.ts +1 -1
  80. package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +1 -1
  81. package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +1 -1
  82. package/src/benchmark/benches/recommended-oas3.bench.ts +3 -3
  83. package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
  84. package/src/benchmark/benchmark.js +9 -5
  85. package/src/benchmark/utils.ts +5 -5
  86. package/src/bundle.ts +18 -17
  87. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +3 -1
  88. package/src/config/__tests__/config-resolvers.test.ts +123 -121
  89. package/src/config/__tests__/config.test.ts +76 -76
  90. package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +4 -2
  91. package/src/config/__tests__/fixtures/resolve-config/plugin.js +4 -1
  92. package/src/config/__tests__/load.test.ts +2 -2
  93. package/src/config/__tests__/resolve-plugins.test.ts +3 -3
  94. package/src/config/__tests__/utils.test.ts +83 -0
  95. package/src/config/all.ts +3 -4
  96. package/src/config/builtIn.ts +5 -5
  97. package/src/config/config-resolvers.ts +122 -83
  98. package/src/config/config.ts +36 -32
  99. package/src/config/load.ts +13 -16
  100. package/src/config/minimal.ts +5 -4
  101. package/src/config/recommended.ts +5 -4
  102. package/src/config/rules.ts +6 -6
  103. package/src/config/types.ts +28 -19
  104. package/src/config/utils.ts +74 -54
  105. package/src/decorators/__tests__/filter-out.test.ts +8 -4
  106. package/src/decorators/__tests__/remove-x-internal.test.ts +5 -5
  107. package/src/decorators/common/filters/filter-helper.ts +1 -1
  108. package/src/decorators/common/info-description-override.ts +1 -1
  109. package/src/decorators/common/operation-description-override.ts +1 -1
  110. package/src/decorators/common/remove-x-internal.ts +4 -4
  111. package/src/decorators/common/tag-description-override.ts +1 -1
  112. package/src/format/codeframes.ts +4 -4
  113. package/src/format/format.ts +10 -10
  114. package/src/index.ts +3 -4
  115. package/src/js-yaml/index.ts +3 -8
  116. package/src/lint.ts +22 -18
  117. package/src/oas-types.ts +1 -6
  118. package/src/redocly/__tests__/redocly-client.test.ts +25 -19
  119. package/src/redocly/index.ts +6 -4
  120. package/src/redocly/registry-api.ts +6 -6
  121. package/src/ref-utils.ts +2 -2
  122. package/src/resolve.ts +7 -4
  123. package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
  124. package/src/rules/__tests__/utils.test.ts +160 -0
  125. package/src/rules/ajv.ts +7 -8
  126. package/src/rules/common/__tests__/info-description.test.ts +3 -3
  127. package/src/rules/common/__tests__/info-license.test.ts +2 -2
  128. package/src/rules/common/__tests__/license-url.test.ts +2 -2
  129. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
  130. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +8 -8
  131. package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
  132. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +3 -3
  133. package/src/rules/common/__tests__/operation-2xx-response.test.ts +3 -3
  134. package/src/rules/common/__tests__/operation-4xx-response.test.ts +3 -3
  135. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
  136. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
  137. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
  138. package/src/rules/common/__tests__/operation-security-defined.test.ts +2 -2
  139. package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
  140. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
  141. package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
  142. package/src/rules/common/__tests__/path-params-defined.test.ts +3 -3
  143. package/src/rules/common/__tests__/paths-kebab-case.test.ts +15 -15
  144. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
  145. package/src/rules/common/__tests__/spec.test.ts +2 -2
  146. package/src/rules/common/__tests__/tag-description.test.ts +2 -2
  147. package/src/rules/common/__tests__/tags-alphabetical.test.ts +2 -2
  148. package/src/rules/common/assertions/__tests__/asserts.test.ts +513 -130
  149. package/src/rules/common/assertions/index.ts +6 -6
  150. package/src/rules/common/info-license-url.ts +4 -9
  151. package/src/rules/common/info-license.ts +15 -0
  152. package/src/rules/common/no-ambiguous-paths.ts +1 -1
  153. package/src/rules/common/no-enum-type-mismatch.ts +12 -9
  154. package/src/rules/common/no-invalid-parameter-examples.ts +4 -4
  155. package/src/rules/common/no-invalid-schema-examples.ts +4 -4
  156. package/src/rules/common/operation-operationId.ts +1 -1
  157. package/src/rules/common/operation-parameters-unique.ts +2 -2
  158. package/src/rules/common/path-not-include-query.ts +1 -1
  159. package/src/rules/common/path-params-defined.ts +1 -1
  160. package/src/rules/common/paths-kebab-case.ts +4 -1
  161. package/src/rules/common/scalar-property-missing-example.ts +1 -1
  162. package/src/rules/common/spec.ts +10 -7
  163. package/src/rules/no-unresolved-refs.ts +1 -1
  164. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  165. package/src/rules/oas2/__tests__/spec/info.test.ts +12 -12
  166. package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
  167. package/src/rules/oas2/__tests__/spec/paths.test.ts +10 -10
  168. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +6 -2
  169. package/src/rules/oas2/__tests__/spec/utils.ts +6 -6
  170. package/src/rules/oas2/index.ts +3 -3
  171. package/src/rules/oas2/remove-unused-components.ts +13 -8
  172. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  173. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
  174. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +13 -13
  175. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +2 -2
  176. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
  177. package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
  178. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
  179. package/src/rules/oas3/__tests__/spec/info.test.ts +12 -12
  180. package/src/rules/oas3/__tests__/spec/operation.test.ts +8 -8
  181. package/src/rules/oas3/__tests__/spec/paths.test.ts +10 -10
  182. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +12 -12
  183. package/src/rules/oas3/__tests__/spec/servers.test.ts +15 -15
  184. package/src/rules/oas3/__tests__/spec/spec.test.ts +6 -6
  185. package/src/rules/oas3/__tests__/spec/utils.ts +6 -6
  186. package/src/rules/oas3/index.ts +3 -3
  187. package/src/rules/oas3/no-empty-servers.ts +1 -1
  188. package/src/rules/oas3/no-invalid-media-type-examples.ts +14 -6
  189. package/src/rules/oas3/no-servers-empty-enum.ts +9 -10
  190. package/src/rules/oas3/remove-unused-components.ts +18 -7
  191. package/src/rules/other/stats.ts +46 -17
  192. package/src/rules/utils.ts +19 -3
  193. package/src/types/index.ts +5 -5
  194. package/src/types/redocly-yaml.ts +8 -7
  195. package/src/typings/common.ts +9 -1
  196. package/src/typings/openapi.ts +1 -1
  197. package/src/utils.ts +31 -8
  198. package/src/visitors.ts +4 -4
  199. package/src/walk.ts +15 -11
  200. package/tsconfig.tsbuildinfo +1 -1
  201. package/lib/rules/common/license-url.d.ts +0 -2
  202. package/lib/rules/common/license-url.js +0 -12
  203. package/src/rules/common/license-url.ts +0 -10
@@ -10,7 +10,7 @@ export declare type PreprocessorConfig = PreprocessorSeverity | ({
10
10
  severity?: ProblemSeverity;
11
11
  } & Record<string, any>);
12
12
  export declare type DecoratorConfig = PreprocessorConfig;
13
- export declare type LintRawConfig = {
13
+ export declare type StyleguideRawConfig = {
14
14
  plugins?: (string | Plugin)[];
15
15
  extends?: string[];
16
16
  doNotResolveExamples?: boolean;
@@ -28,7 +28,8 @@ export declare type LintRawConfig = {
28
28
  oas3_0Decorators?: Record<string, DecoratorConfig>;
29
29
  oas3_1Decorators?: Record<string, DecoratorConfig>;
30
30
  };
31
- export declare type ResolvedLintConfig = PluginLintConfig & {
31
+ export declare type ApiStyleguideRawConfig = Omit<StyleguideRawConfig, 'plugins'>;
32
+ export declare type ResolvedStyleguideConfig = PluginStyleguideConfig & {
32
33
  plugins?: Plugin[];
33
34
  recommendedFallback?: boolean;
34
35
  extends?: void | never;
@@ -51,13 +52,13 @@ export declare type CustomRulesConfig = {
51
52
  };
52
53
  export declare type Plugin = {
53
54
  id: string;
54
- configs?: Record<string, PluginLintConfig>;
55
+ configs?: Record<string, PluginStyleguideConfig>;
55
56
  rules?: CustomRulesConfig;
56
57
  preprocessors?: PreprocessorsConfig;
57
58
  decorators?: DecoratorsConfig;
58
59
  typeExtension?: TypeExtensionsConfig;
59
60
  };
60
- export declare type PluginLintConfig = Omit<LintRawConfig, 'plugins' | 'extends'>;
61
+ export declare type PluginStyleguideConfig = Omit<StyleguideRawConfig, 'plugins' | 'extends'>;
61
62
  export declare type ResolveHeader = {
62
63
  name: string;
63
64
  envVariable?: undefined;
@@ -83,33 +84,36 @@ export declare type Region = 'us' | 'eu';
83
84
  export declare type AccessTokens = {
84
85
  [region in Region]?: string;
85
86
  };
86
- export declare type DeprecatedRawConfig = {
87
+ export declare type DeprecatedInRawConfig = {
87
88
  apiDefinitions?: Record<string, string>;
88
- lint?: LintRawConfig;
89
- resolve?: RawResolveConfig;
90
- region?: Region;
89
+ lint?: StyleguideRawConfig;
91
90
  referenceDocs?: Record<string, any>;
91
+ apis?: Record<string, Api & DeprecatedInApi>;
92
92
  };
93
93
  export declare type Api = {
94
94
  root: string;
95
- lint?: Omit<LintRawConfig, 'plugins'>;
96
- 'features.openapi'?: Record<string, any>;
97
- 'features.mockServer'?: Record<string, any>;
95
+ styleguide?: ApiStyleguideRawConfig;
96
+ } & FeaturesConfig;
97
+ export declare type DeprecatedInApi = {
98
+ lint?: ApiStyleguideRawConfig;
98
99
  };
99
- export declare type ResolvedApi = Omit<Api, 'lint'> & {
100
- lint: Omit<ResolvedLintConfig, 'plugins'>;
100
+ export declare type ResolvedApi = Omit<Api, 'styleguide'> & {
101
+ styleguide: ResolvedStyleguideConfig;
101
102
  };
102
103
  export declare type RawConfig = {
103
104
  apis?: Record<string, Api>;
104
- lint?: LintRawConfig;
105
+ styleguide?: StyleguideRawConfig;
105
106
  resolve?: RawResolveConfig;
106
107
  region?: Region;
107
- 'features.openapi'?: Record<string, any>;
108
- 'features.mockServer'?: Record<string, any>;
109
108
  organization?: string;
110
- };
111
- export declare type ResolvedConfig = Omit<RawConfig, 'lint' | 'apis'> & {
112
- lint: ResolvedLintConfig;
109
+ } & FeaturesConfig;
110
+ export declare type ResolvedConfig = Omit<RawConfig, 'apis' | 'styleguide'> & {
113
111
  apis: Record<string, ResolvedApi>;
112
+ styleguide: ResolvedStyleguideConfig;
113
+ };
114
+ declare type FeaturesConfig = {
115
+ 'features.openapi'?: Record<string, any>;
116
+ 'features.mockServer'?: Record<string, any>;
114
117
  };
115
118
  export declare type RulesFields = 'rules' | 'oas2Rules' | 'oas3_0Rules' | 'oas3_1Rules' | 'preprocessors' | 'oas2Preprocessors' | 'oas3_0Preprocessors' | 'oas3_1Preprocessors' | 'decorators' | 'oas2Decorators' | 'oas3_0Decorators' | 'oas3_1Decorators';
119
+ export {};
@@ -1,13 +1,13 @@
1
1
  import { Config } from './config';
2
- import type { Api, DeprecatedRawConfig, Plugin, RawConfig, RawResolveConfig, ResolveConfig, ResolvedLintConfig, RulesFields } from './types';
2
+ import type { Api, DeprecatedInRawConfig, Plugin, RawConfig, RawResolveConfig, ResolveConfig, ResolvedStyleguideConfig, RulesFields } from './types';
3
3
  export declare function parsePresetName(presetName: string): {
4
4
  pluginId: string;
5
5
  configName: string;
6
6
  };
7
- export declare function transformApiDefinitionsToApis(apiDefinitions?: Record<string, string>): Record<string, Api>;
7
+ export declare function transformApiDefinitionsToApis(apiDefinitions?: DeprecatedInRawConfig['apiDefinitions']): Record<string, Api> | undefined;
8
8
  export declare function prefixRules<T extends Record<string, any>>(rules: T, prefix: string): any;
9
- export declare function mergeExtends(rulesConfList: ResolvedLintConfig[]): Omit<ResolvedLintConfig, RulesFields> & Required<Pick<ResolvedLintConfig, RulesFields>>;
10
- export declare function getMergedConfig(config: Config, entrypointAlias?: string): Config;
11
- export declare function transformConfig(rawConfig: DeprecatedRawConfig | RawConfig): RawConfig;
9
+ export declare function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]): Omit<ResolvedStyleguideConfig, RulesFields> & Required<Pick<ResolvedStyleguideConfig, RulesFields>>;
10
+ export declare function getMergedConfig(config: Config, apiName?: string): Config;
11
+ export declare function transformConfig(rawConfig: DeprecatedInRawConfig & RawConfig): RawConfig;
12
12
  export declare function getResolveConfig(resolve?: RawResolveConfig): ResolveConfig;
13
13
  export declare function getUniquePlugins(plugins: Plugin[]): Plugin[];
@@ -25,14 +25,26 @@ 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 transformApis(legacyApis) {
39
+ if (!legacyApis)
40
+ return undefined;
41
+ const apis = {};
42
+ for (let _a of Object.entries(legacyApis)) {
43
+ const [apiName, _b] = _a, { lint } = _b, apiContent = __rest(_b, ["lint"]);
44
+ apis[apiName] = Object.assign({ styleguide: lint }, apiContent);
45
+ }
46
+ return apis;
47
+ }
36
48
  function prefixRules(rules, prefix) {
37
49
  if (!prefix)
38
50
  return rules;
@@ -63,7 +75,7 @@ function mergeExtends(rulesConfList) {
63
75
  };
64
76
  for (let rulesConf of rulesConfList) {
65
77
  if (rulesConf.extends) {
66
- throw new Error(`\`extends\` is not supported in shared configs yet: ${JSON.stringify(rulesConf, null, 2)}.`);
78
+ throw new Error(`'extends' is not supported in shared configs yet: ${JSON.stringify(rulesConf, null, 2)}.`);
67
79
  }
68
80
  Object.assign(result.rules, rulesConf.rules);
69
81
  Object.assign(result.oas2Rules, rulesConf.oas2Rules);
@@ -93,44 +105,49 @@ function mergeExtends(rulesConfList) {
93
105
  return result;
94
106
  }
95
107
  exports.mergeExtends = mergeExtends;
96
- function getMergedConfig(config, entrypointAlias) {
108
+ function getMergedConfig(config, apiName) {
97
109
  var _a, _b, _c, _d, _e, _f;
98
110
  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,
111
+ ...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; }),
112
+ (_b = (_a = config.rawConfig) === null || _a === void 0 ? void 0 : _a.styleguide) === null || _b === void 0 ? void 0 : _b.extendPaths,
101
113
  ]
102
114
  .flat()
103
115
  .filter(Boolean);
104
116
  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,
117
+ ...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; }),
118
+ (_d = (_c = config.rawConfig) === null || _c === void 0 ? void 0 : _c.styleguide) === null || _d === void 0 ? void 0 : _d.pluginPaths,
107
119
  ]
108
120
  .flat()
109
121
  .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)
122
+ return apiName
123
+ ? new config_1.Config(Object.assign(Object.assign({}, config.rawConfig), { styleguide: Object.assign(Object.assign({}, (config.apis[apiName]
124
+ ? config.apis[apiName].styleguide
125
+ : config.rawConfig.styleguide)), { extendPaths,
126
+ pluginPaths }), 'features.openapi': Object.assign(Object.assign({}, config['features.openapi']), (_e = config.apis[apiName]) === null || _e === void 0 ? void 0 : _e['features.openapi']), 'features.mockServer': Object.assign(Object.assign({}, config['features.mockServer']), (_f = config.apis[apiName]) === null || _f === void 0 ? void 0 : _f['features.mockServer']) }), config.configFile)
115
127
  : config;
116
128
  }
117
129
  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");
130
+ function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig) {
131
+ const isDeprecatedFieldInApis = rawConfig.apis &&
132
+ Object.values(rawConfig.apis).some((api) => api[deprecatedField]);
133
+ if (rawConfig[deprecatedField] && rawConfig[updatedField]) {
134
+ utils_1.showErrorForDeprecatedField(deprecatedField, updatedField);
121
135
  }
122
- if (rawConfig['features.openapi'] &&
123
- rawConfig.referenceDocs) {
124
- throw new Error("Do not use 'referenceDocs' field. Use 'features.openapi' instead.\n");
136
+ if (rawConfig[deprecatedField] || isDeprecatedFieldInApis) {
137
+ utils_1.showWarningForDeprecatedField(deprecatedField, updatedField);
125
138
  }
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`);
129
- }
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`);
139
+ }
140
+ function transformConfig(rawConfig) {
141
+ const migratedFields = [
142
+ ['apiDefinitions', 'apis'],
143
+ ['referenceDocs', 'features.openapi'],
144
+ ['lint', 'styleguide'], // TODO: update docs
145
+ ];
146
+ for (const [deprecatedField, updatedField] of migratedFields) {
147
+ checkForDeprecatedFields(deprecatedField, updatedField, rawConfig);
132
148
  }
133
- return Object.assign({ 'features.openapi': referenceDocs, apis: transformApiDefinitionsToApis(apiDefinitions) }, rest);
149
+ const { apis, apiDefinitions, referenceDocs, lint } = rawConfig, rest = __rest(rawConfig, ["apis", "apiDefinitions", "referenceDocs", "lint"]);
150
+ return Object.assign({ 'features.openapi': referenceDocs, apis: transformApis(apis) || transformApiDefinitionsToApis(apiDefinitions), styleguide: lint }, rest);
134
151
  }
135
152
  exports.transformConfig = transformConfig;
136
153
  function getResolveConfig(resolve) {
@@ -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;
@@ -167,7 +167,7 @@ function formatProblems(problems, opts) {
167
167
  function formatStylish(problem, locationPad, ruleIdPad) {
168
168
  const color = COLORS[problem.severity];
169
169
  if (!SEVERITY_NAMES[problem.severity]) {
170
- return 'Error not found severity. Please check your config file. Allowed values: \`warn,error,off\`';
170
+ return 'Error not found severity. Please check your config file. Allowed values: `warn,error,off`';
171
171
  }
172
172
  const severityName = color(SEVERITY_NAMES[problem.severity].toLowerCase().padEnd(7));
173
173
  const { start } = problem.location[0];
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { BundleOutputFormat, readFileFromUrl, slash } from './utils';
1
+ export { BundleOutputFormat, readFileFromUrl, slash, doesYamlFileExist } from './utils';
2
2
  export { Oas3_1Types } from './types/oas3_1';
3
3
  export { Oas3Types } from './types/oas3';
4
4
  export { Oas2Types } from './types/oas2';
@@ -8,7 +8,7 @@ export { Oas2Definition } from './typings/swagger';
8
8
  export { StatsAccumulator, StatsName } from './typings/common';
9
9
  export { normalizeTypes } from './types';
10
10
  export { Stats } from './rules/other/stats';
11
- export { Config, LintConfig, RawConfig, IGNORE_FILE, Region, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, RuleSeverity } from './config';
11
+ export { Config, StyleguideConfig, RawConfig, IGNORE_FILE, Region, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, RuleSeverity, } from './config';
12
12
  export { RedoclyClient, isRedoclyRegistryURL } from './redocly';
13
13
  export { Source, BaseResolver, Document, resolveDocument, ResolveError, YamlParseError, makeDocumentFromString, } from './resolve';
14
14
  export { parseYaml, stringifyYaml } from './js-yaml';
package/lib/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.isRedoclyRegistryURL = exports.RedoclyClient = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.slash = exports.readFileFromUrl = void 0;
3
+ exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.OasVersion = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.isRedoclyRegistryURL = exports.RedoclyClient = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.StyleguideConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.Oas2Types = exports.Oas3Types = exports.Oas3_1Types = exports.doesYamlFileExist = exports.slash = exports.readFileFromUrl = void 0;
4
4
  var utils_1 = require("./utils");
5
5
  Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } });
6
6
  Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } });
7
+ Object.defineProperty(exports, "doesYamlFileExist", { enumerable: true, get: function () { return utils_1.doesYamlFileExist; } });
7
8
  var oas3_1_1 = require("./types/oas3_1");
8
9
  Object.defineProperty(exports, "Oas3_1Types", { enumerable: true, get: function () { return oas3_1_1.Oas3_1Types; } });
9
10
  var oas3_1 = require("./types/oas3");
@@ -18,7 +19,7 @@ var stats_1 = require("./rules/other/stats");
18
19
  Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return stats_1.Stats; } });
19
20
  var config_1 = require("./config");
20
21
  Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } });
21
- Object.defineProperty(exports, "LintConfig", { enumerable: true, get: function () { return config_1.LintConfig; } });
22
+ Object.defineProperty(exports, "StyleguideConfig", { enumerable: true, get: function () { return config_1.StyleguideConfig; } });
22
23
  Object.defineProperty(exports, "IGNORE_FILE", { enumerable: true, get: function () { return config_1.IGNORE_FILE; } });
23
24
  Object.defineProperty(exports, "getMergedConfig", { enumerable: true, get: function () { return config_1.getMergedConfig; } });
24
25
  Object.defineProperty(exports, "transformConfig", { enumerable: true, get: function () { return config_1.transformConfig; } });
@@ -6,12 +6,7 @@ exports.stringifyYaml = exports.parseYaml = void 0;
6
6
  const js_yaml_1 = require("js-yaml");
7
7
  const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = js_yaml_1.JSON_SCHEMA.extend({
8
8
  implicit: [js_yaml_1.types.merge],
9
- explicit: [
10
- js_yaml_1.types.binary,
11
- js_yaml_1.types.omap,
12
- js_yaml_1.types.pairs,
13
- js_yaml_1.types.set,
14
- ],
9
+ explicit: [js_yaml_1.types.binary, js_yaml_1.types.omap, js_yaml_1.types.pairs, js_yaml_1.types.set],
15
10
  });
16
11
  const parseYaml = (str, opts) => js_yaml_1.load(str, Object.assign({ schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP }, opts));
17
12
  exports.parseYaml = parseYaml;
package/lib/lint.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BaseResolver, Document } from './resolve';
2
2
  import { NodeType } from './types';
3
3
  import { ProblemSeverity } from './walk';
4
- import { LintConfig, Config } from './config';
4
+ import { StyleguideConfig, Config } from './config';
5
5
  export declare function lint(opts: {
6
6
  ref: string;
7
7
  config: Config;
@@ -15,7 +15,7 @@ export declare function lintFromString(opts: {
15
15
  }): Promise<import("./walk").NormalizedProblem[]>;
16
16
  export declare function lintDocument(opts: {
17
17
  document: Document;
18
- config: LintConfig;
18
+ config: StyleguideConfig;
19
19
  customTypes?: Record<string, NodeType>;
20
20
  externalRefResolver: BaseResolver;
21
21
  }): Promise<import("./walk").NormalizedProblem[]>;
package/lib/lint.js CHANGED
@@ -26,7 +26,7 @@ function lint(opts) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
27
  const { ref, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
28
28
  const document = (yield externalRefResolver.resolveDocument(null, ref, true));
29
- return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.lint }));
29
+ return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
30
30
  });
31
31
  }
32
32
  exports.lint = lint;
@@ -34,7 +34,7 @@ function lintFromString(opts) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts;
36
36
  const document = resolve_1.makeDocumentFromString(source, absoluteRef || '/');
37
- return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.lint }));
37
+ return lintDocument(Object.assign(Object.assign({ document }, opts), { externalRefResolver, config: opts.config.styleguide }));
38
38
  });
39
39
  }
40
40
  exports.lintFromString = lintFromString;
@@ -45,7 +45,11 @@ function lintDocument(opts) {
45
45
  const oasVersion = oas_types_1.detectOpenAPI(document.parsed);
46
46
  const oasMajorVersion = oas_types_1.openAPIMajor(oasVersion);
47
47
  const rules = config.getRulesForOasVersion(oasMajorVersion);
48
- const types = types_1.normalizeTypes(config.extendTypes((customTypes !== null && customTypes !== void 0 ? customTypes : oasMajorVersion === oas_types_1.OasMajorVersion.Version3) ? (oasVersion === oas_types_1.OasVersion.Version3_1 ? oas3_1_1.Oas3_1Types : oas3_1.Oas3Types) : oas2_1.Oas2Types, oasVersion), config);
48
+ const types = types_1.normalizeTypes(config.extendTypes((customTypes !== null && customTypes !== void 0 ? customTypes : oasMajorVersion === oas_types_1.OasMajorVersion.Version3)
49
+ ? oasVersion === oas_types_1.OasVersion.Version3_1
50
+ ? oas3_1_1.Oas3_1Types
51
+ : oas3_1.Oas3Types
52
+ : oas2_1.Oas2Types, oasVersion), config);
49
53
  const ctx = {
50
54
  problems: [],
51
55
  oasVersion: oasVersion,
@@ -57,7 +61,7 @@ function lintDocument(opts) {
57
61
  const resolvedRefMap = yield resolve_1.resolveDocument({
58
62
  rootDocument: document,
59
63
  rootType: types.DefinitionRoot,
60
- externalRefResolver
64
+ externalRefResolver,
61
65
  });
62
66
  walk_1.walkDocument({
63
67
  document,
@@ -79,12 +83,18 @@ function lintConfig(opts) {
79
83
  visitorsData: {},
80
84
  };
81
85
  const plugins = config_1.resolvePlugins([config_1.defaultPlugin]);
82
- const config = new config_1.LintConfig({
86
+ const config = new config_1.StyleguideConfig({
83
87
  plugins,
84
88
  rules: { spec: 'error' },
85
89
  });
86
90
  const types = types_1.normalizeTypes(redocly_yaml_1.ConfigTypes, config);
87
- const rules = [{ severity: severity || 'error', ruleId: 'configuration spec', visitor: spec_1.OasSpec({ severity: 'error' }) }];
91
+ const rules = [
92
+ {
93
+ severity: severity || 'error',
94
+ ruleId: 'configuration spec',
95
+ visitor: spec_1.OasSpec({ severity: 'error' }),
96
+ },
97
+ ];
88
98
  const normalizedVisitors = visitors_1.normalizeVisitors(rules, types);
89
99
  walk_1.walkDocument({
90
100
  document,
@@ -13,5 +13,5 @@ export declare class RegistryApi {
13
13
  organizations: string[];
14
14
  }>;
15
15
  prepareFileUpload({ organizationId, name, version, filesHash, filename, isUpsert, }: RegistryApiTypes.PrepareFileuploadParams): Promise<RegistryApiTypes.PrepareFileuploadOKResponse>;
16
- pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize }: RegistryApiTypes.PushApiParams): Promise<void>;
16
+ pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize, }: RegistryApiTypes.PushApiParams): Promise<void>;
17
17
  }
@@ -80,7 +80,7 @@ class RegistryApi {
80
80
  throw new Error('Could not prepare file upload');
81
81
  });
82
82
  }
83
- pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize }) {
83
+ pushApi({ organizationId, name, version, rootFilePath, filePaths, branch, isUpsert, isPublic, batchId, batchSize, }) {
84
84
  return __awaiter(this, void 0, void 0, function* () {
85
85
  const response = yield this.request(`/${organizationId}/${name}/${version}`, {
86
86
  method: 'PUT',
@@ -95,7 +95,7 @@ class RegistryApi {
95
95
  isUpsert,
96
96
  isPublic,
97
97
  batchId,
98
- batchSize
98
+ batchSize,
99
99
  }),
100
100
  }, this.region);
101
101
  if (response.ok) {
@@ -2,7 +2,7 @@ import { ErrorObject } from '@redocly/ajv';
2
2
  import { Location } from '../ref-utils';
3
3
  import { ResolveFn } from '../walk';
4
4
  export declare function releaseAjvInstance(): void;
5
- export declare function validateJsonSchema(data: any, schema: any, schemaLoc: Location, instancePath: string, resolve: ResolveFn, disallowAdditionalProperties: boolean): {
5
+ export declare function validateJsonSchema(data: any, schema: any, schemaLoc: Location, instancePath: string, resolve: ResolveFn, allowAdditionalProperties: boolean): {
6
6
  valid: boolean;
7
7
  errors: (ErrorObject & {
8
8
  suggest?: string[];
package/lib/rules/ajv.js CHANGED
@@ -8,7 +8,7 @@ function releaseAjvInstance() {
8
8
  ajvInstance = null;
9
9
  }
10
10
  exports.releaseAjvInstance = releaseAjvInstance;
11
- function getAjv(resolve, disallowAdditionalProperties) {
11
+ function getAjv(resolve, allowAdditionalProperties) {
12
12
  if (!ajvInstance) {
13
13
  ajvInstance = new ajv_1.default({
14
14
  schemaId: '$id',
@@ -20,7 +20,7 @@ function getAjv(resolve, disallowAdditionalProperties) {
20
20
  discriminator: true,
21
21
  allowUnionTypes: true,
22
22
  validateFormats: false,
23
- defaultAdditionalProperties: !disallowAdditionalProperties,
23
+ defaultAdditionalProperties: allowAdditionalProperties,
24
24
  loadSchemaSync(base, $ref) {
25
25
  const resolvedRef = resolve({ $ref }, base.split('#')[0]);
26
26
  if (!resolvedRef || !resolvedRef.location)
@@ -32,15 +32,15 @@ function getAjv(resolve, disallowAdditionalProperties) {
32
32
  }
33
33
  return ajvInstance;
34
34
  }
35
- function getAjvValidator(schema, loc, resolve, disallowAdditionalProperties) {
36
- const ajv = getAjv(resolve, disallowAdditionalProperties);
35
+ function getAjvValidator(schema, loc, resolve, allowAdditionalProperties) {
36
+ const ajv = getAjv(resolve, allowAdditionalProperties);
37
37
  if (!ajv.getSchema(loc.absolutePointer)) {
38
38
  ajv.addSchema(Object.assign({ $id: loc.absolutePointer }, schema), loc.absolutePointer);
39
39
  }
40
40
  return ajv.getSchema(loc.absolutePointer);
41
41
  }
42
- function validateJsonSchema(data, schema, schemaLoc, instancePath, resolve, disallowAdditionalProperties) {
43
- const validate = getAjvValidator(schema, schemaLoc, resolve, disallowAdditionalProperties);
42
+ function validateJsonSchema(data, schema, schemaLoc, instancePath, resolve, allowAdditionalProperties) {
43
+ const validate = getAjvValidator(schema, schemaLoc, resolve, allowAdditionalProperties);
44
44
  if (!validate)
45
45
  return { valid: true, errors: [] }; // unresolved refs are reported
46
46
  const valid = validate(data, {
@@ -1,2 +1,2 @@
1
1
  import { Oas3Rule, Oas2Rule } from '../../visitors';
2
- export declare const InfoLicense: Oas3Rule | Oas2Rule;
2
+ export declare const InfoLicenseUrl: Oas3Rule | Oas2Rule;
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InfoLicense = void 0;
3
+ exports.InfoLicenseUrl = void 0;
4
4
  const utils_1 = require("../utils");
5
- const InfoLicense = () => {
5
+ const InfoLicenseUrl = () => {
6
6
  return {
7
- Info(info, { report }) {
8
- if (!info.license) {
9
- report({
10
- message: utils_1.missingRequiredField('Info', 'license'),
11
- location: { reportOnKey: true }
12
- });
13
- }
7
+ License(license, ctx) {
8
+ utils_1.validateDefinedAndNonEmpty('url', license, ctx);
14
9
  },
15
10
  };
16
11
  };
17
- exports.InfoLicense = InfoLicense;
12
+ exports.InfoLicenseUrl = InfoLicenseUrl;
@@ -0,0 +1,2 @@
1
+ import { Oas3Rule, Oas2Rule } from '../../visitors';
2
+ export declare const InfoLicense: Oas3Rule | Oas2Rule;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InfoLicense = void 0;
4
+ const utils_1 = require("../utils");
5
+ const InfoLicense = () => {
6
+ return {
7
+ Info(info, { report }) {
8
+ if (!info.license) {
9
+ report({
10
+ message: utils_1.missingRequiredField('Info', 'license'),
11
+ location: { reportOnKey: true },
12
+ });
13
+ }
14
+ },
15
+ };
16
+ };
17
+ exports.InfoLicense = InfoLicense;
@@ -28,14 +28,12 @@ const NoEnumTypeMismatch = () => {
28
28
  if (mismatchedResults[enumValue].length !== schema.type.length)
29
29
  delete mismatchedResults[enumValue];
30
30
  }
31
- ;
32
31
  for (const mismatchedKey of Object.keys(mismatchedResults)) {
33
32
  report({
34
- message: `Enum value \`${mismatchedKey}\` must be of one type. Allowed types: \`${schema.type}\`.`,
33
+ message: `Enum value \`${mismatchedKey}\` must be of allowed types: \`${schema.type}\`.`,
35
34
  location: location.child(['enum', schema.enum.indexOf(mismatchedKey)]),
36
35
  });
37
36
  }
38
- ;
39
37
  }
40
38
  },
41
39
  };
@@ -4,17 +4,17 @@ exports.NoInvalidParameterExamples = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const NoInvalidParameterExamples = (opts) => {
6
6
  var _a;
7
- const disallowAdditionalProperties = (_a = opts.disallowAdditionalProperties) !== null && _a !== void 0 ? _a : true;
7
+ const allowAdditionalProperties = (_a = utils_1.getAdditionalPropertiesOption(opts)) !== null && _a !== void 0 ? _a : false;
8
8
  return {
9
9
  Parameter: {
10
10
  leave(parameter, ctx) {
11
11
  if (parameter.example) {
12
- utils_1.validateExample(parameter.example, parameter.schema, ctx.location.child('example'), ctx, disallowAdditionalProperties);
12
+ utils_1.validateExample(parameter.example, parameter.schema, ctx.location.child('example'), ctx, allowAdditionalProperties);
13
13
  }
14
14
  if (parameter.examples) {
15
15
  for (const [key, example] of Object.entries(parameter.examples)) {
16
16
  if ('value' in example) {
17
- utils_1.validateExample(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx, false);
17
+ utils_1.validateExample(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx, true);
18
18
  }
19
19
  }
20
20
  }
@@ -4,17 +4,17 @@ exports.NoInvalidSchemaExamples = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  const NoInvalidSchemaExamples = (opts) => {
6
6
  var _a;
7
- const disallowAdditionalProperties = (_a = opts.disallowAdditionalProperties) !== null && _a !== void 0 ? _a : true;
7
+ const allowAdditionalProperties = (_a = utils_1.getAdditionalPropertiesOption(opts)) !== null && _a !== void 0 ? _a : false;
8
8
  return {
9
9
  Schema: {
10
10
  leave(schema, ctx) {
11
11
  if (schema.examples) {
12
12
  for (const example of schema.examples) {
13
- utils_1.validateExample(example, schema, ctx.location.child(['examples', schema.examples.indexOf(example)]), ctx, disallowAdditionalProperties);
13
+ utils_1.validateExample(example, schema, ctx.location.child(['examples', schema.examples.indexOf(example)]), ctx, allowAdditionalProperties);
14
14
  }
15
15
  }
16
16
  if (schema.example) {
17
- utils_1.validateExample(schema.example, schema, ctx.location.child('example'), ctx, false);
17
+ utils_1.validateExample(schema.example, schema, ctx.location.child('example'), ctx, true);
18
18
  }
19
19
  },
20
20
  },
@@ -10,7 +10,7 @@ const OperationOperationId = () => {
10
10
  utils_1.validateDefinedAndNonEmpty('operationId', operation, ctx);
11
11
  },
12
12
  },
13
- }
13
+ },
14
14
  };
15
15
  };
16
16
  exports.OperationOperationId = OperationOperationId;
@@ -12,7 +12,7 @@ const PathNotIncludeQuery = () => {
12
12
  });
13
13
  }
14
14
  },
15
- }
15
+ },
16
16
  };
17
17
  };
18
18
  exports.PathNotIncludeQuery = PathNotIncludeQuery;
@@ -4,7 +4,10 @@ exports.PathsKebabCase = void 0;
4
4
  const PathsKebabCase = () => {
5
5
  return {
6
6
  PathItem(_path, { report, key }) {
7
- const segments = key.substr(1).split('/').filter(s => s !== ''); // filter out empty segments
7
+ const segments = key
8
+ .substr(1)
9
+ .split('/')
10
+ .filter((s) => s !== ''); // filter out empty segments
8
11
  if (!segments.every((segment) => /^{.+}$/.test(segment) || /^[a-z0-9-.]+$/.test(segment))) {
9
12
  report({
10
13
  message: `\`${key}\` does not use kebab-case.`,
@@ -45,7 +45,7 @@ const OasSpec = () => {
45
45
  }
46
46
  report({
47
47
  message: `The field \`${propName}\` is not allowed here.`,
48
- location: location.child([propName]).key()
48
+ location: location.child([propName]).key(),
49
49
  });
50
50
  }
51
51
  }