Skip to content

Commit

Permalink
feat: router path now supports plus sign, useful for swagger consumin…
Browse files Browse the repository at this point in the history
…g gateways that want to proxy, like AWS APIGW (#217)
  • Loading branch information
jameselsey authored and easonlin404 committed Sep 27, 2018
1 parent 0744535 commit 82de8d7
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 @@ -386,7 +386,7 @@ func (operation *Operation) ParseProduceComment(commentLine string) error {

// ParseRouterComment parses comment for gived `router` comment string.
func (operation *Operation) ParseRouterComment(commentLine string) error {
re := regexp.MustCompile(`([\w\.\/\-{}]+)[^\[]+\[([^\]]+)`)
re := regexp.MustCompile(`([\w\.\/\-{}\+]+)[^\[]+\[([^\]]+)`)
var matches []string

if matches = re.FindStringSubmatch(commentLine); len(matches) != 3 {
Expand Down
9 changes: 9 additions & 0 deletions operation_test.go
Expand Up @@ -105,6 +105,15 @@ func TestParseRouterComment(t *testing.T) {
assert.Equal(t, "GET", operation.HTTPMethod)
}

func TestParseRouterCommentWithPlusSign(t *testing.T) {
comment := `/@Router /customer/get-wishlist/{proxy+} [post]`
operation := NewOperation()
err := operation.ParseComment(comment, nil)
assert.NoError(t, err)
assert.Equal(t, "/customer/get-wishlist/{proxy+}", operation.Path)
assert.Equal(t, "POST", operation.HTTPMethod)
}

func TestParseRouterCommentOccursErr(t *testing.T) {
comment := `/@Router /customer/get-wishlist/{wishlist_id}`
operation := NewOperation()
Expand Down

0 comments on commit 82de8d7

Please sign in to comment.