Skip to content

Commit

Permalink
Merge pull request #15 from jsightapi/SERV-391
Browse files Browse the repository at this point in the history
SERV-391 jsigth to openapi yaml, fix last line break for yaml
  • Loading branch information
add2 authored Apr 22, 2024
2 parents a8fa709 + 7692471 commit fc9137e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ func Test_openapi(t *testing.T) {
info:
title: ""
version: ""
paths: {}
`
paths: {}`

cc := map[string]testCase{
http.MethodOptions: {
Expand Down
9 changes: 8 additions & 1 deletion openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@ func jsonToYAML(jsonData []byte) ([]byte, error) {
return nil, err
}

return to.Bytes(), nil
return removeLastLineBreak(to), nil
}

func removeLastLineBreak(input *bytes.Buffer) []byte {
if bs := input.Bytes(); len(bs) > 0 && bs[len(bs)-1] == '\n' {
return bs[:len(bs)-1]
}
return input.Bytes()
}

0 comments on commit fc9137e

Please sign in to comment.