swag: $ sign in router path generates parse error
Describe the bug
Our API path includes $ signs, as they’re widely used in the FHIR medical record format. Including the $ signs in the router comment leads to a swag error:
ParseComment error in file main.go :can not parse router comment "/objects$modifier [get]"
To Reproduce
Create a main.go file with the following content:
package swag_test
// @id specialObjectList
// @Summary Special objects listing
// @Router /objects$modifier [get]
// @Description A special listing method...
// @Tags Test
func specialObjectList() {
}
Run swag init
Expected behavior
To have the /objects$modifier route correctly registered.
Your swag version e.g. 1.7.4
Your go version go1.17.2 darwin/amd64
Desktop (please complete the following information):
- OS: macOS 11.3.1
Additional context I believe #551 was a similar issue; I’d be happy to make a similar PR to add a $ sign into the regex if it would be accepted.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 15 (13 by maintainers)
Specifically, the FHIR spec defines operations which make use of the $ character. https://www.hl7.org/fhir/operations.html
We actually do manually add
$signs in to our generated definitions in order to have our paths display correctly in swagger-ui. We were hoping to avoid having to manually add them.In the end, this is an OSS project , feel free to contribute and break it 😄.