@redocly/openapi-core 1.29.0 → 1.31.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 (40) hide show
  1. package/CHANGELOG.md +12 -4
  2. package/lib/config/all.js +1 -1
  3. package/lib/config/minimal.js +1 -1
  4. package/lib/config/recommended-strict.js +1 -1
  5. package/lib/config/recommended.js +1 -1
  6. package/lib/config/spec.js +1 -1
  7. package/lib/logger.d.ts +4 -1
  8. package/lib/logger.js +3 -2
  9. package/lib/rules/arazzo/index.js +3 -3
  10. package/lib/rules/arazzo/requestBody-replacements-unique.js +21 -16
  11. package/lib/rules/common/operation-tag-defined.js +7 -1
  12. package/lib/rules/{spot → respect}/no-criteria-xpath.js +1 -1
  13. package/lib/rules/respect/respect-supported-versions.d.ts +2 -0
  14. package/lib/rules/{spot/spot-supported-versions.js → respect/respect-supported-versions.js} +6 -6
  15. package/lib/types/redocly-yaml.d.ts +1 -1
  16. package/lib/types/redocly-yaml.js +1 -1
  17. package/lib/typings/arazzo.d.ts +1 -1
  18. package/lib/typings/arazzo.js +2 -2
  19. package/package.json +2 -1
  20. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +2 -2
  21. package/src/config/all.ts +1 -1
  22. package/src/config/minimal.ts +1 -1
  23. package/src/config/recommended-strict.ts +1 -1
  24. package/src/config/recommended.ts +1 -1
  25. package/src/config/spec.ts +1 -1
  26. package/src/logger.ts +3 -1
  27. package/src/rules/arazzo/__tests__/no-criteria-xpath.test.ts +2 -2
  28. package/src/rules/arazzo/__tests__/{spot-supported-versions.test.ts → respect-supported-versions.test.ts} +5 -5
  29. package/src/rules/arazzo/index.ts +3 -3
  30. package/src/rules/arazzo/requestBody-replacements-unique.ts +20 -15
  31. package/src/rules/common/__tests__/operation-tag-defined.test.ts +68 -0
  32. package/src/rules/common/operation-tag-defined.ts +6 -1
  33. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +2 -0
  34. package/src/rules/{spot → respect}/no-criteria-xpath.ts +1 -1
  35. package/src/rules/{spot/spot-supported-versions.ts → respect/respect-supported-versions.ts} +6 -6
  36. package/src/types/redocly-yaml.ts +1 -1
  37. package/src/typings/arazzo.ts +1 -1
  38. package/tsconfig.tsbuildinfo +1 -1
  39. package/lib/rules/spot/spot-supported-versions.d.ts +0 -2
  40. /package/lib/rules/{spot → respect}/no-criteria-xpath.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @redocly/openapi-core
2
2
 
3
+ ## 1.31.0
4
+
5
+ ## 1.30.0
6
+
7
+ ### Patch Changes
8
+
9
+ - Updated `operation-tag-defined` built-in rule to verify tags are defined on the operation prior to matching them to a global tag.
10
+
3
11
  ## 1.29.0
4
12
 
5
13
  ### Minor Changes
@@ -26,7 +34,7 @@
26
34
 
27
35
  ### Patch Changes
28
36
 
29
- - Added support for Arazzo version 1.0.1 in Spot validation rules.
37
+ - Added support for Arazzo version 1.0.1 in Respect validation rules.
30
38
 
31
39
  ## 1.28.1
32
40
 
@@ -67,13 +75,13 @@
67
75
 
68
76
  ### Patch Changes
69
77
 
70
- - Updated Spot validation rules.
78
+ - Updated Respect validation rules.
71
79
 
72
80
  ## 1.26.1
73
81
 
74
82
  ### Patch Changes
75
83
 
76
- - Removed the `no-actions-type-end` Spot rule.
84
+ - Removed the `no-actions-type-end` Respect rule.
77
85
  - Removed unused lodash.isequal dependency.
