Skip to content

Commit

Permalink
fix spectral ruleset addedOrChanged and changed (#2353)
Browse files Browse the repository at this point in the history
  • Loading branch information
niclim authored Sep 29, 2023
1 parent 41192ac commit 724f8fd
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "openapi-workspaces",
"license": "MIT",
"private": true,
"version": "0.50.4",
"version": "0.50.5",
"workspaces": [
"projects/json-pointer-helpers",
"projects/openapi-io",
Expand Down
2 changes: 1 addition & 1 deletion projects/fastify-capture/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/fastify-capture",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.50.4",
"version": "0.50.5",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/json-pointer-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/json-pointer-helpers",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.50.4",
"version": "0.50.5",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-io",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.50.4",
"version": "0.50.5",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/openapi-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/openapi-utilities",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.50.4",
"version": "0.50.5",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/optic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/optic",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.50.4",
"version": "0.50.5",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/rulesets-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/rulesets-base",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.50.4",
"version": "0.50.5",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion projects/standard-rulesets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@useoptic/standard-rulesets",
"license": "MIT",
"packageManager": "[email protected]",
"version": "0.50.4",
"version": "0.50.5",
"main": "build/index.js",
"types": "build/index.d.ts",
"files": [
Expand Down
35 changes: 34 additions & 1 deletion projects/standard-rulesets/src/spectral/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,41 @@ export class SpectralRulesets extends ExternalRuleBase {
matches: this.options.matches,
});
});
const changed = this.options.changed.map((ruleInput) => {
return new SpectralRule({
name:
'Spectral Rules applied to changes to the specification: ' +
ruleInput,
flatSpecFile: absolutePathTmpSpec,
applies: 'changed',
rulesetPointer: ruleInput,
matches: this.options.matches,
});
});
const addedOrChanged = this.options.addedOrChanged.flatMap((ruleInput) => {
return [
new SpectralRule({
name:
'Spectral Rules applied to additions to the specification: ' +
ruleInput,
flatSpecFile: absolutePathTmpSpec,
applies: 'added',
rulesetPointer: ruleInput,
matches: this.options.matches,
}),
new SpectralRule({
name:
'Spectral Rules applied to changes to the specification: ' +
ruleInput,
flatSpecFile: absolutePathTmpSpec,
applies: 'changed',
rulesetPointer: ruleInput,
matches: this.options.matches,
}),
];
});

const allRulesets = [...always, ...added];
const allRulesets = [...always, ...added, ...changed, ...addedOrChanged];

const allResults = await Promise.all(
allRulesets.map((ruleset) => ruleset.runRulesV2(inputs))
Expand Down

0 comments on commit 724f8fd

Please sign in to comment.