OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
[ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When creating new SomeApi instance like const newInstance = someApiInstance.withMiddleware(middlewares), the provided middlewares are not used by new instance.
This is because some methods, including rxjsRequest(), are defined as arrow functions and are copied to new instance in clone(). With current code, the methods in the new instance alway reads middleware of some old instance (this when creating the arrow functions).
IMO the current behavior effectively removed the meaning of withMiddleware().
openapi-generator version
generator-cli v4.3.1 (the problem still exists in master)
Bug Report Checklist
Description
When creating new
SomeApi
instance likeconst newInstance = someApiInstance.withMiddleware(middlewares)
, the provided middlewares are not used by new instance.This is because some methods, including
rxjsRequest()
, are defined as arrow functions and are copied to new instance inclone()
. With current code, the methods in the new instance alway reads middleware of some old instance (this
when creating the arrow functions).IMO the current behavior effectively removed the meaning of
withMiddleware()
.openapi-generator version
generator-cli v4.3.1
(the problem still exists inmaster
)Related issues/PRs
They were changed to current form in https://github.com/OpenAPITools/openapi-generator/pull/3077/files , seemingly to save bytes.
Suggest a fix
Changing clone method to use
new
(like in typescript-fetch ) should fix it.