@@ -207,6 +207,20 @@ def generateBySpec(
207
207
| asStringAlways.mapWithMetadata((body, metadata) =>
208
208
| if metadata.isSuccess then body.fromJson[T].left.map(e => DeserializationException(body, Exception(e)))
209
209
| else Left(HttpError(body, metadata.code))
210
+ | )""" .stripMargin,
211
+ " " ,
212
+ config.httpSource match
213
+ case HttpSource .Sttp4 =>
214
+ """ |def asEmptyResponse: ResponseAs[Either[ResponseException[String], String]] =
215
+ | asStringAlways.mapWithMetadata((body, metadata) =>
216
+ | if metadata.isSuccess then Right(body)
217
+ | else Left(UnexpectedStatusCode(body, metadata))
218
+ | )""" .stripMargin
219
+ case HttpSource .Sttp3 =>
220
+ """ |def asEmptyResponse: ResponseAs[Either[ResponseException[String, Exception], String], Any] =
221
+ | asStringAlways.mapWithMetadata((body, metadata) =>
222
+ | if metadata.isSuccess then Right(body)
223
+ | else Left(HttpError(body, metadata.code))
210
224
| )""" .stripMargin
211
225
).mkString(" \n " )
212
226
)
@@ -402,9 +416,9 @@ def resourceCode(
402
416
def responseType (t : String ) =
403
417
httpSource match
404
418
case HttpSource .Sttp4 =>
405
- s " Request[Either[ ${ if t == " String " then " String " else " ResponseException[String]" } , $t]] "
419
+ s " Request[Either[ResponseException[String], $t]] "
406
420
case HttpSource .Sttp3 =>
407
- s " RequestT[Identity, Either[ ${ if t == " String " then " String " else " ResponseException[String, Exception]" } , $t], Any] "
421
+ s " RequestT[Identity, Either[ResponseException[String, Exception], $t], Any] "
408
422
409
423
val (resType, mapResponse) = v.response match
410
424
case Some (r) if r.schemaPath.forall(hasProps) =>
@@ -414,7 +428,7 @@ def resourceCode(
414
428
responseType(bodyType),
415
429
s " .response(asJson[ $bodyType]) "
416
430
)
417
- case _ => (responseType(" String" ), " " )
431
+ case _ => (responseType(" String" ), " .response(asEmptyResponse) " )
418
432
419
433
s """ |def ${toScalaName(k)}(\n ${params.mkString(" ,\n " )}): $resType = { $queryParams
420
434
| $setReqUri
0 commit comments