Skip to content

Commit 2017cd1

Browse files
Merge branch 'main' into CLOUDP-304053/fix
2 parents 7b04e62 + 764b37f commit 2017cd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+128923
-3921
lines changed

.github/scripts/split_spec.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ 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+
mkdir -p ./openapi/.raw
17+
mv -f "openapi-foas.json" "./openapi/.raw/v2.json"
18+
mv -f "openapi-foas.yaml" "./openapi/.raw/v2.yaml"
1219

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

1926
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:?}"
27+
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

.husky/pre-commit

100644100755
File mode changed.

.lintstagedrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"**/*.{js,jsx,ts,tsx,json,md}": ["prettier --write"],
3-
"**/*.js": ["jest --findRelatedTests --passWithNoTests"]
3+
"**/*.js": ["jest --findRelatedTests --passWithNoTests"],
4+
"tools/spectral/ipa/**/*.yaml": ["node tools/spectral/ipa/scripts/generateRulesetReadme.js"],
5+
"**/*.go": ["./tools/cli/precommit.sh"]
46
}

CONTRIBUTING.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Node.js v20 or later
88
- npm v8 or later
99
- Git
10+
- Go 1.21 or later (for CLI development)
1011

1112
### Installation
1213

@@ -21,11 +22,17 @@
2122
npm install
2223
```
2324

24-
3. Set up Git hooks (optional):
25+
3. Set up Git hooks (recommended):
2526
```bash
2627
npm run precommit
2728
```
2829

30+
4. If working on the Go CLI, set up the Go environment:
31+
```bash
32+
cd tools/cli
33+
make setup
34+
```
35+
2936
This will install Husky, which manages Git hooks for the project. The hooks ensure code quality by automatically running various checks before commits.
3037

3138
## Development Workflow
@@ -34,16 +41,28 @@ This will install Husky, which manages Git hooks for the project. The hooks ensu
3441

3542
This project uses the following Git hooks:
3643

37-
- **pre-commit**: Automatically formats your code using Prettier and runs tests for staged JavaScript files to ensure code quality before each commit.
44+
- **pre-commit**:
45+
- Automatically formats your code using Prettier and runs tests for staged JavaScript files
46+
- If you get the message `hint: The '.husky/pre-commit' hook was ignored because it's not set as executable.` during the commit, you can run `chmod ug+x .husky/*` to make it executable.
47+
- For Go files, runs formatting, linting, and tests using the project's Makefile
3848

3949
### Available Scripts
4050

51+
#### JavaScript/Node.js
4152
- `npm run format` - Format all files with Prettier
4253
- `npm run format-check` - Check formatting without modifying files
4354
- `npm run lint-js` - Lint JavaScript files
4455
- `npm run test` - Run all tests
4556

4657
#### IPA specific targets
47-
4858
- `npm run gen-ipa-docs` - Generate IPA ruleset documentation (see `./tools` folder for more information)
4959
- `npm run ipa-validation` - Run OpenAPI validation with Spectral
60+
61+
#### Go OpenAPI CLI (internal)
62+
When working in the `tools/cli` directory:
63+
- `make fmt` - Format Go code
64+
- `make lint` - Run golangci-lint
65+
- `make unit-test` - Run Go unit tests
66+
- `make e2e-test` - Run end-to-end tests
67+
- `make build` - Build the CLI binary
68+
- `make gen-docs` - Generate CLI documentation

changelog/internal/metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"runDate": "2025-03-11",
3-
"specRevision": "039e6ac71118273c1be2ea529b26035b1b884a00",
4-
"specRevisionShort": "039e6ac7111",
3+
"specRevision": "9c739cc8a51f69b2bf5ffc8178fd1d28b63bae65",
4+
"specRevisionShort": "9c739cc8a51",
55
"versions": [
66
"2023-01-01",
77
"2023-02-01",

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)

0 commit comments

Comments
 (0)