Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ updates:
day: tuesday
commit-message:
prefix: "chore"
- package-ecosystem: npm
Copy link
Member

@wtrocki wtrocki Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important: Set one of the package version -1 . post merge we can validate dependabot updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When should I do this? Now or post merge?

directory: "/tools/spectral/ipa"
schedule:
interval: weekly
day: tuesday
commit-message:
prefix: "chore"
2 changes: 1 addition & 1 deletion .github/workflows/code-health-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
npm run gen-ipa-docs
if [[ -n $(git status --porcelain) ]]; then
echo "IPA docs not up to date, please run 'npm run gen-ipa-docs' and commit the changes"
echo "IPA docs or NPM dependencies not up to date, please run 'npm run gen-ipa-docs' and 'npm install' then commit the changes"
exit 1
fi
exit 0
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*.env

/tools/postman/openapi
/tools/postman/node_modules
/node_modules
**/*node_modules

# Tool generated files
*.idea
Expand Down
636 changes: 36 additions & 600 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@stoplight/spectral-ruleset-bundler": "^1.6.3",
"apache-arrow": "^21.0.0",
"dotenv": "^17.2.0",
"ember-inflector": "^6.0.0",
"eslint-plugin-jest": "^29.0.1",
"inflection": "^3.0.2",
"markdown-table": "^3.0.4",
Expand Down
3 changes: 2 additions & 1 deletion tools/spectral/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# MongoDB API Spectral Validation

A set of custom validator rules for the MongoDB Atlas Programmatic API, adhering to API Standards (IPA)
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).

## Structure

- **/ipa** - Contains custom Spectral rulesets covering MongoDB API standards.
Expand Down
44 changes: 36 additions & 8 deletions tools/spectral/ipa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

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.


## Quick Links

| Site | Link |
| --------------------------- | -------------------------------------------------------------------------------------------------------- |
| MongoDB API Standards (IPA) | [https://mongodb.github.io/ipa/](https://mongodb.github.io/ipa/) |
| Installation & Usage | [IPA README](https://github.com/mongodb/openapi/tree/main/tools/spectral/ipa#readme) |
| Implemented Rules | [Ruleset Documentation](https://github.com/mongodb/openapi/tree/main/tools/spectral/ipa/rulesets#readme) |
| Spectral Docs | [Spectral](https://docs.stoplight.io/docs/spectral/674b27b261c3c-overview) |
| Contributing | [CONTRIBUTING.md](https://github.com/mongodb/openapi/blob/main/tools/spectral/CONTRIBUTING.md) |
| Changelog | [CHANGELOG.md](https://github.com/mongodb/openapi/blob/main/tools/spectral/CHANGELOG.md) |
| Issues | [https://github.com/mongodb/openapi/issues](https://github.com/mongodb/openapi/issues) |

## Running Locally

### Prerequisites
Expand All @@ -19,12 +32,6 @@ npm run ipa-validation

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.

The Spectral CLI can also be used to run the validation on any valid OpenAPI file (`json` or `yaml`).

```
spectral lint {path/to/oas/file} --ruleset=./tools/spectral/ipa/ipa-spectral.yaml
```

## Integrating IPA Validations

To incorporate the IPA Spectral ruleset for OpenAPI specification validation in your repositories, you can follow these implementation approaches:
Expand All @@ -40,23 +47,44 @@ extends:
- https://raw.githubusercontent.com/mongodb/openapi/<latest-git-commit-sha>/tools/spectral/ipa/ipa-spectral.yaml
```

#### Package-based Installation
##### Limitations
The IPA Validation Framework uses a third party dependency to validate OperationIDs. With this approach, server based installation is only supported via cloning the repo or via package-based installation.

Not supported yet
#### Package-based Installation (**TO BE RELEASED**)
Run:
```
npm install @mongodb-js/ipa-validation-ruleset
```

Then reference the ruleset directly in your `.spectral.yaml` file:
```
extends:
- "@mongodb-js/ipa-validation-ruleset"
```

### Integration Methods

#### Local Configuration

Create a `.spectral.yaml` file that extends our ruleset:

```
extends:
- "@mongodb/ipa-validation-ruleset"
```

or

```
extends:
- https://raw.githubusercontent.com/mongodb/openapi/<latest-git-commit-sha>/tools/spectral/ipa/ipa-spectral.yaml
```

For more information about how to extend rulesets, see the [web page](https://meta.stoplight.io/docs/spectral/83527ef2dd8c0-extending-rulesets).

##### Limitations
Due to usage of a third party dependency to validate OperationIDs, the server based appraoch is only supported via cloning the repo.

#### Customization Options

You can override specific rules from our ruleset by adding them to your local `.spectral.yaml`:
Expand Down
Loading
Loading