I’ve already created an github issue for this,
just bringing it here, might be useful
Guys, I’m not sure if tapir is able to parse x-www-form-urlencoded
request bodies
I use .in(formBody[A])
and Codec.formCaseClassCodec
for type A.
for instance, my endpoint looks like this:
ztapir
.endpoint
.post
.in(formBody[UpdatePoliciesForm])
where UpdatePoliciesForm
is the following:
import sttp.tapir.generic.auto._
final case class UpdatePasswordForm(
login: Login,
password: Password
) extends Serializable
object UpdatePasswordForm {
implicit val formBodyCodec: Codec[String, UpdatePasswordForm, CodecFormat.XWwwFormUrlencoded] =
Codec.formCaseClassCodec
}
So requests like
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'login=dmedser' \
--data-urlencode 'password=p@ssw0rd' \
lead to an error, while only the following request could be parsed successfully
--header 'Content-Type: text/plain' \
--data-raw 'login=dmedser&password=p@ssw0rd'
but Content-Type and data format aren’t what I expect
If you take a look at formBody
you may notice that it seems the same as raw string body
def formBody[T: Codec[String, *, CodecFormat.XWwwFormUrlencoded]]: EndpointIO.Body[String, T] =
stringBodyUtf8AnyFormat[T, CodecFormat.XWwwFormUrlencoded](implicitly)
I’m not sure if that’s the reason, just FYI