Skip to content

Commit

Permalink
fix OpenAPI code gen not quoting arbitrary header names (#3136)
Browse files Browse the repository at this point in the history
  • Loading branch information
geeeezmo authored Sep 18, 2024
1 parent 1988b18 commit a52f6f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ object CodeGen {
case "www-authenticate" => "HeaderCodec.wwwAuthenticate"
case "x-frame-options" => "HeaderCodec.xFrameOptions"
case "x-requested-with" => "HeaderCodec.xRequestedWith"
case name => s"HeaderCodec.name[String]($name)"
case name => s"""HeaderCodec.name[String]("$name")"""
}
s""".header($headerSelector)"""
}
Expand Down
1 change: 1 addition & 0 deletions zio-http-gen/src/test/resources/EndpointWithHeaders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ object Users {
val get = Endpoint(Method.GET / "api" / "v1" / "users")
.header(HeaderCodec.accept)
.header(HeaderCodec.contentType)
.header(HeaderCodec.name[String]("token"))
.in[Unit]

}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ object CodeGenSpec extends ZIOSpecDefault {
},
test("Endpoint with headers") {
val endpoint =
Endpoint(Method.GET / "api" / "v1" / "users").header(HeaderCodec.accept).header(HeaderCodec.contentType)
Endpoint(Method.GET / "api" / "v1" / "users")
.header(HeaderCodec.accept)
.header(HeaderCodec.contentType)
.header(HeaderCodec.name[String]("Token"))
val openAPI = OpenAPIGen.fromEndpoints(endpoint)

codeGenFromOpenAPI(openAPI) { testDir =>
Expand Down

0 comments on commit a52f6f6

Please sign in to comment.