File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import type { Serde } from "@restatedev/restate-sdk-core" ;
19
19
20
- import type { z } from "zod" ;
20
+ import { z , ZodVoid } from "zod" ;
21
21
import { zodToJsonSchema } from "zod-to-json-schema" ;
22
22
23
23
export type { Serde } from "@restatedev/restate-sdk-core" ;
24
24
25
25
class ZodSerde < T extends z . ZodType > implements Serde < z . infer < T > > {
26
- contentType = "application/json" ;
26
+ contentType ? = "application/json" ;
27
27
jsonSchema ?: object | undefined ;
28
28
29
29
constructor ( private readonly schema : T ) {
30
30
this . jsonSchema = zodToJsonSchema ( schema ) ;
31
+ if ( schema instanceof ZodVoid || schema instanceof z . ZodUndefined ) {
32
+ this . contentType = undefined ;
33
+ }
31
34
}
32
35
33
36
serialize ( value : T ) : Uint8Array {
Original file line number Diff line number Diff line change @@ -50,8 +50,7 @@ function handlerInputDiscovery(handler: HandlerWrapper): d.InputPayload {
50
50
51
51
if ( handler . inputSerde . jsonSchema ) {
52
52
jsonSchema = handler . inputSerde . jsonSchema ;
53
- contentType =
54
- handler . accept ?? handler . inputSerde . contentType ?? "application/json" ;
53
+ contentType = handler . accept ?? handler . inputSerde . contentType ;
55
54
} else if ( handler . accept ) {
56
55
contentType = handler . accept ;
57
56
} else if ( handler . inputSerde . contentType ) {
Original file line number Diff line number Diff line change @@ -455,7 +455,7 @@ export class HandlerWrapper {
455
455
public readonly enableLazyState ?: boolean ,
456
456
public readonly asTerminalError ?: ( error : any ) => TerminalError | undefined
457
457
) {
458
- this . accept = accept ? accept : inputSerde . contentType ;
458
+ this . accept = accept !== undefined ? accept : inputSerde . contentType ;
459
459
this . contentType = outputSerde . contentType ;
460
460
}
461
461
You can’t perform that action at this time.
0 commit comments