Skip to content

Commit bb10ac5

Browse files
feat!: introduce comprehensive OpenAPI 3.0.x/3.1.x parser with validation, walking, and upgrading
1 parent 20eee3b commit bb10ac5

File tree

285 files changed

+61015
-1596
lines changed

Some content is hidden

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

285 files changed

+61015
-1596
lines changed

.github/workflows/test.yaml

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,57 +7,77 @@ on:
77
branches: [main]
88

99
jobs:
10-
test-and-build:
10+
lint:
11+
name: Lint and Format Check
1112
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install mise
17+
uses: jdx/mise-action@v2
18+
19+
- name: Check code formatting
20+
run: mise run fmt-check
21+
22+
- name: Check module dependencies
23+
run: mise run mod-check
24+
25+
- name: Run lint task
26+
run: mise run lint
27+
28+
- name: Check examples are up to date
29+
run: mise run examples-check
30+
31+
test-and-build:
32+
name: Test and Build
33+
needs: lint
34+
strategy:
35+
matrix:
36+
os: [ubuntu-latest, windows-latest]
37+
runs-on: ${{ matrix.os }}
1238
permissions:
1339
contents: read
1440
pull-requests: write
1541

1642
steps:
1743
- uses: actions/checkout@v4
1844

19-
- name: Set up Go
20-
uses: actions/setup-go@v5
21-
with:
22-
go-version: "1.23"
23-
24-
- name: Install dependencies
25-
run: go mod download
26-
27-
- name: Run golangci-lint
28-
uses: golangci/golangci-lint-action@v6
29-
with:
30-
version: latest
45+
- name: Install mise
46+
uses: jdx/mise-action@v2
3147

3248
- name: Run tests with coverage
33-
run: |
34-
go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
35-
go tool cover -html=coverage.out -o coverage.html
49+
if: matrix.os == 'ubuntu-latest'
50+
run: mise run test-coverage
51+
52+
- name: Run tests (Windows)
53+
if: matrix.os == 'windows-latest'
54+
run: mise run test
3655

