@@ -493,11 +493,10 @@ fn response_type(response: &ReferenceOr<Response>, ref_cache: &mut RefCache) ->
493493 "Reference in response top level: {reference}"
494494 ) ) ) ,
495495 ReferenceOr :: Item ( resp) => {
496- if resp. content . len ( ) != 1 {
497- Err ( Error :: unimplemented (
498- "Response content with not exactly 1 option." ,
499- ) )
500- } else {
496+ if resp. content . len ( ) == 0 {
497+ // No content case
498+ Ok ( DataType :: Unit )
499+ } else if resp. content . len ( ) == 1 {
501500 let ( content_type, media_type) = resp. content . first ( ) . unwrap ( ) ;
502501
503502 if content_type. starts_with ( "application/json" ) {
@@ -520,6 +519,10 @@ fn response_type(response: &ReferenceOr<Response>, ref_cache: &mut RefCache) ->
520519 "Response content type: {content_type}"
521520 ) ) )
522521 }
522+ } else {
523+ Err ( Error :: unimplemented (
524+ "Response content with not exactly 1 option." ,
525+ ) )
523526 }
524527 }
525528 }
@@ -883,6 +886,7 @@ fn status_match(range_results: bool, code: &StatusCode) -> RustPrinter {
883886fn response_body_parsing ( data_type : & DataType ) -> RustPrinter {
884887 match data_type {
885888 DataType :: Binary => unit ( ) + "response.bytes().await?" ,
889+ DataType :: Unit => unit ( ) + "()" ,
886890 _ => unit ( ) + "response.json::<" + data_type. render_declaration ( false ) + ">().await?" ,
887891 }
888892}
0 commit comments