You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+13
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,7 @@ OPTIONS:
104
104
--overridesFile value File to read global type overrides from. (default: ".swaggo")
105
105
--parseGoList Parse dependency via 'go list' (default: true)
106
106
--tags value, -t value A comma-separated list of tags to filter the APIs for which the documentation is generated.Special caseif the tag is prefixed with the '!' character then the APIs with that tag will be excluded
107
+
--templateDelims value, --td value Provide custom delimeters for Go template generation. The format is leftDelim,rightDelim. For example: "[[,]]"
107
108
--collectionFormat value, --cf value Set default collection format (default: "csv")
108
109
--help, -h show help (default: false)
109
110
```
@@ -908,6 +909,18 @@ By default `swag` command generates Swagger specification in three different fil
908
909
909
910
If you would like to limit a set of file types which should be generated you can use `--outputTypes` (short `-ot`) flag. Default value is `go,json,yaml` - output types separated with comma. To limit output only to `go` and `yaml` files, you would write `go,yaml`. With completecommand that would be `swag init --outputTypes go,yaml`.
910
911
912
+
### Change the default Go Template action delimiters
If your swagger annotations or struct fields contain "{{" or "}}", the template generation will most likely fail, as these are the default delimiters for [go templates](https://pkg.go.dev/text/template#Template.Delims).
917
+
918
+
To make the generation work properly, you can change the default delimiters with `-td`. For example:
919
+
```console
920
+
swag init -g http/api.go -td "[[,]]"
921
+
```
922
+
The new delimiter is a string with the format "`<left delimiter>`,`<right delimiter>`".
923
+
911
924
## About the Project
912
925
This project was inspired by [yvasiyarov/swagger](https://github.com/yvasiyarov/swagger) but we simplified the usage and added support a variety of [web frameworks](#supported-web-frameworks). Gopher image source is [tenntenn/gopher-stickers](https://github.com/tenntenn/gopher-stickers). It has licenses [creative commons licensing](http://creativecommons.org/licenses/by/3.0/deed.en).
Copy file name to clipboardexpand all lines: cmd/swag/main.go
+21
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ const (
35
35
quietFlag="quiet"
36
36
tagsFlag="tags"
37
37
parseExtensionFlag="parseExtension"
38
+
templateDelimsFlag="templateDelims"
38
39
packageName="packageName"
39
40
collectionFormatFlag="collectionFormat"
40
41
)
@@ -143,6 +144,12 @@ var initFlags = []cli.Flag{
143
144
Value: "",
144
145
Usage: "A comma-separated list of tags to filter the APIs for which the documentation is generated.Special case if the tag is prefixed with the '!' character then the APIs with that tag will be excluded",
145
146
},
147
+
&cli.StringFlag{
148
+
Name: templateDelimsFlag,
149
+
Aliases: []string{"td"},
150
+
Value: "",
151
+
Usage: "Provide custom delimeters for Go template generation. The format is leftDelim,rightDelim. For example: \"[[,]]\"",
0 commit comments