Skip to content

Commit d363c0f

Browse files
sphterrywtrockilovisaberggren
authored
CLOUDP 329998: IPA package configuration (#846)
Co-authored-by: Wojciech Trocki <[email protected]> Co-authored-by: Lovisa Berggren <[email protected]>
1 parent ab14281 commit d363c0f

File tree

9 files changed

+3386
-622
lines changed

9 files changed

+3386
-622
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@ updates:
2222
day: tuesday
2323
commit-message:
2424
prefix: "chore"
25+
- package-ecosystem: npm
26+
directory: "/tools/spectral/ipa"
27+
schedule:
28+
interval: weekly
29+
day: tuesday
30+
commit-message:
31+
prefix: "chore"

.github/workflows/code-health-tools.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
run: |
6565
npm run gen-ipa-docs
6666
if [[ -n $(git status --porcelain) ]]; then
67-
echo "IPA docs not up to date, please run 'npm run gen-ipa-docs' and commit the changes"
67+
echo "IPA docs or NPM dependencies not up to date, please run 'npm run gen-ipa-docs' and 'npm install' then commit the changes"
6868
exit 1
6969
fi
7070
exit 0

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
*.env
1515

1616
/tools/postman/openapi
17-
/tools/postman/node_modules
18-
/node_modules
17+
**/*node_modules
1918

2019
# Tool generated files
2120
*.idea

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@stoplight/spectral-ruleset-bundler": "^1.6.3",
3333
"apache-arrow": "^21.0.0",
3434
"dotenv": "^17.2.0",
35-
"ember-inflector": "^6.0.0",
3635
"eslint-plugin-jest": "^29.0.1",
3736
"inflection": "^3.0.2",
3837
"markdown-table": "^3.0.4",

tools/spectral/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# MongoDB API Spectral Validation
22

3-
A set of custom validator rules for the MongoDB Atlas Programmatic API, adhering to API Standards (IPA)
3+
A set of custom validation rules for the MongoDB Atlas Programmatic API, adhering to MongoDB API standards - [Improvement Proposal for APIs](https://mongodb.github.io/ipa/) (IPA).
4+
45
## Structure
56

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

tools/spectral/ipa/README.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
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+
| 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+
518
## Running Locally
619

720
### Prerequisites
@@ -19,30 +32,20 @@ npm run ipa-validation
1932

2033
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) on the raw [v2.yaml](https://github.com/mongodb/openapi/blob/main/openapi/.raw/v2.yaml) OpenAPI spec.
2134

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

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

3239
### Installation Options
3340

34-
#### Server-based Installation
35-
36-
You can reference our ruleset directly in your `.spectral.yaml` file without installation:
37-
41+
#### Package-based Installation (**TO BE RELEASED**)
42+
Run:
3843
```
39-
extends:
40-
- https://raw.githubusercontent.com/mongodb/openapi/<latest-git-commit-sha>/tools/spectral/ipa/ipa-spectral.yaml
44+
npm install @mongodb-js/ipa-validation-ruleset
4145
```
4246

43-
#### Package-based Installation
44-
45-
Not supported yet
47+
#### Limitations
48+
The IPA Validation Framework uses third party dependencies for certain rules. With this approach, [server based installation](https://docs.stoplight.io/docs/spectral/7895ff1196448-sharing-and-distributing-rulesets#http-server) is not supported. Instead, use the recommended package-based installation or clone the repo.
4649

4750
### Integration Methods
4851

@@ -52,7 +55,7 @@ Create a `.spectral.yaml` file that extends our ruleset:
5255

5356
```
5457
extends:
55-
- https://raw.githubusercontent.com/mongodb/openapi/<latest-git-commit-sha>/tools/spectral/ipa/ipa-spectral.yaml
58+
- "@mongodb/ipa-validation-ruleset"
5659
```
5760

5861
For more information about how to extend rulesets, see the [web page](https://meta.stoplight.io/docs/spectral/83527ef2dd8c0-extending-rulesets).
@@ -63,7 +66,7 @@ You can override specific rules from our ruleset by adding them to your local `.
6366

6467
```
6568
extends:
66-
- https://raw.githubusercontent.com/mongodb/openapi/<latest-git-commit-sha>/tools/spectral/ipa/ipa-spectral.yaml
69+
- "@mongodb/ipa-validation-ruleset"
6770
6871
overrides:
6972
- files:

0 commit comments

Comments
 (0)