OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][WEBCLIENT] Webclient client generator uses rest template exceptions
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used? 4.3.1
- Have you search for related issues/PRs? None found
- What's the actual output vs expected output? The webclient openapi client uses rest template exceptions instead of webclient ones.
- [Optional] Bounty to sponsor the fix (example)
Description
The Spring webclient client generator is still using the old resttemplate exceptions. HttpClientErrorException is a RestTemplate exception, this can be verified by looking through the docs of its super class.
This would require code using the API generated by the library to handle both resttemplate and webclient exceptions.
openapi-generator version
Tested using version 4.3.1 of the maven plugin and generating the samples with the current master version.
OpenAPI declaration file content or url
Any spec will result in the error so the pet store default should serve as an example.
https://github.com/OpenAPITools/openapi-generator/blob/master/samples/yaml/api-docs.yml
Command line used for generation
Any webclient based config will result in the exception being used so I'll link the script to generate samples here to be used as an example.
https://github.com/OpenAPITools/openapi-generator/blob/master/bin/java-petstore-webclient.sh
Steps to reproduce
- Run the Java webclient test script ( https://github.com/OpenAPITools/openapi-generator/blob/master/bin/java-petstore-webclient.sh)
- Verify that it is using a HttpClientErrorException when validating null parameters
Suggest a fix
Change the java webclient mustache template to use WebClientResponseException instead of HttpClientErrorException
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with bin/java-petstore-webclient.sh and samples/yaml/api-docs.yml to reproduce the generated client behavior. Locate the Java webclient mustache template and verify the generated code uses the appropriate WebClient exception rather than the RestTemplate exception. Done means the generated client no longer uses HttpClientErrorException for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100