OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA][WEBCLIENT] Webclient client generator uses rest template exceptions

Open
#6,301 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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
Suggest a fix

Change the java webclient mustache template to use WebClientResponseException instead of HttpClientErrorException

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.