OpenAPITools / OpenAPITools/openapi-generator
Adapter of type listed in anyOf isn't resolved
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
getDelegateAdapter goes through the list of adapters, but skips mentioned adapter (in this case this adapter). And this and TypeToken.get({{.}}.class refers to different model types.
This leads to getDelegateAdapter tries to find this adapter first and only after that it starts searching adapter for TypeToken.get({{.}}.class by proceeding iterating through adapters list. But if TypeToken.get({{.}}.class adapter is listed before this adapter - custom type adapter for TypeToken.get({{.}}.class is never found... It makes clients randomly break depending on chosen names for model (as they are sorted).
Not sure is my explanation clear, TL;DR; probably getDelegateAdapter should be replaced by getAdapter here?
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 modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache at line 47 and inspect how getDelegateAdapter handles the adapter list for anyOf models. Reproduce the failure with an adapter listed before the current adapter, then verify that generated clients consistently find the TypeToken adapter regardless of model-name ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100