Skip to content

Commit a34a9ff

Browse files
author
Sophia Marie Terry
committed
Move package into ipa directory
1 parent 158e3cd commit a34a9ff

File tree

6 files changed

+73
-13023
lines changed

6 files changed

+73
-13023
lines changed

tools/spectral/README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@
22

33
A set of custom validation rules for the MongoDB Atlas Programmatic API, adhering to API Standards (IPA).
44

5-
## Quick Links
6-
7-
| Site | Link |
8-
| --------------------------- | -------------------------------------------------------------------------------------------------------- |
9-
| MongoDB API Standards (IPA) | [https://mongodb.github.io/ipa/](https://mongodb.github.io/ipa/) |
10-
| Installation & Usage | [IPA README](https://github.com/mongodb/openapi/tree/main/tools/spectral/ipa#readme) |
11-
| Implemented Rules | [Ruleset Documentation](https://github.com/mongodb/openapi/tree/main/tools/spectral/ipa/rulesets#readme) |
12-
| Spectral Docs | [Spectral](https://docs.stoplight.io/docs/spectral/674b27b261c3c-overview) |
13-
| Spectral Wiki (Internal) | [http://go/openapi-spectral-updates](http://go/openapi-spectral-updates) |
14-
| Contributing | [CONTRIBUTING.md](https://github.com/mongodb/openapi/blob/main/tools/spectral/CONTRIBUTING.md) |
15-
| Changelog | [CHANGELOG.md](https://github.com/mongodb/openapi/blob/main/tools/spectral/CHANGELOG.md) |
16-
| Issues | [https://github.com/mongodb/openapi/issues](https://github.com/mongodb/openapi/issues) |
17-
18-
195
## Structure
206

217
- **/ipa** - Contains custom Spectral rulesets covering MongoDB API standards.

tools/spectral/ipa/README.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
The IPA validation uses [Spectral](https://docs.stoplight.io/docs/spectral/9ffa04e052cc1-spectral-cli) to validate the [MongoDB Atlas Admin API OpenAPI Specification](https://github.com/mongodb/openapi/tree/main/openapi). The rules cover MongoDB's [Improvement Proposal for APIs](https://mongodb.github.io/ipa/) (IPA), which are best-practices for API design.
44

5+
6+
## Quick Links
7+
8+
| Site | Link |
9+
| --------------------------- | -------------------------------------------------------------------------------------------------------- |
10+
| MongoDB API Standards (IPA) | [https://mongodb.github.io/ipa/](https://mongodb.github.io/ipa/) |
11+
| Installation & Usage | [IPA README](https://github.com/mongodb/openapi/tree/main/tools/spectral/ipa#readme) |
12+
| Implemented Rules | [Ruleset Documentation](https://github.com/mongodb/openapi/tree/main/tools/spectral/ipa/rulesets#readme) |
13+
| Spectral Docs | [Spectral](https://docs.stoplight.io/docs/spectral/674b27b261c3c-overview) |
14+
| Spectral Wiki (Internal) | [http://go/openapi-spectral-updates](http://go/openapi-spectral-updates) |
15+
| Contributing | [CONTRIBUTING.md](https://github.com/mongodb/openapi/blob/main/tools/spectral/CONTRIBUTING.md) |
16+
| Changelog | [CHANGELOG.md](https://github.com/mongodb/openapi/blob/main/tools/spectral/CHANGELOG.md) |
17+
| Issues | [https://github.com/mongodb/openapi/issues](https://github.com/mongodb/openapi/issues) |
18+
519
## Running Locally
620

721
### Prerequisites
@@ -14,25 +28,32 @@ The IPA validation uses [Spectral](https://docs.stoplight.io/docs/spectral/9ffa0
1428
To run the IPA validation locally, install necessary dependencies with `npm install` if you haven't already. Then, simply run:
1529

1630
```
17-
npm run ipa-validation --file="{your/file/name}"
31+
npm run ipa-validation
1832
```
1933

2034
This command will run Spectral CLI for the ruleset [ipa-spectral.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/ipa-spectral.yaml).
2135

2236
For use on the OpenAPI specification, run `npm run ipa-validation` from the root directory of the OpenAPI repo, which will validate the raw [v2.yaml](https://github.com/mongodb/openapi/blob/main/openapi/.raw/v2.yaml) OpenAPI spec.
2337

24-
The Spectral CLI can also be used to run the validation on any valid OpenAPI file (`json` or `yaml`).
25-
26-
```
27-
spectral lint {path/to/oas/file} --ruleset=./tools/spectral/ipa/ipa-spectral.yaml
28-
```
29-
3038
## Integrating IPA Validations
3139

3240
To incorporate the IPA Spectral ruleset for OpenAPI specification validation in your repositories, you can follow these implementation approaches:
3341

3442
### Installation Options
3543

44+
#### Package-based Installation
45+
46+
Run:
47+
```
48+
npm install @mongodb/ipa-validation-ruleset
49+
```
50+
51+
Then reference the ruleset directly in your `.spectral.yaml` file:
52+
```
53+
extends:
54+
- "@mongodb/ipa-validation-ruleset"
55+
```
56+
3657
#### Server-based Installation
3758

3859
You can reference our ruleset directly in your `.spectral.yaml` file without installation:
@@ -42,10 +63,6 @@ extends:
4263
- https://raw.githubusercontent.com/mongodb/openapi/<latest-git-commit-sha>/tools/spectral/ipa/ipa-spectral.yaml
4364
```
4465

45-
#### Package-based Installation
46-
47-
Not supported yet
48-
4966
### Integration Methods
5067

5168
#### Local Configuration
@@ -57,6 +74,13 @@ extends:
5774
- https://raw.githubusercontent.com/mongodb/openapi/<latest-git-commit-sha>/tools/spectral/ipa/ipa-spectral.yaml
5875
```
5976

77+
or
78+
79+
```
80+
extends:
81+
- "@mongodb/ipa-validation-ruleset"
82+
```
83+
6084
For more information about how to extend rulesets, see the [web page](https://meta.stoplight.io/docs/spectral/83527ef2dd8c0-extending-rulesets).
6185

6286
#### Customization Options

tools/spectral/ipa/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/spectral/ipa/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@mongodb-js/ipa-validation-ruleset",
3+
"version": "1.0.0",
4+
"description": "Custom validation rules for MongoDB API Standards (IPA).",
5+
"keywords": [
6+
"mongodb",
7+
"openapi",
8+
"spectral"
9+
],
10+
"homepage": "https://github.com/mongodb/openapi/tree/main/tools/spectral/ipa#readme",
11+
"bugs": {
12+
"url": "https://github.com/mongodb/openapi/issues"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/mongodb/openapi.git"
17+
},
18+
"license": "Apache-2.0",
19+
"author": "MongoDB",
20+
"type": "module",
21+
"main": "ipa-spectral.yaml",
22+
"scripts": {
23+
"test": "jest"
24+
}
25+
}

0 commit comments

Comments
 (0)