78
86
 
79
87
  ## 1.26.0
@@ -196,7 +204,7 @@
196
204
 
197
205
  ### Minor Changes
198
206
 
199
- - Added Spot and Arazzo rules: `no-criteria-xpath`, `no-actions-type-end`, `criteria-unique`.
207
+ - Added Respect and Arazzo rules: `no-criteria-xpath`, `no-actions-type-end`, `criteria-unique`.
200
208
 
201
209
  ### Patch Changes
202
210
 
package/lib/config/all.js CHANGED
@@ -222,7 +222,7 @@ const all = {
222
222
  'stepId-unique': 'error',
223
223
  'sourceDescription-name-unique': 'error',
224
224
  'sourceDescriptions-not-empty': 'error',
225
- 'spot-supported-versions': 'off',
225
+ 'respect-supported-versions': 'off',
226
226
  'workflowId-unique': 'error',
227
227
  'workflow-dependsOn': 'error',
228
228
  },
@@ -198,7 +198,7 @@ const minimal = {
198
198
  'step-onFailure-unique': 'off',
199
199
  'stepId-unique': 'error',
200
200
  'sourceDescription-name-unique': 'off',
201
- 'spot-supported-versions': 'off',
201
+ 'respect-supported-versions': 'off',
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'off',
204
204
  },
@@ -198,7 +198,7 @@ const recommendedStrict = {
198
198
  'stepId-unique': 'error',
199
199
  'sourceDescription-name-unique': 'error',
200
200
  'sourceDescriptions-not-empty': 'error',
201
- 'spot-supported-versions': 'off',
201
+ 'respect-supported-versions': 'off',
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'error',
204
204
  },
@@ -198,7 +198,7 @@ const recommended = {
198
198
  'stepId-unique': 'error',
199
199
  'sourceDescription-name-unique': 'error',
200
200
  'sourceDescriptions-not-empty': 'error',
201
- 'spot-supported-versions': 'off',
201
+ 'respect-supported-versions': 'off',
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'error',
204
204
  },
