Skip to content

Commit

Permalink
feat: added deprecation parsing (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerzal authored and easonlin404 committed Jun 12, 2019
1 parent f7df9bf commit b534de4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func (operation *Operation) ParseComment(comment string, astFile *ast.File) erro
if err := operation.ParseSecurityComment(lineRemainder); err != nil {
return err
}
case "@deprecated":
operation.Deprecate()
}
return nil
}
Expand Down
16 changes: 15 additions & 1 deletion operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,8 @@ func TestParseMultiDescription(t *testing.T) {
assert.NoError(t, err)

comment = `@Tags multi`
operation.ParseComment(comment, nil)
err = operation.ParseComment(comment, nil)
assert.NoError(t, err)

comment = `@Description line two x`
err = operation.ParseComment(comment, nil)
Expand All @@ -722,3 +723,16 @@ func TestParseMultiDescription(t *testing.T) {
expected := `"description": "line one\nline two x"`
assert.Contains(t, string(b), expected)
}

func TestParseDeprecationDescription(t *testing.T) {
comment := `@Deprecated`
operation := NewOperation()
operation.parser = New()

err := operation.ParseComment(comment, nil)
assert.NoError(t, err)

if !operation.Deprecated {
t.Error("Failed to parse @deprecated comment")
}
}

0 comments on commit b534de4

Please sign in to comment.