api-quality-spectral-ruleset 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +69 -0
- package/apq-spectral.yaml +1119 -0
- package/functions/apq-alternate-paths.js +35 -0
- package/functions/apq-at-most-one-body-parameter.js +24 -0
- package/functions/apq-compare-insensitive.js +33 -0
- package/functions/apq-custom-schema.js +88 -0
- package/functions/apq-default-value.js +23 -0
- package/functions/apq-naming-convention.js +21 -0
- package/functions/apq-parameter-naming-convention.js +76 -0
- package/functions/apq-properties-schema-format.js +29 -0
- package/functions/apq-resources-by-verb.js +117 -0
- package/functions/apq-responses.js +26 -0
- package/functions/apq-schema-format.js +98 -0
- package/functions/apq-standard-response-codes.js +76 -0
- package/functions/apq-truthy-insensitive.js +18 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<!-- README.md -->
|
|
2
|
+
|
|
3
|
+
[](https://github.com/apiaddicts/apquality-spectral/actions/workflows/node.js.yml) 
|
|
4
|
+
|
|
5
|
+
# APIAddicts Style Guide Spectral
|
|
6
|
+
|
|
7
|
+
This repository contains a Style Guide for OpenAPI definitions.
|
|
8
|
+
The Style Guide is the spectral guide that implements similar rules that sonarapi-rules. It's used by [ApiQuality Guidelines](https://apiquality.io) and another users.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
> **NOTE:** It is highly recommended that you leverage the Spectral rule set. APIAddicts team have found Spectral to be very useful identifying many common mistakes that affect the overall quality of their Open API documentation. It's one of the first things the API Stewardship Board turns to when reviewing an API specification.
|
|
12
|
+
>
|
|
13
|
+
> However, the errors, warnings, and info messages identified by Spectral should be evaluated in the context of *your service*, and using *your judgement*. If you have any questions, concerns, or comments, please don't hesitate to start a discussion in the [API Stewardship Teams Channel](https://github.com/apiaddicts/apiaddicts-style-guide-spectral/issues).
|
|
14
|
+
|
|
15
|
+
## How to use the Spectral Ruleset
|
|
16
|
+
|
|
17
|
+
### Dependencies
|
|
18
|
+
|
|
19
|
+
The Spectral Ruleset requires Node version 14 or later.
|
|
20
|
+
|
|
21
|
+
### Install Spectral
|
|
22
|
+
|
|
23
|
+
`npm i @stoplight/spectral-cli -g`
|
|
24
|
+
|
|
25
|
+
### Usage
|
|
26
|
+
|
|
27
|
+
You can specify the ruleset directly on the command line:
|
|
28
|
+
|
|
29
|
+
`spectral lint -r https://raw.githubusercontent.com/apiaddicts/apquality-spectral/refs/heads/main/apq-spectral.yaml <api definition file>`
|
|
30
|
+
|
|
31
|
+
Or you can create a Spectral configuration file (`.spectral.yaml`) that references the ruleset:
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
extends:
|
|
35
|
+
- https://raw.githubusercontent.com/apiaddicts/apquality-spectral/refs/heads/main/apq-spectral.yaml
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Example
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
spectral lint -r https://raw.githubusercontent.com/apiaddicts/apquality-spectral/refs/heads/main/apq-spectral.yaml petstore.yaml
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Using the Spectral VSCode extension
|
|
45
|
+
|
|
46
|
+
There is a [Spectral VSCode extension](https://marketplace.visualstudio.com/items?itemName=stoplight.spectral) 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.
|
|
47
|
+
|
|
48
|
+
1. Install the Spectral VSCode extension from the extensions tab in VSCode.
|
|
49
|
+
2. Create a Spectral configuration file (`.spectral.yaml`) in the root directory of your project
|
|
50
|
+
as shown above.
|
|
51
|
+
3. Set `spectral.rulesetFile` to the name of this configuration file in your VSCode settings.
|
|
52
|
+
|
|
53
|
+
Now when you open an API definition in this project, it should highlight lines with errors.
|
|
54
|
+
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.
|
|
55
|
+
|
|
56
|
+
## Contributing
|
|
57
|
+
|
|
58
|
+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
|
|
59
|
+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
|
|
60
|
+
the rights to use your contribution.
|
|
61
|
+
|
|
62
|
+
When you submit a pull request, an ApiQuality team member will determine whether you need to provide
|
|
63
|
+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
|
|
64
|
+
provided by the Pull Request template.
|
|
65
|
+
|
|
66
|
+
## Trademarks
|
|
67
|
+
|
|
68
|
+
This project may contain trademarks or logos for projects, products, or services. Authorized use of ApiQuality
|
|
69
|
+
trademarks. Any use of third-party trademarks or logos are subject to those third-party's policies.
|