-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spring Redirect Enpoint : produces attribute not empty #50
Comments
Hey @drapej, thank you for reporting this issue. I created a test with the sample that you provided for the return type The other case is tricky. Because the following works fine: @SpringBootApplication
open class DummyApp
fun main(args: Array<String>) {
runApplication<DummyApp>(*args)
}
@Controller
open class ProducesServletResponseTestController {
@GetMapping("/todos")
@ResponseBody
fun getTest(response: HttpServletResponse) {
response.outputStream.println("Hello, world!")
}
} Although I have no return type on the function I can call the endpoint and receive the Hello world. I don't see any possibility to distinguish the normal case from a redirect for that setup. |
Hi @cc-jhr, In your second case, if your put that, that's not work because Hikaku produces endpoint with "application/json". @GetMapping("/todos", produces = ["text/plain"])
@ResponseBody
fun getTest(response: HttpServletResponse) {
response.outputStream.println("Hello, world!")
} That's what I don't understand, why Hikaku generates a produce for endpoints that don't have a return and not uses only the produces specified. |
Hi @drapej, sorry it took me some time to respond. I created a second test for that. If that looks fine to you, we could release that. |
Hi @cc-jhr, "In a case like the one we discussed above (HttpServletResponse, no return type), I'd expect the developer to set the value produces explicitly. The library shouldn't make any assumptions there." => totally agree with you 👍 Thank you for the new test with no return type, it's perfect. |
Setup information
hikaku version: 3.0.0
specification converter: OpenApiConverter
implementation converter: SpringConverter
build tool and version: gradle 5.6.4
test framework: junit5
Describe the bug
Hi,
we have a problem with Spring endpoints which must return a redirect URL (status 302 or 301).
When we run the Hikaku test, Hikaku generate a "produces" attribute for this endpoint, and so the test fail because our OpenApi Endpoint doesn't have a content.
This generation of produces attribute is in the ProducesSpringExtension, and for now, to have a empty produces, the endpoint have to respect one of these condition :
In other case, it used the produces (if it's present) or put a default produces
Expected behavior
When endpoint :
Then ProducesSpringExtension return the produces attribute define in the endpoint.
N.B. : when we do a redirect with the HttpServletResponse, we don't have to specify a @ResponseStatus but this is the only way I think to differentiate in the ProducesSpringExtension a Redirect from another status
Code samples
Sample of the current bug
I can if you want suggest a PR.
The text was updated successfully, but these errors were encountered: