Comments (4)
Hey @drapej,
thank you for reporting this issue.
I created a test with the sample that you provided for the return type RedirectView
. You are correct. The spring internal for produces is empty for that case. So I fixed that.
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.
I would have to document that for this particular case it won't return anything for produces, but it does for others and so on. It would also create a weird behaviour for the code above.
So instead of creating a special case, I'd rather keep it simple and leave the HttpServletResponse case as is. This is where hikaku has it's limits.
from hikaku.
Hi @cc-jhr,
Thank you for your answer.
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.
from hikaku.
Hi @drapej,
sorry it took me some time to respond.
You are correct. If there is no return type the list of produces entries should be empty. That case was currently missing.
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.
I created a second test for that. If that looks fine to you, we could release that.
from hikaku.
Hi @cc-jhr,
No problem for the delay ;)
"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.
from hikaku.
Related Issues (20)
- Failed to get the implementation on Spring MVC 5.3.18
- Support OpenAPI 3.1
- Spring endpoints not discovered, `RequestMappingInfo.patternsCondition` returns null
- Support google-style custom methods api paths
- Add windows CI build
- Support OpenApi common parameters
- Fix linux build
- Tests for ClassLocator
- Query Parameter based on an object HOT 2
- Update spring-mvc to 5.2.0
- Unable to get code running on OpenJDK 11 HOT 9
- Support Spring Webflux HOT 3
- ResponseEntity<Unit> produces 'application/json' HOT 2
- Base API path not considered HOT 2
- Allow undeclared endpoints HOT 1
- Regex error in regex replacement HOT 1
- Cannot locate classes with javax.ws.rs.Path HOT 1
- Allow to disable adding the HEAD and OPTIONS endpoints automatically in the Spring Converter HOT 2
- Will ktor be supported by Hikaku?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hikaku.