Skip to content
Merged
73 changes: 73 additions & 0 deletions .gherkin-lintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"no-files-without-scenarios" : "on",
"no-unnamed-features": "on",
"no-unnamed-scenarios": "on",
"no-dupe-scenario-names": ["on", "in-feature"],
"no-dupe-feature-names": "on",
"no-partially-commented-tag-lines": "on",
"indentation" : [
"on", {
"Feature": 0,
"Background": 2,
"Scenario": 2,
"Step": 2,
"Examples": 4,
"example": 6,
"given": 4,
"when": 4,
"then": 4,
"and": 4,
"but": 4,
"feature tag": 2,
"scenario tag": 2
}
],
"no-trailing-spaces": "on",
"new-line-at-eof": ["on", "no"],
"no-multiple-empty-lines": "on",
"no-empty-file": "on",
"no-scenario-outlines-without-examples": "on",
"name-length": ["on", {"Feature": 90, "Step": 190, "Scenario": 190}],
"no-restricted-tags": ["on", {"tags": ["@watch", "@wip"]}],
"use-and": "on",
"keywords-in-logical-order": "on",
"no-duplicate-tags": "on",
"no-superfluous-tags": "on",
"no-homogenous-tags": "on",
"one-space-between-tags": "on",
"no-unused-variables": "on",
"no-background-only-scenario": "on",
"no-empty-background": "on",
"scenario-size": ["on", { "steps-length": {"Background": 15, "Scenario": 15}}],
"only-one-when": "off",
"allowed-tags": ["on", {
"patterns": [
"^@watch$",
"^@wip$",
"^@.*$"
]
}],
"file-name": ["off", {"style": "kebab-case"}],
"max-scenarios-per-file": ["on", {"maxScenarios": 50, "countOutlineExamples": true}],
"no-restricted-patterns": ["on", {
"Global": [
"^globally restricted pattern"
],
"Feature": [
"poor description",
"validate",
],
"Background": [
"show last response",
"a debugging step"
],
"Scenario": [
"show last response",
"a debugging step"
]
}],
"required-tags": ["on", {
"tags": ["^@.*$"],
"ignoreUntagged": false
}]
}
8 changes: 6 additions & 2 deletions .github/workflows/megalinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ jobs:
run: npm install -g @stoplight/spectral
- name: Install Spectral functions
run: npm install -g @stoplight/spectral-functions
# - name: Run spectral:oas Spectral Linting
# run: spectral lint code/API_definitions/*.yaml --verbose --ruleset .spectral.yml
- name: Install Gherkin Linter
run: npm install -g gherkin-lint
- name: Run Gherkin Linting
run: gherkin-lint code/Test_definitions/*.feature
# - name: Run spectral:oas Spectral Linting
# run: spectral lint code/API_definitions/*.yaml --verbose --ruleset .spectral.yml
# Replace openapi.yaml file with your API specification file

# MegaLinter
Expand Down
40 changes: 24 additions & 16 deletions .spectral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Changelog:
# - 31.01.2024: Initial version
# - 19.03.2024: Corrected camara-http-methods rule
# - 03.12.2024: Corrected camara-path-param-id and camara-discriminator-use to handle null values error in example fields
# - 09.01.2025: Updated info-contact rule


extends: "spectral:oas"
Expand All @@ -16,7 +18,7 @@ rules:
# The severity keyword is optional in rule definition and can be error, warn, info, hint, or off. The default value is warn.
contact-properties: false
duplicated-entry-in-enum: true
info-contact: true
info-contact: false
info-description: true
info-license: true
license-url: true
Expand Down Expand Up @@ -84,16 +86,16 @@ rules:
description: |
This rule ensures consistent and descriptive naming for path parameters in your OpenAPI specification.
Please use 'resource_id' instead of just 'id' for your path parameters.
given: "$..parameters[?(@.in == 'path')]"
given: "$.paths[*][*].parameters[?(@.in == 'path')].name"
then:
field: name
function: pattern
functionOptions:
notMatch: \b(id|Id|ID|iD)\b
match: "^(?!.*\\b(id|Id|ID|iD)\\b).*$"
recommended: true # Set to true/false to enable/disable this rule

camara-security-no-secrets-in-path-or-query-parameters:
message: "Sensitive data found in path: {{error}} Consider avoiding the use of Sesentive data "
message: "Sensitive data found in path: {{error}} Consider avoiding the use of sensitive data "
severity: warn
description: |
This rule checks for sensitive data ('MSISDN' and 'IMSI') in API paths and suggests avoiding their use.
Expand Down Expand Up @@ -146,8 +148,8 @@ rules:
message: "Functionality method description Warning: Each method should have description."
severity: warn
description: |
This rule checks if each operation (POST, GET, DELETE, PUT, PATCH, OPTIONS) in your API specification has a description.
Ensure that you have added a 'summary' field for each operation in your OpenAPI specification.
This rule checks if each operation (POST, GET, DELETE, PUT, PATCH, OPTIONS) in your API specification has a description.
Ensure that you have added a 'summary' field for each operation in your OpenAPI specification.
given:
- "$.paths.*.post"
- "$.paths.*.get"
Expand All @@ -159,7 +161,7 @@ rules:
field: description
function: truthy
recommended: true # Set to true/false to enable/disable this rule

camara-parameters-descriptions:
message: "Parameter description is missing or empty: {{error}}"
severity: warn
Expand All @@ -171,7 +173,7 @@ rules:
field: description
function: truthy
recommended: true # Set to true/false to enable/disable this rule

camara-response-descriptions:
message: "Parameter description is missing or empty: {{error}}"
severity: warn
Expand All @@ -196,13 +198,13 @@ rules:
field: description
function: truthy
recommended: true # Set to true/false to enable/disable this rule

camara-operation-summary:
message: "Operation Summary Warning: Each operation should include a short summary for better understanding."
severity: warn
description: |
This rule checks if each operation (POST, GET, DELETE, PUT, PATCH, OPTIONS) in your API specification has a meaningful summary.
Ensure that you have added a 'summary' field for each operation in your OpenAPI specification.
This rule checks if each operation (POST, GET, DELETE, PUT, PATCH, OPTIONS) in your API specification has a meaningful summary.
Ensure that you have added a 'summary' field for each operation in your OpenAPI specification.
given:
- "$.paths.*.post"
- "$.paths.*.get"
Expand All @@ -219,18 +221,24 @@ rules:
description: |
Ensure that API definition YAML files with oneOf or anyOf sections include a discriminator object for serialization, deserialization, and validation.
severity: hint
given: "$..[?(@.oneOf || @.anyOf)]"
given: "$.components.schemas[*]"
then:
field: discriminator
function: truthy
description: "Discriminator object is required when using oneOf or anyOf."
- field: oneOf
function: truthy
message: "Schemas with 'oneOf' should include a 'discriminator' for type identification."
- field: anyOf
function: truthy
message: "Schemas with 'anyOf' should include a 'discriminator' for type identification."
- field: discriminator
function: truthy
message: "A 'discriminator' object is required when using 'oneOf' or 'anyOf'."
recommended: true # Set to true/false to enable/disable this rule

camara-operationid-casing-convention:
message: Operation Id must be in Camel case "{{error}}"
severity: hint
description: |
This rule checks Operation ids should follow a specific case convention: camel case.
This rule checks Operation ids should follow a specific case convention: camel case.
given: "$.paths.*.*.operationId"
then:
function: casing
Expand Down
Loading