File tree 4 files changed +41
-4
lines changed
4 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 5
5
always_run : false
6
6
fail_fast : false
7
7
verbose : false
8
- description : ' Run swag fmt to format Swaggo comments in your code'
8
+ description : ' Run swag fmt to format Swag annotations in your code.'
9
+ args : []
10
+
11
+ - id : swag-init
12
+ name : swag-init
13
+ entry : run-swag-init.sh
14
+ language : script
15
+ always_run : false
16
+ fail_fast : false
17
+ verbose : false
18
+ description : ' Run swag init to generate Swagger docs from Swag annotations, and generate the required files.'
9
19
args : []
Original file line number Diff line number Diff line change @@ -13,11 +13,19 @@ repos:
13
13
rev : " main"
14
14
hooks :
15
15
- id : swag-fmt
16
+ - id : swag-init
16
17
` ` `
17
18
18
19
Arguments to ` swag` can be passed as `args`.
19
20
20
- For example, to pass the `--exclude` flag to `swag fmt` :
21
+ The example below shows :
22
+
23
+ - How to pass the `--exclude` flag to `swag fmt`
24
+ - How to run the equivalent of `swag init` with these flags :
25
+
26
+ ` ` `
27
+ swag init --parseInternal --requiredByDefault --parseDependency --dir "./cmd/api/" --generalInfo routes.go --output ./cmd/api/docs/
28
+ ` ` `
21
29
22
30
` ` ` yaml
23
31
repos:
@@ -27,7 +35,15 @@ repos:
27
35
hooks:
28
36
- id: swag-fmt
29
37
args:
30
- - --exclude ./a/special/file.go
38
+ - --exclude=./a/special/file.go
39
+ - id: swag-init
40
+ args:
41
+ - --parseInternal
42
+ - --requiredByDefault
43
+ - --parseDependency
44
+ - --dir=./cmd/api/
45
+ - --generalInfo=routes.go
46
+ - --output=./cmd/api/docs/
31
47
` ` `
32
48
33
49
# # Available Hooks
@@ -36,3 +52,5 @@ All of these hooks require [swaggo/swag](https://github.com/swaggo/swag#getting-
36
52
in your `$PATH`.
37
53
38
54
- ` swag-fmt` - Runs `swag fmt` on all files in the project.
55
+ - ` swag-init` - Runs `swag init` on the project. Please
56
+ reference [available CLI flags in the documentation](https://github.com/swaggo/swag#swag-cli).
Original file line number Diff line number Diff line change 6
6
exit 1
7
7
fi
8
8
9
- swag fmt $@
9
+ swag fmt " $@ "
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ if ! which swag & > /dev/null
4
+ then
5
+ echo " swag could not be found. Please ensure it is installed and available on your PATH."
6
+ exit 1
7
+ fi
8
+
9
+ swag init " $@ "
You can’t perform that action at this time.
0 commit comments