Skip to content

Commit

Permalink
Merge pull request #337 from ravindrapalaskar17/Update-Spectral-rule
Browse files Browse the repository at this point in the history
Update spectral rule to handle null values error in example fields
  • Loading branch information
rartych authored Dec 20, 2024
2 parents 2afc51f + aa4244f commit 0270f54
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions artifacts/linting_rules/.spectral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# 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


extends: "spectral:oas"
Expand Down Expand Up @@ -84,12 +85,12 @@ 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:
Expand Down Expand Up @@ -219,11 +220,17 @@ 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:
Expand Down

0 comments on commit 0270f54

Please sign in to comment.