@@ -12,7 +12,7 @@ const spec = {
12
12
  async3Rules: {},
13
13
  arazzo1Rules: {
14
14
  'sourceDescription-type': 'error',
15
- 'spot-supported-versions': 'off',
15
+ 'respect-supported-versions': 'off',
16
16
  'workflowId-unique': 'error',
17
17
  'stepId-unique': 'error',
18
18
  'sourceDescription-name-unique': 'error',
package/lib/logger.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as colorette from 'colorette';
2
- export { options as colorOptions } from 'colorette';
2
+ export declare const colorOptions: {
3
+ enabled: boolean;
4
+ };
3
5
  export declare const colorize: typeof colorette;
4
6
  declare class Logger {
5
7
  protected stderr(str: string): boolean;
@@ -8,3 +10,4 @@ declare class Logger {
8
10
  error(str: string): boolean | void;
9
11
  }
10
12
  export declare const logger: Logger;
13
+ export {};
package/lib/logger.js CHANGED
@@ -4,8 +4,9 @@ exports.logger = exports.colorize = exports.colorOptions = void 0;
4
4
  const colorette = require("colorette");
5
5
  const env_1 = require("./env");
6
6
  const utils_1 = require("./utils");
7
- var colorette_1 = require("colorette");
8
- Object.defineProperty(exports, "colorOptions", { enumerable: true, get: function () { return colorette_1.options; } });
7
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
+ // @ts-ignore this works but some types are not working
9
+ exports.colorOptions = colorette.options;
9
10
  exports.colorize = new Proxy(colorette, {
10
11
  get(target, prop) {
11
12
  if (env_1.isBrowser) {
@@ -5,7 +5,7 @@ const struct_1 = require("../common/struct");
5
5
  const assertions_1 = require("../common/assertions");
6
6
  const sourceDescription_type_1 = require("../arazzo/sourceDescription-type");
7
7
  const sourceDescriptions_not_empty_1 = require("./sourceDescriptions-not-empty");
8
- const spot_supported_versions_1 = require("../spot/spot-supported-versions");
8
+ const respect_supported_versions_1 = require("../respect/respect-supported-versions");
9
9
  const workflowId_unique_1 = require("./workflowId-unique");
10
10
  const stepId_unique_1 = require("./stepId-unique");
11
11
  const sourceDescriptions_name_unique_1 = require("./sourceDescriptions-name-unique");
@@ -14,13 +14,13 @@ const parameters_unique_1 = require("./parameters-unique");
14
14
  const step_onSuccess_unique_1 = require("./step-onSuccess-unique");
15
15
  const step_onFailure_unique_1 = require("./step-onFailure-unique");
16
16
  const requestBody_replacements_unique_1 = require("./requestBody-replacements-unique");
17
- const no_criteria_xpath_1 = require("../spot/no-criteria-xpath");
17
+ const no_criteria_xpath_1 = require("../respect/no-criteria-xpath");
18
18
  const criteria_unique_1 = require("./criteria-unique");
19
19
  exports.rules = {
20
20
  struct: struct_1.Struct,
21
21
  assertions: assertions_1.Assertions,
22
22
  'sourceDescription-type': sourceDescription_type_1.SourceDescriptionType,
23
- 'spot-supported-versions': spot_supported_versions_1.SpotSupportedVersions,
23
+ 'respect-supported-versions': respect_supported_versions_1.RespectSupportedVersions,
24
24
  'workflowId-unique': workflowId_unique_1.WorkflowIdUnique,
25
25
  'stepId-unique': stepId_unique_1.StepIdUnique,
26
26
  'sourceDescription-name-unique': sourceDescriptions_name_unique_1.SourceDescriptionsNameUnique,
@@ -4,23 +4,28 @@ exports.RequestBodyReplacementsUnique = void 0;
4
4
  const RequestBodyReplacementsUnique = () => {
5
5
  const seenReplacements = new Set();
6
6
  return {
7
- RequestBody: {
8
- enter(requestBody, { report, location }) {
9
- if (!requestBody.replacements)
10
- return;
11
- for (const replacement of requestBody.replacements) {
12
- if (seenReplacements.has(replacement.target)) {
13
- report({
14
- message: 'Every `replacement` in `requestBody` must be unique.',
15
- location: location.child([
16
- 'replacements',
17
- requestBody.replacements.indexOf(replacement),
18
- `target`,
19
- ]),
20
- });
7
+ Step: {
8
+ leave() {
9
+ seenReplacements.clear();
10
+ },
11
+ RequestBody: {
12
+ enter(requestBody, { report, location }) {
13
+ if (!requestBody.replacements)
14
+ return;
15
+ for (const replacement of requestBody.replacements) {
16
+ if (seenReplacements.has(replacement.target)) {
17
+ report({
18
+ message: 'Every `replacement` in `requestBody` must be unique.',
19
+ location: location.child([
20
+ 'replacements',
21
+ requestBody.replacements.indexOf(replacement),
22
+ `target`,
23
+ ]),
24
+ });
25
+ }
26
+ seenReplacements.add(replacement.target);
21
27
  }
22
- seenReplacements.add(replacement.target);
23
- }
28
+ },
24
29
  },
25
30
  },
26
31
  };
@@ -8,7 +8,7 @@ const OperationTagDefined = () => {
8
8
  definedTags = new Set((root.tags ?? []).map((t) => t.name));
9
9
  },
10
10
  Operation(operation, { report, location }) {
11
- if (operation.tags) {
11
+ if (operation?.tags) {
12
12
  for (let i = 0; i < operation.tags.length; i++) {
13
13
  if (!definedTags.has(operation.tags[i])) {
14
14
  report({
@@ -18,6 +18,12 @@ const OperationTagDefined = () => {
18
18
  }
19
19
  }
20
20
  }
21
+ else {
22
+ report({
23
+ message: `Operation tags should be defined`,
24
+ location: location.key(),
25
+ });
26
+ }
21
27
  },
22
28
  };
23
29
  };
@@ -10,7 +10,7 @@ const NoCriteriaXpath = () => {
10
10
  }
11
11
  if (criteria?.type?.type === 'xpath' || criteria?.type === 'xpath') {
12
12
  report({
13
- message: 'The `xpath` type criteria is not supported by Spot.',
13
+ message: 'The `xpath` type criteria is not supported by Respect.',
14
14
  location: location.child(['type']),
15
15
  });
16
16
  }
@@ -0,0 +1,2 @@
1
+ import type { Arazzo1Rule } from '../../visitors';
2
+ export declare const RespectSupportedVersions: Arazzo1Rule;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SpotSupportedVersions = void 0;
3
+ exports.RespectSupportedVersions = void 0;
4
4
  const arazzo_1 = require("../../typings/arazzo");
5
5
  const utils_1 = require("../../utils");
6
- const SpotSupportedVersions = () => {
7
- const supportedVersions = arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_SPOT.join(', ');
6
+ const RespectSupportedVersions = () => {
7
+ const supportedVersions = arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.join(', ');
8
8
  return {
9
9
  Root: {
10
10
  enter(root, { report, location }) {
11
- if (!arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_SPOT.includes(root.arazzo)) {
11
+ if (!arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.includes(root.arazzo)) {
12
12
  report({
13
- message: `Only ${supportedVersions} Arazzo ${(0, utils_1.pluralize)('version is', arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_SPOT.length)} supported by Spot.`,
13
+ message: `Only ${supportedVersions} Arazzo ${(0, utils_1.pluralize)('version is', arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.length)} supported by Respect.`,
14
14
  location: location.child('arazzo'),
15
15
  });
16
16
  }
@@ -18,4 +18,4 @@ const SpotSupportedVersions = () => {
18
18
  },
19
19
  };
20
20
  };
21
- exports.SpotSupportedVersions = SpotSupportedVersions;
21
+ exports.RespectSupportedVersions = RespectSupportedVersions;
@@ -9,7 +9,7 @@ declare const builtInAsync2Rules: readonly ["info-contact", "info-license-strict
9
9
  declare const builtInAsync3Rules: readonly ["info-contact", "info-license-strict", "operation-operationId", "tag-description", "tags-alphabetical", "channels-kebab-case", "no-channel-trailing-slash"];
10
10
  export type BuiltInAsync2RuleId = typeof builtInAsync2Rules[number];
11
11
  export type BuiltInAsync3RuleId = typeof builtInAsync3Rules[number];
12
- declare const builtInArazzo1Rules: readonly ["sourceDescription-type", "workflowId-unique", "stepId-unique", "sourceDescription-name-unique", "sourceDescriptions-not-empty", "workflow-dependsOn", "parameters-unique", "step-onSuccess-unique", "step-onFailure-unique", "spot-supported-versions", "requestBody-replacements-unique", "no-criteria-xpath", "criteria-unique"];
12
+ declare const builtInArazzo1Rules: readonly ["sourceDescription-type", "workflowId-unique", "stepId-unique", "sourceDescription-name-unique", "sourceDescriptions-not-empty", "workflow-dependsOn", "parameters-unique", "step-onSuccess-unique", "step-onFailure-unique", "respect-supported-versions", "requestBody-replacements-unique", "no-criteria-xpath", "criteria-unique"];
13
13
  export type BuiltInArazzo1RuleId = typeof builtInArazzo1Rules[number];
14
14
  declare const oas2NodeTypesList: readonly ["Root", "Tag", "TagList", "ExternalDocs", "SecurityRequirement", "SecurityRequirementList", "Info", "Contact", "License", "Paths", "PathItem", "Parameter", "ParameterList", "ParameterItems", "Operation", "Example", "ExamplesMap", "Examples", "Header", "Responses", "Response", "Schema", "Xml", "SchemaProperties", "NamedSchemas", "NamedResponses", "NamedParameters", "NamedSecuritySchemes", "SecurityScheme", "TagGroup", "TagGroups", "EnumDescriptions", "Logo", "XCodeSample", "XCodeSampleList", "XServer", "XServerList"];
15
15
  export type Oas2NodeType = typeof oas2NodeTypesList[number];
@@ -139,7 +139,7 @@ const builtInArazzo1Rules = [
139
139
  'parameters-unique',
140
140
  'step-onSuccess-unique',
141
141
  'step-onFailure-unique',
142
- 'spot-supported-versions',
142
+ 'respect-supported-versions',
143
143
  'requestBody-replacements-unique',
144
144
  'no-criteria-xpath',
145
145
  'criteria-unique',
@@ -128,4 +128,4 @@ export interface ArazzoDefinition {
128
128
  };
129
129
  }
130
130
  export declare const VERSION_PATTERN: RegExp;
131
- export declare const ARAZZO_VERSIONS_SUPPORTED_BY_SPOT: string[];
131
+ export declare const ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT: string[];
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ARAZZO_VERSIONS_SUPPORTED_BY_SPOT = exports.VERSION_PATTERN = void 0;
3
+ exports.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT = exports.VERSION_PATTERN = void 0;
4
4
  exports.VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/;
5
- exports.ARAZZO_VERSIONS_SUPPORTED_BY_SPOT = ['1.0.1'];
5
+ exports.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT = ['1.0.1'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-core",
3
- "version": "1.29.0",
3
+ "version": "1.31.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "engines": {
@@ -28,6 +28,7 @@
28
28
  "OpenAPI linter",
29
29
  "Swagger linter",
30
30
  "AsyncAPI linter",
31
+ "Arazzo linter",
31
32
  "oas"
32
33
  ],
33
34
  "contributors": [
@@ -9,10 +9,10 @@ exports[`resolveConfig should ignore minimal from the root and read local file 1
9
9
  "no-criteria-xpath": "off",
10
10
  "parameters-unique": "error",
11
11
  "requestBody-replacements-unique": "warn",
12
+ "respect-supported-versions": "off",
12
13
  "sourceDescription-name-unique": "error",
13
14
  "sourceDescription-type": "error",
14
15
  "sourceDescriptions-not-empty": "error",
15
- "spot-supported-versions": "off",
16
16
  "step-onFailure-unique": "warn",
17
17
  "step-onSuccess-unique": "warn",
18
18
  "stepId-unique": "error",
@@ -238,10 +238,10 @@ exports[`resolveStyleguideConfig should resolve extends with local file config w
238
238
  "no-criteria-xpath": "off",
239
239
  "parameters-unique": "error",
240
240
  "requestBody-replacements-unique": "warn",
241
+ "respect-supported-versions": "off",
241
242
  "sourceDescription-name-unique": "error",
242
243
  "sourceDescription-type": "error",
243
244
  "sourceDescriptions-not-empty": "error",
244
- "spot-supported-versions": "off",
245
245
  "step-onFailure-unique": "warn",
246
246
  "step-onSuccess-unique": "warn",
247
247
  "stepId-unique": "error",
package/src/config/all.ts CHANGED
@@ -222,7 +222,7 @@ const all: PluginStyleguideConfig<'built-in'> = {
222
222
  'stepId-unique': 'error',
223
223
  'sourceDescription-name-unique': 'error',
224
224
  'sourceDescriptions-not-empty': 'error',
225
- 'spot-supported-versions': 'off',
225
+ 'respect-supported-versions': 'off',
226
226
  'workflowId-unique': 'error',
227
227
  'workflow-dependsOn': 'error',
228
228
  },
@@ -198,7 +198,7 @@ const minimal: PluginStyleguideConfig<'built-in'> = {
198
198
  'step-onFailure-unique': 'off',
199
199
  'stepId-unique': 'error',
200
200
  'sourceDescription-name-unique': 'off',
201
- 'spot-supported-versions': 'off',
201
+ 'respect-supported-versions': 'off',
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'off',
204
204
  },
@@ -198,7 +198,7 @@ const recommendedStrict: PluginStyleguideConfig<'built-in'> = {
198
198
  'stepId-unique': 'error',
199
199
  'sourceDescription-name-unique': 'error',
200
200
  'sourceDescriptions-not-empty': 'error',
201
- 'spot-supported-versions': 'off',
201
+ 'respect-supported-versions': 'off',
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'error',
204
204
  },
@@ -198,7 +198,7 @@ const recommended: PluginStyleguideConfig<'built-in'> = {
198
198
  'stepId-unique': 'error',
199
199
  'sourceDescription-name-unique': 'error',
200
200
  'sourceDescriptions-not-empty': 'error',
201
- 'spot-supported-versions': 'off',
201
+ 'respect-supported-versions': 'off',
202
202
  'workflowId-unique': 'error',
203
203
  'workflow-dependsOn': 'error',
204
204
  },
@@ -12,7 +12,7 @@ const spec: PluginStyleguideConfig<'built-in'> = {
12
12
  async3Rules: {},
13
13
  arazzo1Rules: {
14
14
  'sourceDescription-type': 'error',
15
- 'spot-supported-versions': 'off',
15
+ 'respect-supported-versions': 'off',
16
16
  'workflowId-unique': 'error',
17
17
  'stepId-unique': 'error',
18
18
  'sourceDescription-name-unique': 'error',
package/src/logger.ts CHANGED
@@ -2,7 +2,9 @@ import * as colorette from 'colorette';
2
2
  import { isBrowser } from './env';
3
3
  import { identity } from './utils';
4
4
 
5
- export { options as colorOptions } from 'colorette';
5
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
+ // @ts-ignore this works but some types are not working
7
+ export const colorOptions = colorette.options;
6
8
 
7
9
  export const colorize = new Proxy(colorette, {
8
10
  get(target: typeof colorette, prop: string): typeof identity {
@@ -90,7 +90,7 @@ describe('Arazzo no-criteria-xpath', () => {
90
90
  "source": "arazzo.yaml",
91
91
  },
92
92
  ],
93
- "message": "The \`xpath\` type criteria is not supported by Spot.",
93
+ "message": "The \`xpath\` type criteria is not supported by Respect.",
94
94
  "ruleId": "no-criteria-xpath",
95
95
  "severity": "error",
96
96
  "suggest": [],
@@ -103,7 +103,7 @@ describe('Arazzo no-criteria-xpath', () => {
103
103
  "source": "arazzo.yaml",
104
104
  },
105
105
  ],
106
- "message": "The \`xpath\` type criteria is not supported by Spot.",
106
+ "message": "The \`xpath\` type criteria is not supported by Respect.",
107
107
  "ruleId": "no-criteria-xpath",
108
108
  "severity": "error",
109
109
  "suggest": [],
@@ -3,7 +3,7 @@ import { lintDocument } from '../../../lint';
3
3
  import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
4
4
  import { BaseResolver } from '../../../resolve';
5
5
 
6
- describe('Arazzo spot-supported-versions', () => {
6
+ describe('Arazzo respect-supported-versions', () => {
7
7
  const documentWithUnsupportedVersion = parseYamlToDocument(
8
8
  outdent`
9
9
  arazzo: '1.0.2'
@@ -67,7 +67,7 @@ describe('Arazzo spot-supported-versions', () => {
67
67
  externalRefResolver: new BaseResolver(),
68
68
  document: documentWithUnsupportedVersion,
69
69
  config: await makeConfig({
70
- rules: { 'spot-supported-versions': 'error' },
70
+ rules: { 'respect-supported-versions': 'error' },
71
71
  }),
72
72
  });
73
73
 
@@ -81,8 +81,8 @@ describe('Arazzo spot-supported-versions', () => {
81
81
  "source": "arazzo.yaml",
82
82
  },
83
83
  ],
84
- "message": "Only 1.0.1 Arazzo version is supported by Spot.",
85
- "ruleId": "spot-supported-versions",
84
+ "message": "Only 1.0.1 Arazzo version is supported by Respect.",
85
+ "ruleId": "respect-supported-versions",
86
86
  "severity": "error",
87
87
  "suggest": [],
88
88
  },
@@ -95,7 +95,7 @@ describe('Arazzo spot-supported-versions', () => {
95
95
  externalRefResolver: new BaseResolver(),
96
96
  document: documentWithSupportedVersion,
97
97
  config: await makeConfig({
98
- rules: { 'spot-supported-versions': 'error' },
98
+ rules: { 'respect-supported-versions': 'error' },
99
99
  }),
100
100
  });
101
101
 
@@ -2,7 +2,7 @@ import { Struct } from '../common/struct';
2
2
  import { Assertions } from '../common/assertions';
3
3
  import { SourceDescriptionType } from '../arazzo/sourceDescription-type';
4
4
  import { SourceDescriptionsNotEmpty } from './sourceDescriptions-not-empty';
5
- import { SpotSupportedVersions } from '../spot/spot-supported-versions';
5
+ import { RespectSupportedVersions } from '../respect/respect-supported-versions';
6
6
  import { WorkflowIdUnique } from './workflowId-unique';
7
7
  import { StepIdUnique } from './stepId-unique';
8
8
  import { SourceDescriptionsNameUnique } from './sourceDescriptions-name-unique';
@@ -11,7 +11,7 @@ import { ParametersUnique } from './parameters-unique';
11
11
  import { StepOnSuccessUnique } from './step-onSuccess-unique';
12
12
  import { StepOnFailureUnique } from './step-onFailure-unique';
13
13
  import { RequestBodyReplacementsUnique } from './requestBody-replacements-unique';
14
- import { NoCriteriaXpath } from '../spot/no-criteria-xpath';
14
+ import { NoCriteriaXpath } from '../respect/no-criteria-xpath';
15
15
  import { CriteriaUnique } from './criteria-unique';
16
16
 
17
17
  import type { Arazzo1Rule } from '../../visitors';
@@ -21,7 +21,7 @@ export const rules: Arazzo1RuleSet<'built-in'> = {
21
21
  struct: Struct as Arazzo1Rule,
22
22
  assertions: Assertions as Arazzo1Rule,
23
23
  'sourceDescription-type': SourceDescriptionType,
24
- 'spot-supported-versions': SpotSupportedVersions,
24
+ 'respect-supported-versions': RespectSupportedVersions,
25
25
  'workflowId-unique': WorkflowIdUnique,
26
26
  'stepId-unique': StepIdUnique,
27
27
  'sourceDescription-name-unique': SourceDescriptionsNameUnique,
@@ -5,23 +5,28 @@ export const RequestBodyReplacementsUnique: Arazzo1Rule = () => {
5
5
  const seenReplacements = new Set();
6
6
 
7
7
  return {
8
- RequestBody: {
9
- enter(requestBody, { report, location }: UserContext) {
10
- if (!requestBody.replacements) return;
8
+ Step: {
9
+ leave() {
10
+ seenReplacements.clear();
11
+ },
12
+ RequestBody: {
13
+ enter(requestBody, { report, location }: UserContext) {
14
+ if (!requestBody.replacements) return;
11
15
 
12
- for (const replacement of requestBody.replacements) {
13
- if (seenReplacements.has(replacement.target)) {
14
- report({
15
- message: 'Every `replacement` in `requestBody` must be unique.',
16
- location: location.child([
17
- 'replacements',
18
- requestBody.replacements.indexOf(replacement),
19
- `target`,
20
- ]),
21
- });
16
+ for (const replacement of requestBody.replacements) {
17
+ if (seenReplacements.has(replacement.target)) {
18
+ report({
19
+ message: 'Every `replacement` in `requestBody` must be unique.',
20
+ location: location.child([
21
+ 'replacements',
22
+ requestBody.replacements.indexOf(replacement),
23
+ `target`,
24
+ ]),
25
+ });
26
+ }
27
+ seenReplacements.add(replacement.target);
22
28
  }
23
- seenReplacements.add(replacement.target);
24
- }
29
+ },
25
30
  },
26
31
  },
27
32
  };
@@ -0,0 +1,68 @@
1
+ import { outdent } from 'outdent';
2
+ import { lintDocument } from '../../../lint';
3
+ import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
4
+ import { BaseResolver } from '../../../resolve';
5
+
6
+ describe('Oas3 operation-tag-defined', () => {
7
+ it('should not report on operation object if at least one tag is defined', async () => {
8
+ const document = parseYamlToDocument(
9
+ outdent`
10
+ openapi: 3.0.4
11
+ tags:
12
+ - name: a
13
+ paths:
14
+ /some:
15
+ get:
16
+ tags:
17
+ - a
18
+ `,
19
+ 'foobar.yaml'
20
+ );
21
+
22
+ const results = await lintDocument({
23
+ externalRefResolver: new BaseResolver(),
24
+ document,
25
+ config: await makeConfig({ rules: { 'operation-tag-defined': 'error' } }),
26
+ });
27
+
28
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`[]`);
29
+ });
30
+
31
+ it('should report on operation object if no tags are defined', async () => {
32
+ const document = parseYamlToDocument(
33
+ outdent`
34
+ openapi: 3.0.4
35
+ tags:
36
+ - name: a
37
+ paths:
38
+ /some:
39
+ get:
40
+ `,
41
+ 'foobar.yaml'
42
+ );
43
+
44
+ const results = await lintDocument({
45
+ externalRefResolver: new BaseResolver(),
46
+ document,
47
+ config: await makeConfig({ rules: { 'operation-tag-defined': 'error' } }),
48
+ });
49
+
50
+ expect(replaceSourceWithRef(results)).toMatchInlineSnapshot(`
51
+ [
52
+ {
53
+ "location": [
54
+ {
55
+ "pointer": "#/paths/~1some/get",
56
+ "reportOnKey": true,
57
+ "source": "foobar.yaml",
58
+ },
59
+ ],
60
+ "message": "Operation tags should be defined",
61
+ "ruleId": "operation-tag-defined",
62
+ "severity": "error",
63
+ "suggest": [],
64
+ },
65
+ ]
66
+ `);
67
+ });
68
+ });
@@ -11,7 +11,7 @@ export const OperationTagDefined: Oas3Rule | Oas2Rule = () => {
11
11
  definedTags = new Set((root.tags ?? []).map((t) => t.name));
12
12
  },
13
13
  Operation(operation: Oas2Operation | Oas3Operation, { report, location }: UserContext) {
14
- if (operation.tags) {
14
+ if (operation?.tags) {
15
15
  for (let i = 0; i < operation.tags.length; i++) {
16
16
  if (!definedTags.has(operation.tags[i])) {
17
17
  report({
@@ -20,6 +20,11 @@ export const OperationTagDefined: Oas3Rule | Oas2Rule = () => {
20
20
  });
21
21
  }
22
22
  }
23
+ } else {
24
+ report({
25
+ message: `Operation tags should be defined`,
26
+ location: location.key(),
27
+ });
23
28
  }
24
29
  },
25
30
  };
@@ -3,6 +3,8 @@ import { lintDocument } from '../../../lint';
3
3
  import { parseYamlToDocument, replaceSourceWithRef, makeConfig } from '../../../../__tests__/utils';
4
4
  import { BaseResolver } from '../../../resolve';
5
5
 
6
+ jest.setTimeout(10000);
7
+
6
8
  describe('no-invalid-media-type-examples', () => {
7
9
  it('should report on invalid example', async () => {
8
10
  const document = parseYamlToDocument(