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
* Add template action delimiter cli flag
* Add delims to generator config and template
Also adds tests using the "quote" test as a base. This has to have a
custom Instance name or it will clash with the "quotes" one and panic
since it will have registered two "swagger" instances in the package
test.
* Add testdata for custom delim flags
Based on the "quote" testdata.
* Add delims to the spec, with tests.
Make sure we don't add delims if they are empty. This shouldn't be
possible, but might as well be safe.
* Go mod tidy and sum update
* Make the CLI experience a bit cleaner
* Revert go.mod and sum
* Update readme
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).
0 commit comments