Skip to content

Commit

Permalink
Merge pull request #84 from Teamwork/fix/multiline-enum-issues
Browse files Browse the repository at this point in the history
Fix: multiline enum was generating bad swagger
  • Loading branch information
shane-tw authored Oct 8, 2021
2 parents 5465e14 + f2f9e18 commit 1cc15ec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
go:
- 1.10.x
- 1.17.x
go_import_path: github.com/teamwork/kommentaar
notifications:
email: false
Expand All @@ -10,6 +10,8 @@ cache:
- $HOME/.cache/go-build
install:
- ./bin/setup-travis
env:
- GO111MODULE=off
script:
- cd $HOME/gopath/src/github.com/teamwork/kommentaar
- ./bin/test -race ./...
Expand Down
3 changes: 2 additions & 1 deletion docparse/jsonschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func setTags(name, fName string, p *Schema, tags []string) error {
switch {
case strings.HasPrefix(t, "enum: "):
p.Type = "enum"
for _, e := range strings.Split(t[5:], " ") {
t = strings.ReplaceAll(t[5:], "\n", " ")
for _, e := range strings.Split(t, " ") {
e = strings.TrimSpace(e)
if e != "" {
p.Enum = append(p.Enum, e)
Expand Down
2 changes: 1 addition & 1 deletion docparse/jsonschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestFieldToProperty(t *testing.T) {
"deeper": {Reference: "a.refAnother"},
"docs": {Type: "string", Description: "This has some documentation!",
Required: []string{"docs"},
Enum: []string{"one", "two", "three"},
Enum: []string{"one", "two", "three", "four", "five", "six", "seven"},
},
}

Expand Down
3 changes: 2 additions & 1 deletion docparse/testdata/src/a/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type foo struct {
deeper refAnother

// This has some documentation! {required}
// {enum: one two three}
// {enum: one two three
// four five six seven}
docs string
//m map[string]int
}
Expand Down

0 comments on commit 1cc15ec

Please sign in to comment.