Skip to content

Commit 6d21862

Browse files
committed
Produce: json
1 parent deebfcb commit 6d21862

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

coderd/coderdtest/swaggerparser.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ func assertAccept(t *testing.T, comment SwaggerComment) {
295295
}
296296
}
297297

298+
var allowedProduceTypes = []string{"json", "text/event-stream"}
299+
298300
func assertProduce(t *testing.T, comment SwaggerComment) {
299301
var hasResponseModel bool
300302
for _, r := range comment.successes {
@@ -306,6 +308,7 @@ func assertProduce(t *testing.T, comment SwaggerComment) {
306308

307309
if hasResponseModel {
308310
assert.True(t, comment.produce != "", "Route must have @Produce annotation as it responds with a model structure")
311+
assert.Contains(t, allowedProduceTypes, comment.produce, "@Produce value is limited to specific types: %s", strings.Join(allowedProduceTypes, ","))
309312
} else {
310313
if (comment.router == "/workspaceagents/me/app-health" && comment.method == "post") ||
311314
(comment.router == "/workspaceagents/me/version" && comment.method == "post") ||

coderd/workspaceagents.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
826826
// @ID submit-workspace-agent-stats
827827
// @Security CoderSessionToken
828828
// @Accept json
829-
// @Produce application/json
829+
// @Produce json
830830
// @Tags Agents
831831
// @Param request body codersdk.AgentStats true "Stats request"
832832
// @Success 200 {object} codersdk.AgentStatsResponse
@@ -904,7 +904,7 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
904904
// @ID submit-workspace-agent-application-health
905905
// @Security CoderSessionToken
906906
// @Accept json
907-
// @Produce application/json
907+
// @Produce json
908908
// @Tags Agents
909909
// @Param request body codersdk.PostWorkspaceAppHealthsRequest true "Application health request"
910910
// @Success 200

0 commit comments

Comments
 (0)