Spectral rules to check conformance to Azure API Guidelines
Перейти к файлу
Mike Kistler 1399ab263e Minor fix to operation-id rule 2021-09-06 20:26:28 -05:00
docs Minor fix to operation-id rule 2021-09-06 20:26:28 -05:00
functions Minor fix to operation-id rule 2021-09-06 20:26:28 -05:00
test Minor fix to operation-id rule 2021-09-06 20:26:28 -05:00
.eslintrc.js Initial ruleset for Azure API Guidelines 2021-09-06 20:26:20 -05:00
.gitignore Initial commit 2021-09-01 13:58:06 +00:00
.markdownlint.json Initial ruleset for Azure API Guidelines 2021-09-06 20:26:20 -05:00
CODE_OF_CONDUCT.md CODE_OF_CONDUCT.md committed 2021-09-01 06:58:09 -07:00
CONTRIBUTING.md Initial ruleset for Azure API Guidelines 2021-09-06 20:26:20 -05:00
LICENSE LICENSE committed 2021-09-01 06:58:09 -07:00
README.md Initial ruleset for Azure API Guidelines 2021-09-06 20:26:20 -05:00
SECURITY.md SECURITY.md committed 2021-09-01 06:58:11 -07:00
SUPPORT.md Initial ruleset for Azure API Guidelines 2021-09-06 20:26:20 -05:00
openapi-style-guidelines.md Minor fix to operation-id rule 2021-09-06 20:26:28 -05:00
package-lock.json Initial ruleset for Azure API Guidelines 2021-09-06 20:26:20 -05:00
package.json Initial ruleset for Azure API Guidelines 2021-09-06 20:26:20 -05:00
spectral.yaml Rename version-policy.js for consistency 2021-09-06 20:26:28 -05:00

README.md

Azure Spectral Ruleset

This repository contains a Spectral ruleset to check conformance to the Azure API Guidelines and the Azure OpenAPI Style Guidelines.

How to use

Install Spectral

npm install -g @stoplightio/spectral

Usage

You can specify the ruleset directly on the command line:

spectral lint -r https://raw.githubusercontent.com/azure/azure-spectral-ruleset/main/spectral.yaml <api definition file>

Or you can create a Spectral configuration file (.spectral.yaml) that references the ruleset:

extends:
  - https://raw.githubusercontent.com/azure/azure-spectral-ruleset/main/spectral.yaml

Example

spectral lint -r https://raw.githubusercontent.com/azure/azure-spectral-ruleset/main/spectral.yaml petstore.yaml

Using the Spectral VSCode extension

There is a Spectral VSCode extension that will run the Spectral linter on an open API definition file and show errors right within VSCode. You can use this ruleset with the Spectral VSCode extension.

  1. Install the Spectral VSCode extension from the extensions tab in VSCode.
  2. Create a Spectral configuration file (.spectral.yaml) in the root directory of your project as shown above.
  3. Set spectral.rulesetFile to the name of this configuration file in your VSCode settings.

Now when you open an API definition in this project, it should highlight lines with errors. You can also get a full list of problems in the file by opening the "Problems panel" with "View / Problems". In the Problems panel you can filter to show or hide errors, warnings, or infos.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.