MCPcopy Index your code
hub / github.com/coder/coder / assertAccept

Function assertAccept

coderd/coderdtest/swaggerparser.go:363–385  ·  view source on GitHub ↗
(t *testing.T, comment SwaggerComment)

Source from the content-addressed store, hash-verified

361}
362
363func 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
387var allowedProduceTypes = []string{"json", "text/event-stream", "text/html", "text/plain"}
388

Callers 1

VerifySwaggerDefinitionsFunction · 0.85

Calls 1

EmptyMethod · 0.45

Tested by

no test coverage detected