Skip to content

Commit 4aac04a

Browse files
committed
fix: fail severity
1 parent 96e9124 commit 4aac04a

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

spectral/index.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { cwd, env, exit } from "node:process";
1414
import { parseArgs } from "node:util";
1515

1616
import { error, notice, summary, warning } from "@actions/core";
17-
import { Document, Spectral } from "@stoplight/spectral-core";
17+
import { Document, Ruleset, Spectral } from "@stoplight/spectral-core";
1818
import Parsers from "@stoplight/spectral-parsers";
1919

2020
import { defaultRuleset } from "./ruleset";
@@ -39,7 +39,7 @@ const { values: { only = [], except = [], ci, fail }, positionals } = parseArgs(
3939
},
4040
fail: {
4141
type: "string",
42-
default: "2",
42+
default: "0",
4343
short: "f",
4444
}
4545
}
@@ -66,7 +66,7 @@ interface ExecuteOptions {
6666

6767
async function execute(filename: string, { only, except, failSeverity, ci }: ExecuteOptions) {
6868
const spectral = new Spectral();
69-
spectral.setRuleset(defaultRuleset);
69+
spectral.setRuleset(new Ruleset(defaultRuleset, { source: filename }));
7070

7171
if (except.length > 0)
7272
for (const rule of except)
@@ -100,7 +100,6 @@ async function execute(filename: string, { only, except, failSeverity, ci }: Exe
100100
summary.addRaw(`${diagnostics.length} issue(s).`, true);
101101
summary.addBreak();
102102

103-
// group by file.
104103
const diagnosticsBySource = diagnostics.reduce((acc, diag) => {
105104
const file = diag.source || "<unknown>";
106105
if (!acc[file]) acc[file] = [];

spectral/rules/operation-id.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const prefixesByType = {
1212
};
1313

1414
export const operationId = rule({
15+
severity: "hint",
1516
given: "#OperationObject",
1617
then: [
1718
{

spectral/ruleset.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,14 @@ export const defaultRuleset = ruleset({
3636
.map(([key, { recommended, ...value }]) => [key, value])
3737
),
3838
...rules
39-
}
39+
},
40+
overrides: [
41+
{
42+
files: ["openapi.yaml"],
43+
rules: {
44+
"oas3-schema": "off",
45+
"oas3-unused-component": "off"
46+
}
47+
}
48+
]
4049
});

0 commit comments

Comments
 (0)