Skip to content

Commit 513dcb4

Browse files
committed
fix(rivetkit): fix zod not validating body if content-type header not provided
1 parent 51383ee commit 513dcb4

File tree

1 file changed

+13
-14
lines changed
  • rivetkit-typescript/packages/rivetkit/src/manager

1 file changed

+13
-14
lines changed

rivetkit-typescript/packages/rivetkit/src/manager/router.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ function buildOpenApiResponses<T>(schema: T) {
7979
};
8080
}
8181

82+
function buildOpenApiRequestBody<T>(schema: T) {
83+
return {
84+
required: true,
85+
content: {
86+
"application/json": {
87+
schema,
88+
},
89+
},
90+
};
91+
}
92+
8293
export function createManagerRouter(
8394
registryConfig: RegistryConfig,
8495
runConfig: RunnerConfig,
@@ -405,13 +416,7 @@ function addManagerRoutes(
405416
method: "put",
406417
path: "/actors",
407418
request: {
408-
body: {
409-
content: {
410-
"application/json": {
411-
schema: ActorsGetOrCreateRequestSchema,
412-
},
413-
},
414-
},
419+
body: buildOpenApiRequestBody(ActorsGetOrCreateRequestSchema),
415420
},
416421
responses: buildOpenApiResponses(ActorsGetOrCreateResponseSchema),
417422
});
@@ -457,13 +462,7 @@ function addManagerRoutes(
457462
method: "post",
458463
path: "/actors",
459464
request: {
460-
body: {
461-
content: {
462-
"application/json": {
463-
schema: ActorsCreateRequestSchema,
464-
},
465-
},
466-
},
465+
body: buildOpenApiRequestBody(ActorsCreateRequestSchema),
467466
},
468467
responses: buildOpenApiResponses(ActorsCreateResponseSchema),
469468
});

0 commit comments

Comments
 (0)