-
-
Notifications
You must be signed in to change notification settings - Fork 484
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Using AuthType.Bearer adds a ghost 404 to the generated OpenAPI spec.
To Reproduce
import zio.http.*
import zio.http.endpoint.*
import zio.http.endpoint.openapi.OpenAPIGen
val withBearer = Endpoint(Method.GET / "example").auth(AuthType.Bearer).out[String]
val noAuth = Endpoint(Method.GET / "example").out[String]
// Includes 404 response
println(OpenAPIGen.gen(withBearer).toJsonPretty)
// No 404 response
println(OpenAPIGen.gen(noAuth).toJsonPretty)Expected behaviour
Not sure, but I assume conform to outErrors.
Screenshots
println:
{
"openapi" : "3.1.0",
"info" : {
"title" : "",
"version" : ""
},
"paths" : {
"/example" : {
"get" : {
"responses" : {
"404" : {
"description" : "Not Found\n\n"
},
"200" : {
"content" : {
"application/json" : {
"schema" : {
"type" : "string"
}
}
}
}
},
"security" : [
{
"Bearer" : []
}
]
}
}
},
"components" : {
"securitySchemes" : {
"Bearer" : {
"type" : "http",
"scheme" : "Bearer"
}
}
},
"security" : [
{
"Bearer" : []
}
]
}
{
"openapi" : "3.1.0",
"info" : {
"title" : "",
"version" : ""
},
"paths" : {
"/example" : {
"get" : {
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"type" : "string"
}
}
}
}
}
}
}
},
"components" : {
}
}
Additional context
- The alternative
Bearer.withUnauthorizedStatuserases the type in Endpoint toAuthTypeinstead ofAuthType.Bearer.type. Not really related to the bug. - Looks like unauthorizedStatus defaults to Status.NotFound.
sealed trait AuthType { self =>
type ClientRequirement
def codec: HttpCodec[HttpCodecType.RequestType, ClientRequirement]
def unauthorizedStatus: Status = Status.NotFound
def withUnauthorizedStatus(status: Status): AuthType =
AuthType
.WithStatus(self.asInstanceOf[AuthType { type ClientRequirement = self.ClientRequirement }], status)
.asInstanceOf[AuthType { type ClientRequirement = self.ClientRequirement }]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working