Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
12 changes: 9 additions & 3 deletions .github/scripts/split_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ foascli versions -s openapi-foas.json -o ./openapi/v2/versions.json --env "${tar

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

# Generate one OAS per version based on the versioning extensions
foascli split -s openapi-foas.json --env "${target_env:?}" -o ./openapi/v2/openapi.json --format all
mv -f "openapi-foas.json" "./openapi/v2.json"
mv -f "openapi-foas.yaml" "./openapi/v2.yaml"

# Filters out the current foas, removing all extensions that are not related with versioning
foascli filter -s openapi-foas.json --env "${target_env:?}" -o ./openapi/v2.json --format all

# Moves the unfiltered OAS to the raw folder
mv -f "openapi-foas.json" "./openapi/.raw/v2.json"
mv -f "openapi-foas.yaml" "./openapi/.raw/v2.yaml"

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

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

Choose a reason for hiding this comment

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

Could you filter out from the branded preview the v2 spec and the v2 in the .raw?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure I follow, but for the branded preview, I made it use the filtered version, since it would hide the hidden contents

Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a step in the release process where we create the branded preview (branded_preview.sh), and I see that right now https://htmlpreview.github.io/?https://github.com/mongodb/openapi/blob/main/openapi/branded-preview.html we list v2.json and v2.yaml. I am wondering if with these changes we will start to see also the spec in .raw 🤔 This can also be a follow up ticket. Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ohhh got it! good point, not sure and I hope not :D If we see it I'll remove in a follow-up

2 changes: 1 addition & 1 deletion .github/workflows/generate-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
name: openapi-foas-${{ inputs.env }}
path: |
openapi-foas.*
foas-metadata.json
foas-metadata.json
2 changes: 1 addition & 1 deletion .github/workflows/release-IPA-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: npm install

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

- name: Run Metric Collection Job
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/spectral-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:
- name: Spectral action
uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83
with:
# Path to the OpenAPI spec files and openapi/v2.yaml
file_glob: openapi/v2.yaml
# Path to the OpenAPI spec files and openapi/.raw/v2.yaml
file_glob: openapi/.raw/v2.yaml
spectral_ruleset: tools/spectral/.spectral.yaml #If updated, need to update in MMS too.
- name: IPA validation action
uses: stoplightio/spectral-action@2ad0b9302e32a77c1caccf474a9b2191a8060d83
with:
file_glob: openapi/v2.yaml
file_glob: openapi/.raw/v2.yaml
spectral_ruleset: tools/spectral/ipa/ipa-spectral.yaml
3 changes: 3 additions & 0 deletions openapi/.raw/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Raw / Unfiltered OAS

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)
73,537 changes: 73,537 additions & 0 deletions openapi/.raw/v2.json

Large diffs are not rendered by default.

54,376 changes: 54,376 additions & 0 deletions openapi/.raw/v2.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"format-check": "npx prettier . --check",
"lint-js": "npx eslint **/*.js",
"gen-ipa-docs": "node tools/spectral/ipa/scripts/generateRulesetReadme.js",
"ipa-validation": "spectral lint ./openapi/v2.yaml --ruleset=./tools/spectral/ipa/ipa-spectral.yaml",
"ipa-validation": "spectral lint ./openapi/.raw/v2.yaml --ruleset=./tools/spectral/ipa/ipa-spectral.yaml",
"test": "jest"
},
"jest": {
Expand Down
4 changes: 2 additions & 2 deletions tools/spectral/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ setup: deps devtools ## Set up dev env
.PHONY: linterr
linterr: ## Run spectral linter on foas
@echo "==> Running spectral linter"
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ../../openapi/v2.yaml --ruleset=.spectral.yaml
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ../../openapi/.raw/v2.yaml --ruleset=.spectral.yaml

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

.PHONY: help
.DEFAULT_GOAL := help
Expand Down
2 changes: 1 addition & 1 deletion tools/spectral/ipa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To run the IPA validation locally, install necessary dependencies with `npm inst
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 [v2.yaml](https://github.com/mongodb/openapi/blob/main/openapi/v2.json) OpenAPI spec.
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`).

Expand Down
2 changes: 1 addition & 1 deletion tools/spectral/ipa/metrics/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const dirname = path.dirname(fileURLToPath(import.meta.url));
const rootDir = path.resolve(dirname, '../../../../');

const config = {
defaultOasFilePath: path.join(rootDir, 'openapi', 'v2.json'),
defaultOasFilePath: path.join(rootDir, 'openapi', '.raw', 'v2.json'),
Copy link
Member

Choose a reason for hiding this comment

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

❤️

defaultRulesetFilePath: path.join(dirname, '..', 'ipa-spectral.yaml'),
defaultCollectorResultsFilePath: path.join(dirname, 'scripts', 'ipa-collector-results-combined.log'),
defaultOutputsDir: path.join(dirname, 'outputs'),
Expand Down
Loading