OpenAPITools / OpenAPITools/openapi-generator

[BUG] Incorrect example for java resttemplate client

Open
#13,527 2 comments 1 reaction 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

Description

README.md contains incorrect usage guide - it uses class "Configuration" which not generated by this generator (and some others, f.e. webclient).

Looks like usage guide is just copy-paste of "okhttp-gson" guide.

The main problem (from my point of view) that this guide included into generated artifact (I don't think that it's correct to use unexisted classes as exemple for delivered artifact usage)

To be honest I'm not sure what should be adjusted - guide or generator.

openapi-generator version

6.2.0

Steps to reproduce

Just take this example https://github.com/OpenAPITools/openapi-generator/tree/master/samples/client/petstore/java/resttemplate and try to impelemnt it step by step as in README.md

Suggest a fix

Change code in example from
ApiClient defaultClient = Configuration.getDefaultApiClient();
to
ApiClient defaultClient = new ApiClient();

Or adjust generators to produse such class. (Not sure that it's needed)

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 samples/client/petstore/java/resttemplate/README.md and compare its Configuration-based example with the generated RestTemplate client shown in the sample. Reproduce the README steps, then update the guide or generator only after confirming which source produces the incorrect usage; done means the documented example uses classes present in the generated artifact.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.