Skip to content

Commit 4611756

Browse files
authored
CLOUDP-302671: Update v2 to filtered OAS (#497)
1 parent bb8d816 commit 4611756

File tree

11 files changed

+127935
-13
lines changed

11 files changed

+127935
-13
lines changed

.github/scripts/split_spec.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ foascli versions -s openapi-foas.json -o ./openapi/v2/versions.json --env "${tar
66

77
echo "Running FOAS CLI split command with the following --env=${target_env:?} and -o=./openapi/v2/openapi.json"
88

9+
# Generate one OAS per version based on the versioning extensions
910
foascli split -s openapi-foas.json --env "${target_env:?}" -o ./openapi/v2/openapi.json --format all
10-
mv -f "openapi-foas.json" "./openapi/v2.json"
11-
mv -f "openapi-foas.yaml" "./openapi/v2.yaml"
11+
12+
# Filters out the current foas, removing all extensions that are not related with versioning
13+
foascli filter -s openapi-foas.json --env "${target_env:?}" -o ./openapi/v2.json --format all
14+
15+
# Moves the unfiltered OAS to the raw folder
16+
mv -f "openapi-foas.json" "./openapi/.raw/v2.json"
17+
mv -f "openapi-foas.yaml" "./openapi/.raw/v2.yaml"
1218

1319
# Create folder if it does not exist
1420
mkdir -p ./openapi/v2/private
@@ -17,4 +23,4 @@ echo "Moving preview files to preview and private-preview folder"
1723
find ./openapi/v2 -type f -name "*private-preview*" -exec mv -f {} ./openapi/v2/private/ \;
1824

1925
echo "Generate the versions.json file for private preview APIs"
20-
foascli versions --spec ./openapi/v2.json --stability-level PRIVATE-PREVIEW -o ./openapi/v2/private/versions.json --env "${target_env:?}"
26+
foascli versions --spec ./openapi/.raw/v2.json --stability-level PRIVATE-PREVIEW -o ./openapi/v2/private/versions.json --env "${target_env:?}"

.github/workflows/generate-openapi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ jobs:
7979
name: openapi-foas-${{ inputs.env }}
8080
path: |
8181
openapi-foas.*
82-
foas-metadata.json
82+
foas-metadata.json

.github/workflows/release-IPA-metrics.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: npm install
3434

3535
- name: Fetch OAS file from Dev Branch
36-
run: curl -O "https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/v2.json"
36+
run: curl -O "https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/.raw/v2.json"
3737
working-directory: ${{ github.workspace }}
3838

3939
- name: Run Metric Collection Job

.github/workflows/spectral-lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939
- name: Spectral action
4040
uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83
4141
with:
42-
# Path to the OpenAPI spec files and openapi/v2.yaml
43-
file_glob: openapi/v2.yaml
42+
# Path to the OpenAPI spec files and openapi/.raw/v2.yaml
43+
file_glob: openapi/.raw/v2.yaml
4444
spectral_ruleset: tools/spectral/.spectral.yaml #If updated, need to update in MMS too.
4545
- name: IPA validation action
4646
uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83
4747
with:
48-
file_glob: openapi/v2.yaml
48+
file_glob: openapi/.raw/v2.yaml
4949
spectral_ruleset: tools/spectral/ipa/ipa-spectral.yaml

openapi/.raw/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Raw / Unfiltered OAS
2+
3+
The OAS stored in this folder is only useable for linting and tools that require `x-xgen` type of extensions. To leverage the already applied filters, use [v2.yaml](https://github.com/mongodb/openapi/blob/main/openapi/v2.yaml) or [v2.json](https://github.com/mongodb/openapi/blob/main/openapi/v2.json)

openapi/.raw/v2.json

Lines changed: 73537 additions & 0 deletions
Large diffs are not rendered by default.

openapi/.raw/v2.yaml

Lines changed: 54376 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"format-check": "npx prettier . --check",
88
"lint-js": "npx eslint **/*.js",
99
"gen-ipa-docs": "node tools/spectral/ipa/scripts/generateRulesetReadme.js",
10-
"ipa-validation": "spectral lint ./openapi/v2.yaml --ruleset=./tools/spectral/ipa/ipa-spectral.yaml",
10+
"ipa-validation": "spectral lint ./openapi/.raw/v2.yaml --ruleset=./tools/spectral/ipa/ipa-spectral.yaml",
1111
"test": "jest",
1212
"precommit": "husky install"
1313
},

tools/spectral/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ setup: deps devtools ## Set up dev env
1919
.PHONY: linterr
2020
linterr: ## Run spectral linter on foas
2121
@echo "==> Running spectral linter"
22-
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ../../openapi/v2.yaml --ruleset=.spectral.yaml
22+
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ../../openapi/.raw/v2.yaml --ruleset=.spectral.yaml
2323

2424
.PHONY: lintwarn
2525
lintwarn: ## Run spectral linter on foas
2626
@echo "==> Running spectral linter"
27-
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ../../openapi/v2.yaml --ruleset=.spectral.yaml --fail-severity=warn
27+
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ../../openapi/.raw/v2.yaml --ruleset=.spectral.yaml --fail-severity=warn
2828

2929
.PHONY: help
3030
.DEFAULT_GOAL := help

tools/spectral/ipa/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To run the IPA validation locally, install necessary dependencies with `npm inst
1919
npm run ipa-validation
2020
```
2121

22-
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 [v2.yaml](https://github.com/mongodb/openapi/blob/main/openapi/v2.json) OpenAPI spec.
22+
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.
2323

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

tools/spectral/ipa/metrics/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
55
const rootDir = path.resolve(dirname, '../../../../');
66

77
const config = {
8-
defaultOasFilePath: path.join(rootDir, 'openapi', 'v2.json'),
8+
defaultOasFilePath: path.join(rootDir, 'openapi', '.raw', 'v2.json'),
99
defaultRulesetFilePath: path.join(dirname, '..', 'ipa-spectral.yaml'),
1010
defaultCollectorResultsFilePath: path.join(dirname, 'scripts', 'ipa-collector-results-combined.log'),
1111
defaultOutputsDir: path.join(dirname, 'outputs'),

0 commit comments

Comments
 (0)