Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Relax the aggressive of the id vs identifier detection #89

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rulesets/src/naming.ruleset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ rules:
then:
function: pattern
functionOptions:
notMatch: "(^identifier([A-Z]|$)|.*Identifier([A-Z]|$))"
notMatch: "^identifier$"

sps-mandate-abbreviations-organization:
description: Use abbreviations instead of long form names, i.e. organization SHOULD BE org.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe("sps-mandate-abbreviations-identifier", () => {
await spectral.validateFailure(spec, ruleName, "Warning", 1);
});

test("identifier should warn when it is a word present in the field name", async () => {
test("identifier should not warn when it is a word present in the field name prefix", async () => {
const spec = `
openapi: 3.0.1
paths: {}
Expand All @@ -70,9 +70,24 @@ describe("sps-mandate-abbreviations-identifier", () => {
properties:
identifierNumber:
type: number
NumberIdentifier
`;

await spectral.validateFailure(spec, ruleName, "Warning", 1);
await spectral.validateSuccess(spec, ruleName);
});

test("identifier should not warn when it is a word present in the field name suffix", async () => {
const spec = `
openapi: 3.0.1
paths: {}
components:
schemas:
User:
type: object
properties:
externalIdentifier:
type: number
`;

await spectral.validateSuccess(spec, ruleName);
});
});
2 changes: 1 addition & 1 deletion sps-api-standards.spectral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ rules:
then:
function: pattern
functionOptions:
notMatch: "(^identifier([A-Z]|$)|.*Identifier([A-Z]|$))"
notMatch: "^identifier$"
sps-mandate-abbreviations-organization:
description: Use abbreviations instead of long form names, i.e. organization SHOULD BE org.
severity: warn
Expand Down
Loading