(t *testing.T, comment SwaggerComment)
| 361 | } |
| 362 | |
| 363 | func assertAccept(t *testing.T, comment SwaggerComment) { |
| 364 | var hasRequestBody bool |
| 365 | for _, c := range comment.parameters { |
| 366 | if c.name == "request" && c.kind == "body" || |
| 367 | c.name == "file" && c.kind == "formData" { |
| 368 | hasRequestBody = true |
| 369 | break |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | var hasAccept bool |
| 374 | if comment.accept != "" { |
| 375 | hasAccept = true |
| 376 | } |
| 377 | |
| 378 | if comment.method == "get" { |
| 379 | assert.Empty(t, comment.accept, "GET route does not require the @Accept annotation") |
| 380 | assert.False(t, hasRequestBody, "GET route does not require the request body") |
| 381 | } else { |
| 382 | assert.False(t, hasRequestBody && !hasAccept, "Route with the request body requires the @Accept annotation") |
| 383 | assert.False(t, !hasRequestBody && hasAccept, "Route with @Accept annotation requires the request body or file formData parameter") |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | var allowedProduceTypes = []string{"json", "text/event-stream", "text/html", "text/plain"} |
| 388 |
no test coverage detected