beacon-APIs
beacon-APIs copied to clipboard
Create spectral rule to enforce quotes
Rule should be in .spectral.yml in root directory of repository.It should throw error if non double quotes are used.
To enforce the use of double quotes in your repository, you can create a rule in the .spectral.yml file. Here's an example of how you can define the rule:
rules:
enforce-double-quotes:
given: "$..[?(@.type == 'string')]"
then:
field: "pattern"
function: "pattern"
functionOptions:
match: "^[^\"]*$"
message: "Double quotes must be used for string values."
This rule targets all string values in your repository and checks if they contain any characters other than double quotes. If any non-double quote characters are found, it will throw an error with the specified message.
Make sure to place this rule in the .spectral.yml file in the root directory of your repository.