Skip to content

scala3-sttp4-jsoniter - code does compile when separateErrorChannel=false #22047

@kamilkloch

Description

@kamilkloch

Example generated code with separateErrorChannel=true (code does compile):

  def appRoleDeleteBindSecretId(roleName: String, approleMountPath: String): sttp.client4.Request[Either[ResponseException[String], Unit]] =
    val roleNamePathParam = PathSerializable.serialize("role_name", roleName, PathStyleFormat.SIMPLE, false)
    val approleMountPathPathParam = PathSerializable.serialize("approle_mount_path", approleMountPath, PathStyleFormat.SIMPLE, false)
    val requestURL =
      uri"$baseUrl/auth/${approleMountPathPathParam}/role/${roleNamePathParam}/bind-secret-id"

    basicRequest
      .method(Method.DELETE, requestURL)
      .contentType("application/json")
      .response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))))

Example generated code with separateErrorChannel=false (code does not compile):

def appRoleDeleteBindSecretId(roleName: String, approleMountPath: String): sttp.client4.Request[Unit] =
    val roleNamePathParam = PathSerializable.serialize("role_name", roleName, PathStyleFormat.SIMPLE, false)
    val approleMountPathPathParam = PathSerializable.serialize("approle_mount_path", approleMountPath, PathStyleFormat.SIMPLE, false)
    val requestURL =
      uri"$baseUrl/auth/${approleMountPathPathParam}/role/${roleNamePathParam}/bind-secret-id"

    basicRequest
      .method(Method.DELETE, requestURL)
      .contentType("application/json")
      .response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))).getRight)

value getRight is not a member of sttp.client4.ResponseAs[Either[sttp.client4.ResponseException[String], Unit]] - did you mean sttp.client4.ResponseAs[Either[sttp.client4.ResponseException[String], Unit]].mapRight?
      .response(asString.mapWithMetadata(ResponseAs.deserializeRightWithError(_ => Right(()))).getRight)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions