Open musjj opened 1 month ago
Current, if you try to set multiple Set-Cookie headers, only the last one is used:
Set-Cookie
struct Api; #[derive(ApiResponse)] pub enum FooResponse { #[oai(status = 200)] SetCookie( #[oai(header = "Set-Cookie")] String, #[oai(header = "Set-Cookie")] String, ), } #[OpenApi] impl Api { #[oai(path = "/foo", method = "get")] pub async fn foo(&self) -> FooResponse { FooResponse::SetCookie("foo=1".into(), "bar=1".into()) } }
$ curl -I http://localhost:3000/foo HTTP/1.1 200 OK set-cookie: bar=1 date: Fri, 11 Oct 2024 16:21:35 GMT
This is a limitation of the current OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/issues/1237.
But is there a way to work around this? Is there a way to set additional headers in the response object beyond what is annotated in the struct?
Description of the feature
Current, if you try to set multiple
Set-Cookie
headers, only the last one is used:This is a limitation of the current OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/issues/1237.
But is there a way to work around this? Is there a way to set additional headers in the response object beyond what is annotated in the struct?