Skip to content

Commit

Permalink
feat: add compatibility with HL7 FHIR standard (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-hoffman authored Nov 18, 2021
1 parent 8d7941e commit 69fd233
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,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 given `router` comment string.
func (operation *Operation) ParseRouterComment(commentLine string) error {
Expand Down
21 changes: 21 additions & 0 deletions operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,27 @@ func TestParseRouterCommentWithPlusSign(t *testing.T) {
assert.Equal(t, "POST", operation.RouterProperties[0].HTTPMethod)
}

func TestParseRouterCommentWithDollarSign(t *testing.T) {
t.Parallel()

comment := `/@Router /customer/get-wishlist/{wishlist_id}$move [post]`
operation := NewOperation(nil)
err := operation.ParseComment(comment, nil)
assert.NoError(t, err)
assert.Len(t, operation.RouterProperties, 1)
assert.Equal(t, "/customer/get-wishlist/{wishlist_id}$move", operation.RouterProperties[0].Path)
assert.Equal(t, "POST", operation.RouterProperties[0].HTTPMethod)
}

func TestParseRouterCommentNoDollarSignAtPathStartErr(t *testing.T) {
t.Parallel()

comment := `/@Router $customer/get-wishlist/{wishlist_id}$move [post]`
operation := NewOperation(nil)
err := operation.ParseComment(comment, nil)
assert.Error(t, err)
}

func TestParseRouterCommentWithColonSign(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 69fd233

Please sign in to comment.