Skip to content

Commit

Permalink
feat: support only remain slash (#605)
Browse files Browse the repository at this point in the history
* support only remain slash

* fix gofmt

* move test in right place

Co-authored-by: sdghchj <sdghchj@qq.com>
Co-authored-by: Bogdan U <ubogdan@gmail.com>
  • Loading branch information
3 people committed Jan 10, 2020
1 parent 5b1151f commit ca464bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion operation.go
Expand Up @@ -505,7 +505,7 @@ func parseMimeTypeList(mimeTypeList string, typeList *[]string, format string) e
return nil
}

var routerPattern = regexp.MustCompile(`^(/[\w\.\/\-{}\+:]+)[[:blank:]]+\[(\w+)]`)
var routerPattern = regexp.MustCompile(`^(/[\w\.\/\-{}\+:]*)[[:blank:]]+\[(\w+)]`)

// ParseRouterComment parses comment for gived `router` comment string.
func (operation *Operation) ParseRouterComment(commentLine string) error {
Expand Down
9 changes: 9 additions & 0 deletions operation_test.go
Expand Up @@ -111,6 +111,15 @@ func TestParseRouterComment(t *testing.T) {
assert.Equal(t, "GET", operation.HTTPMethod)
}

func TestParseRouterOnlySlash(t *testing.T) {
comment := `// @Router / [get]`
operation := NewOperation()
err := operation.ParseComment(comment, nil)
assert.NoError(t, err)
assert.Equal(t, "/", operation.Path)
assert.Equal(t, "GET", operation.HTTPMethod)
}

func TestParseRouterCommentWithPlusSign(t *testing.T) {
comment := `/@Router /customer/get-wishlist/{proxy+} [post]`
operation := NewOperation()
Expand Down

0 comments on commit ca464bf

Please sign in to comment.