OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.81k stars 6.58k forks source link

[BUG] Typescript-rxjs: api client instance created with withMiddleware() does not use new middlewares #9098

Open jokester opened 3 years ago

jokester commented 3 years ago

Bug Report Checklist

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)

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.

macjohnny commented 3 years ago

Cc @denyo