Skip to content

Commit

Permalink
fix OpenAPI not deserializing lowercase value of 'in' field in securi…
Browse files Browse the repository at this point in the history
…ty schemes (#3107)

fix OpenAPI not decoding 'in' field in security schemes
  • Loading branch information
geeeezmo authored Sep 7, 2024
1 parent ecd4e0a commit 48fddcd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,23 @@ object OpenAPI {
sealed trait In extends Product with Serializable

object In {
implicit val schema: Schema[In] =
Schema[String]
.transformOrFail(
s =>
s.toLowerCase match {
case "query" => Right(Query)
case "header" => Right(Header)
case "cookie" => Right(Cookie)
case value => Left(s"Invalid ApiKey.In $s")
},
{
case Query => Right("query")
case Header => Right("header")
case Cookie => Right("cookie")
},
)

case object Query extends In

case object Header extends In
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object OpenAPISpec extends ZIOSpecDefault {
| {
| "type" : "apiKey",
| "name" : "Authorization",
| "in" : "Header"
| "in" : "header"
| }
| }
| },
Expand Down

0 comments on commit 48fddcd

Please sign in to comment.