@@ -54,13 +54,13 @@ def __init__(self, required: bool, contentType: str, jsonSchema: Optional[Any] =
54
54
self .jsonSchema = jsonSchema
55
55
56
56
class OutputPayload :
57
- def __init__ (self , contentType : str , setContentTypeIfEmpty : bool , jsonSchema : Optional [Any ] = None ):
57
+ def __init__ (self , setContentTypeIfEmpty : bool , contentType : Optional [ str ] = None , jsonSchema : Optional [Any ] = None ):
58
58
self .contentType = contentType
59
59
self .setContentTypeIfEmpty = setContentTypeIfEmpty
60
60
self .jsonSchema = jsonSchema
61
61
62
62
class Handler :
63
- def __init__ (self , name : str , ty : Optional [ServiceHandlerType ] = None , input : Optional [InputPayload ] = None , output : Optional [OutputPayload ] = None , description : Optional [str ] = None , metadata : Optional [Dict [str , str ]] = None ):
63
+ def __init__ (self , name : str , ty : Optional [ServiceHandlerType ] = None , input : Optional [InputPayload | Dict [ str , str ] ] = None , output : Optional [OutputPayload ] = None , description : Optional [str ] = None , metadata : Optional [Dict [str , str ]] = None ):
64
64
self .name = name
65
65
self .ty = ty
66
66
self .input = input
@@ -180,13 +180,20 @@ def compute_discovery(endpoint: RestateEndpoint, discovered_as : typing.Literal[
180
180
else :
181
181
ty = None
182
182
# input
183
- inp = InputPayload (required = False ,
184
- contentType = handler .handler_io .accept ,
185
- jsonSchema = json_schema_from_type_hint (handler .handler_io .input_type ))
183
+ inp : Optional [InputPayload | Dict [str , str ]] = None
184
+ if handler .handler_io .input_type and handler .handler_io .input_type .is_void :
185
+ inp = {}
186
+ else :
187
+ inp = InputPayload (required = False ,
188
+ contentType = handler .handler_io .accept ,
189
+ jsonSchema = json_schema_from_type_hint (handler .handler_io .input_type ))
186
190
# output
187
- out = OutputPayload (setContentTypeIfEmpty = False ,
188
- contentType = handler .handler_io .content_type ,
189
- jsonSchema = json_schema_from_type_hint (handler .handler_io .output_type ))
191
+ if handler .handler_io .output_type and handler .handler_io .output_type .is_void :
192
+ out = OutputPayload (setContentTypeIfEmpty = False )
193
+ else :
194
+ out = OutputPayload (setContentTypeIfEmpty = False ,
195
+ contentType = handler .handler_io .content_type ,
196
+ jsonSchema = json_schema_from_type_hint (handler .handler_io .output_type ))
190
197
# add the handler
191
198
service_handlers .append (Handler (name = handler .name ,
192
199
ty = ty ,
0 commit comments