Skip to content

Commit 9b321ea

Browse files
authored
Merge pull request #21 from git-pkgs/openapi-docs
Add generated OpenAPI docs support
2 parents 9c0f1bc + 82443e1 commit 9b321ea

14 files changed

Lines changed: 2357 additions & 10 deletions

File tree

.github/workflows/swagger.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Swagger
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
permissions: {}
10+
11+
jobs:
12+
swagger:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
16+
with:
17+
persist-credentials: false
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
21+
with:
22+
go-version: '1.25'
23+
24+
- name: Install swag
25+
run: go install github.com/swaggo/swag/cmd/swag@latest
26+
27+
- name: Generate swagger
28+
run: go generate ./internal/server
29+
30+
- name: Verify no changes
31+
run: |
32+
if [ -n "$(git status --porcelain)" ]; then
33+
echo "Swagger docs are out of date. Run: go generate ./internal/server" >&2
34+
git status --porcelain
35+
exit 1
36+
fi

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ go build -o proxy ./cmd/proxy
6565

6666
The proxy is now running. Configure your package managers to use it.
6767

68+
## OpenAPI (Swagger)
69+
70+
This repo uses swaggo to generate an OpenAPI spec from annotated handlers.
71+
72+
Generate the spec:
73+
74+
```bash
75+
go install github.com/swaggo/swag/cmd/swag@latest
76+
go generate ./internal/server
77+
```
78+
79+
Generated files are written to `docs/swagger/`.
80+
81+
When the proxy is running, fetch the live spec from:
82+
83+
- `http://localhost:8080/openapi.json`
84+
85+
Or replace `http://localhost:8080` with your configured base URL. This link is also shown on the dashboard.
86+
6887
## Configuring Package Managers
6988

7089
### npm

cmd/proxy/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
// Command proxy runs the git-pkgs package registry proxy server.
22
//
3+
// @title git-pkgs proxy API
4+
// @version 0.1.0
5+
// @description HTTP API for package enrichment, vulnerability lookup, cache stats, and source browsing.
6+
// @BasePath /
7+
//
38
// The proxy caches package artifacts from upstream registries (npm, cargo, etc.)
49
// providing faster, more reliable access for development teams.
510
//

0 commit comments

Comments
 (0)