From 3c7540b868b3f4e6a650a1c77c345c9c59053401 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Wed, 4 Sep 2024 16:24:11 +0100 Subject: [PATCH 1/3] Add docs --- .github/workflows/spectral-lint.yml | 2 +- tools/spectral/README.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tools/spectral/README.md diff --git a/.github/workflows/spectral-lint.yml b/.github/workflows/spectral-lint.yml index fc8d95b51c..ad84f46374 100644 --- a/.github/workflows/spectral-lint.yml +++ b/.github/workflows/spectral-lint.yml @@ -32,4 +32,4 @@ jobs: with: # Path to the OpenAPI spec files and openapi/v2.yaml file_glob: openapi/v2.yaml - spectral_ruleset: tools/spectral/.spectral.yaml + spectral_ruleset: tools/spectral/.spectral.yaml #If updated, need to update in MMS too. diff --git a/tools/spectral/README.md b/tools/spectral/README.md new file mode 100644 index 0000000000..0d38b18c35 --- /dev/null +++ b/tools/spectral/README.md @@ -0,0 +1,6 @@ +# Spectral updates + +If adding new rules or updating .spectral.yaml overall, the validations will instantly get updated across mongodb/openapi repository. + +To propagate the changes in MMS, engineers must open a PR and update the pinned commit sha in mms. + From 87ec009411e5fbe77bcbcad49d4265f8262fcc48 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Wed, 4 Sep 2024 16:24:34 +0100 Subject: [PATCH 2/3] Revert "Revert "chore:re-add spectral rule (#217)" (#218)" This reverts commit 12e283e6c447ed431d0bb604e8246f521e3be693. --- tools/spectral/.spectral.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/spectral/.spectral.yaml b/tools/spectral/.spectral.yaml index eb4614f05b..78017c105a 100644 --- a/tools/spectral/.spectral.yaml +++ b/tools/spectral/.spectral.yaml @@ -184,6 +184,17 @@ rules: field: allow_diff pattern: "^true$" + no-slash-before-custom-method: + description: "Custom methods (e.g., ':applyItem') should not be preceded by a '/'." + message: "The path '{{path}}' contains a '/' before a custom method. Custom methods should not start with a '/'." + severity: error + given: "$.paths" + then: + field: "@key" + function: pattern + functionOptions: + notMatch: "/[^/]+/:[a-zA-Z]+$" + overrides: - files: # load sample data has an issue with different path param names for different VERBS - "*.yaml#/paths/~1api~1atlas~1v1.0~1groups~1%7BgroupId%7D~1sampleDatasetLoad~1%7BsampleDatasetId%7D" From 4e25584c44bbcf0d08d8733f8bc5c580486d7ab8 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Wed, 4 Sep 2024 16:32:34 +0100 Subject: [PATCH 3/3] add checklist --- tools/spectral/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/spectral/README.md b/tools/spectral/README.md index 0d38b18c35..1bcaf9aca6 100644 --- a/tools/spectral/README.md +++ b/tools/spectral/README.md @@ -4,3 +4,8 @@ If adding new rules or updating .spectral.yaml overall, the validations will ins To propagate the changes in MMS, engineers must open a PR and update the pinned commit sha in mms. +Please perform the following steps: +1. [ ] Open a PR with the spectral changes and validate that the Spectral lint checks work. +2. [ ] Review and merge the PR. +3. [ ] Open a PR in mms, updating the commit sha of the spectral file imported. +4. [ ] Validate all tests pass. \ No newline at end of file