Skip to content

Commit d95da54

Browse files
committed
docs(vacuum): add custom functions download steps
Vacuum does not resolve custom JS functions from remote URLs — they must be local and passed via the -f flag. Update the guide with download instructions, CI integration, and a Custom Functions section explaining the requirement.
1 parent c80991a commit d95da54

1 file changed

Lines changed: 52 additions & 7 deletions

File tree

docs/guide/vacuum.md

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,34 @@ brew install daveshanley/vacuum/vacuum
1515
# Linux, Windows, Docker: https://quobix.com/vacuum/installing/
1616
```
1717

18-
### 2. Create a `.vacuum.yml` in your project
18+
### 2. Download the Barbacane ruleset
19+
20+
Several rules use custom JavaScript functions (config schema validation, duplicate detection, etc.). Vacuum requires custom functions on the local filesystem, so download the ruleset and its functions:
21+
22+
```bash
23+
mkdir -p .barbacane/rulesets/functions .barbacane/rulesets/schemas
24+
curl -fsSL https://docs.barbacane.dev/rulesets/barbacane.yaml -o .barbacane/rulesets/barbacane.yaml
25+
for f in barbacane-auth-opt-out barbacane-no-duplicate-middlewares barbacane-no-plaintext-upstream \
26+
barbacane-no-unknown-extensions barbacane-valid-secret-refs barbacane-validate-dispatch-config \
27+
barbacane-validate-middleware-config; do
28+
curl -fsSL "https://docs.barbacane.dev/rulesets/functions/${f}.js" -o ".barbacane/rulesets/functions/${f}.js"
29+
done
30+
```
31+
32+
This creates a `.barbacane/rulesets/` directory with the ruleset YAML and custom functions. You may want to add `.barbacane/` to your `.gitignore`.
33+
34+
### 3. Create a `.vacuum.yml` in your project
1935

2036
```yaml
2137
extends:
22-
- - https://docs.barbacane.dev/rulesets/barbacane.yaml
38+
- - .barbacane/rulesets/barbacane.yaml
2339
- recommended
2440
```
2541
26-
### 3. Lint your spec
42+
### 4. Lint your spec
2743
2844
```bash
29-
vacuum lint my-api.yaml
45+
vacuum lint -f .barbacane/rulesets/functions my-api.yaml
3046
```
3147

3248
## Rules
@@ -79,7 +95,7 @@ You can override individual rules in your `.vacuum.yml`:
7995

8096
```yaml
8197
extends:
82-
- - https://docs.barbacane.dev/rulesets/barbacane.yaml
98+
- - .barbacane/rulesets/barbacane.yaml
8399
- recommended
84100

85101
rules:
@@ -100,14 +116,43 @@ rules:
100116
curl -fsSL https://github.com/daveshanley/vacuum/releases/latest/download/vacuum_linux_amd64 -o vacuum
101117
chmod +x vacuum
102118
119+
- name: Download Barbacane ruleset
120+
run: |
121+
mkdir -p .barbacane/rulesets/functions
122+
curl -fsSL https://docs.barbacane.dev/rulesets/barbacane.yaml -o .barbacane/rulesets/barbacane.yaml
123+
for f in barbacane-auth-opt-out barbacane-no-duplicate-middlewares barbacane-no-plaintext-upstream \
124+
barbacane-no-unknown-extensions barbacane-valid-secret-refs barbacane-validate-dispatch-config \
125+
barbacane-validate-middleware-config; do
126+
curl -fsSL "https://docs.barbacane.dev/rulesets/functions/${f}.js" -o ".barbacane/rulesets/functions/${f}.js"
127+
done
128+
103129
- name: Lint OpenAPI spec
104-
run: ./vacuum lint -r .vacuum.yml my-api.yaml
130+
run: ./vacuum lint -f .barbacane/rulesets/functions my-api.yaml
105131
```
106132
107133
### Pre-commit
108134
109135
```bash
110-
vacuum lint -r .vacuum.yml my-api.yaml
136+
vacuum lint -f .barbacane/rulesets/functions my-api.yaml
137+
```
138+
139+
## Custom Functions
140+
141+
Several rules use custom JavaScript functions for validations that go beyond what built-in vacuum functions can express (config schema validation, duplicate detection, secret reference format, etc.). Vacuum requires custom functions to be on the local filesystem — it does not fetch them from remote URLs.
142+
143+
The download steps above place these functions into `.barbacane/rulesets/functions/`. The `-f` flag in the `vacuum lint` command tells vacuum where to find them.
144+
145+
If you cloned the Barbacane repository, you can also point directly at the source:
146+
147+
```yaml
148+
# .vacuum.yml
149+
extends:
150+
- - path/to/Barbacane/docs/rulesets/barbacane.yaml
151+
- recommended
152+
```
153+
154+
```bash
155+
vacuum lint -f path/to/Barbacane/docs/rulesets/functions my-api.yaml
111156
```
112157

113158
## Plugin Config Schemas

0 commit comments

Comments
 (0)