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

Update spectral rule to handle null values error in example fields #337

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
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
18 changes: 12 additions & 6 deletions artifacts/linting_rules/.spectral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,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 +219,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