You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we don't support flag-like query parameters.
query[Option[String]]("flag") decodes ?flag into a None and ?flag= into a Some("")
I'm not sure how this should be represented in an OpenAPI spec. There is the allowEmptyValues field (see https://swagger.io/specification/), but it's deprecated and shouldn't be used. There is a large discussion here: OAI/OpenAPI-Specification#1573, but I think it doesn't reach a conclusion as to how to represent this in OpenAPI. So more research would be needed.
On the tapir side, I think we'll need to add a new field to Query which would store the value, that should be used for the query parameter, in case no value is provided. Sth like query[String]("flag").valueWhenNoValue("true"), except with a better name :)
The text was updated successfully, but these errors were encountered:
For the time being a possible workaround would be to combine two definitions:
defqueryFlag(name: String, description: String="") = {
// this is false when the query parameter exists without a valuevala= query[Option[Boolean]](name)
.description(description)
.example(EndpointIO.Example(true.some, "true".some, None))
.example(EndpointIO.Example(false.some, "false".some, None))
// this is true when the query parameter exists without a value, but same as (a) otherwise// but it is not added to the documentationvalb= queryParams
.map(qp => qp.getMulti(name).exists(_.forall(_.equalsIgnoreCase("true"))))(flag =>QueryParams.fromMap(Map(name -> flag.toString))
)
// combining both does the job…
(a / b).map(_._2)(flag => (flag.some, flag))
}
Currently we don't support flag-like query parameters.
query[Option[String]]("flag")
decodes?flag
into aNone
and?flag=
into aSome("")
I'm not sure how this should be represented in an OpenAPI spec. There is the
allowEmptyValues
field (see https://swagger.io/specification/), but it's deprecated and shouldn't be used. There is a large discussion here: OAI/OpenAPI-Specification#1573, but I think it doesn't reach a conclusion as to how to represent this in OpenAPI. So more research would be needed.On the tapir side, I think we'll need to add a new field to
Query
which would store the value, that should be used for the query parameter, in case no value is provided. Sth likequery[String]("flag").valueWhenNoValue("true")
, except with a better name :)The text was updated successfully, but these errors were encountered: