openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

Adapter of type listed in anyOf isn't resolved

Open dmitryb-dev opened this issue 2 years ago • 0 comments

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.

https://github.com/OpenAPITools/openapi-generator/blob/69f79fb7892948590a9ffe46754c47ddd2634be1/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/anyof_model.mustache#L47

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?

dmitryb-dev avatar Oct 13 '22 21:10 dmitryb-dev