Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/oapi-gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ func docToString(cg *ast.CommentGroup) string {
return ""
}

s = strings.Join(strings.Split(s, "\n"), " ")
s = strings.TrimSuffix(s, "\n")
s = strings.Join(strings.Split(s, "\n"), "\\n") // Escape newlines.
return strings.TrimSpace(s)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/oapi-gen/testdata/all.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cmd/oapi-gen/testdata/not-all.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cmd/oapi-gen/testdata/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ package testdata
//
//openapi:gen
type TestObject struct {
// A is an example field with "quotes".
// A is an example field with "quotes"
// and a newline.
A string `json:"a"`

// B is another example field.
Expand Down
2 changes: 1 addition & 1 deletion gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ type TestObject struct {

func (TestObject) Docs() map[string]string {
return map[string]string{
"test1": "Some test docs",
"test1": "Test1 is an documented field with "quotes"\nand a newline.",
}
}

Expand Down
2 changes: 1 addition & 1 deletion testdata/spec-pkgseg0.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"properties": {
"test1": {
"description": "Some test docs",
"description": "Test1 is an documented field with \u0026#34;quotes\u0026#34;\nand a newline.",
"type": "string"
},
"test2": {
Expand Down
2 changes: 1 addition & 1 deletion testdata/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"properties": {
"test1": {
"description": "Some test docs",
"description": "Test1 is an documented field with \u0026#34;quotes\u0026#34;\nand a newline.",
"type": "string"
},
"test2": {
Expand Down
Loading