3756
- name: Calculate coverage
57+
if: matrix.os == 'ubuntu-latest'
3858
id: coverage
3959
run: |
4060
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}')
4161
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
4262
echo "Coverage: $COVERAGE"
4363
4464
- name: Get main branch coverage
45-
if: github.event_name == 'pull_request'
65+
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest'
4666
id: main-coverage
4767
run: |
4868
# Store current working directory
4969
CURRENT_DIR=$(pwd)
50-
70+
5171
# Fetch main branch
5272
git fetch origin main:main
53-
73+
5474
# Checkout main branch in a temporary directory
5575
git worktree add /tmp/main-branch main
56-
76+
5777
# Run tests on main branch to get coverage
5878
cd /tmp/main-branch
5979
go test -coverprofile=main-coverage.out -covermode=atomic ./... > /dev/null 2>&1 || echo "Main branch tests failed"
60-
80+
6181
if [ -f main-coverage.out ]; then
6282
MAIN_COVERAGE=$(go tool cover -func=main-coverage.out | grep total | awk '{print $3}' || echo "0.0%")
6383
echo "main-coverage=$MAIN_COVERAGE" >> $GITHUB_OUTPUT
@@ -69,23 +89,24 @@ jobs:
6989
echo "main-coverage=0.0%" >> $GITHUB_OUTPUT
7090
echo "Could not get main branch coverage"
7191
fi
72-
92+
7393
# Return to original directory
7494
cd "$CURRENT_DIR"
75-
95+
7696
# Clean up worktree (force removal to handle modified files)
7797
git worktree remove --force /tmp/main-branch || rm -rf /tmp/main-branch
7898
7999
- name: Generate coverage summary
100+
if: matrix.os == 'ubuntu-latest'
80101
id: coverage-summary
81102
run: |
82103
echo "## 📊 Test Coverage Report" > coverage-summary.md
83104
echo "" >> coverage-summary.md
84-
105+
85106
# Current coverage
86107
CURRENT_COV="${{ steps.coverage.outputs.coverage }}"
87108
echo "**Current Coverage:** \`$CURRENT_COV\`" >> coverage-summary.md
88-
109+
89110
# Compare with main if this is a PR
90111
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ steps.main-coverage.outputs.main-coverage }}" != "" ]; then
91112
MAIN_COV="${{ steps.main-coverage.outputs.main-coverage }}"
@@ -109,7 +130,7 @@ jobs:
109130
fi
110131
fi
111132
fi
112-
133+
113134
echo "" >> coverage-summary.md
114135
echo "### Coverage by Package" >> coverage-summary.md
115136
echo "\`\`\`" >> coverage-summary.md
@@ -122,25 +143,25 @@ jobs:
122143
echo "_Generated by GitHub Actions_" >> coverage-summary.md
123144
124145
- name: Comment PR with coverage
125-
if: github.event_name == 'pull_request'
146+
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest'
126147
uses: actions/github-script@v7
127148
with:
128149
script: |
129150
const fs = require('fs');
130151
const coverageSummary = fs.readFileSync('coverage-summary.md', 'utf8');
131-
152+
132153
// Look for existing coverage comment
133154
const comments = await github.rest.issues.listComments({
134155
issue_number: context.issue.number,
135156
owner: context.repo.owner,
136157
repo: context.repo.repo,
137158
});
138-
159+
139160
const botComment = comments.data.find(comment =>
140161
comment.user.type === 'Bot' &&
141162
comment.body.includes('📊 Test Coverage Report')
142163
);
143-
164+
144165
if (botComment) {
145166
// Update existing comment
146167
await github.rest.issues.updateComment({
@@ -160,12 +181,13 @@ jobs:
160181
}
161182
162183
- name: Upload coverage artifact
184+
if: matrix.os == 'ubuntu-latest'
163185
uses: actions/upload-artifact@v4
164186
with:
165187
name: coverage-report
166188
path: |
167189
coverage.out
168190
coverage.html
169191
170-
- name: Build
171-
run: go build -v ./...
192+
- name: Build (${{ matrix.os }})
193+
run: mise run build

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Coverage files generated by test-coverage task
2+
coverage.out
3+
coverage.html
4+
5+
# VSCode settings (user-specific)
6+
.vscode/*
7+
!.vscode/settings.example.json

.golangci.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: "2"
2+
issues:
3+
max-issues-per-linter: 0
4+
max-same-issues: 0
5+
6+
linters:
7+
enable:
8+
- govet
9+
- paralleltest

.mise.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[tools]
2+
go = "1.24.3"
3+
golangci-lint = "2.1.1"
4+
gotestsum = "latest"
5+
6+
[tasks.setup-vscode-symlinks]
7+
description = "Create VSCode symlinks for tools not automatically handled by mise-vscode"
8+
run = [
9+
"mkdir -p .vscode/mise-tools",
10+
"ln -sf $(mise exec [email protected] -- which golangci-lint) .vscode/mise-tools/golangci-lint",
11+
]
12+
13+
[hooks]
14+
postinstall = [
15+
"mise run setup-vscode-symlinks",
16+
"go install go.uber.org/nilaway/cmd/nilaway@8ad05f0",
17+
]

.vscode/settings.example.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"mise.configureExtensionsUseSymLinks": true,
3+
"go.goroot": "${workspaceFolder}/.vscode/mise-tools/goRoot",
4+
"go.alternateTools": {
5+
"go": "${workspaceFolder}/.vscode/mise-tools/go",
6+
"dlv": "${workspaceFolder}/.vscode/mise-tools/dlv",
7+
"gopls": "${workspaceFolder}/.vscode/mise-tools/gopls",
8+
"golangci-lint": "${workspaceFolder}/.vscode/mise-tools/golangci-lint",
9+
"customFormatter": "${workspaceFolder}/.vscode/mise-tools/golangci-lint"
10+
},
11+
"go.lintTool": "golangci-lint",
12+
"go.lintFlags": ["--path-mode=abs", "--fast-only"],
13+
"go.formatTool": "custom",
14+
"go.formatFlags": ["fmt", "--stdin"],
15+
"go.lintOnSave": "package"
16+
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939
The `arazzo` package provides an API for working with Arazzo documents including reading, creating, mutating, walking and validating them.
4040

41+
### [openapi](./openapi)
42+
43+
The `openapi` package provides an API for working with OpenAPI documents including reading, creating, mutating, walking, validating and upgrading them. Supports both OpenAPI 3.0.x and 3.1.x specifications.
44+
4145
## Sub Packages
4246

4347
This repository also contains a number of sub packages that are used by the main packages to provide the required functionality. The below packages may be moved into their own repository in the future, depending on future needs.

0 commit comments

Comments
 (0)