Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new generator: typescript-rxjs #1884

Merged
merged 25 commits into from
Jan 21, 2019
Merged

Conversation

denyo
Copy link
Contributor

@denyo denyo commented Jan 11, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

This PR adds a new generator typescript-rxjs which is based on typescript-fetch and replaces all fetch and Promise related things with rxjs ajax and Observables: https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/dom/AjaxObservable.ts.

Feature/rxjs

* feat: duplicate typescript-fetch, add docs

* duplicate fetch codegen to use for rxjs

* remove mapping helpers from modesl

* introduce rxjs, adjust apis

* make middlewares work

* fix namespace issue with babel

* fix enum generation

* fix formatting of enum

* remove other readme

* feat: duplicate typescript-fetch, add docs

* duplicate fetch codegen to use for rxjs

* remove mapping helpers from modesl

* introduce rxjs, adjust apis

* make middlewares work

* fix namespace issue with babel

* fix enum generation

* fix formatting of enum

* remove other readme
@denyo denyo changed the title Typescript rxjs add new genartor: typescript-rxjs Jan 11, 2019
@denyo denyo changed the title add new genartor: typescript-rxjs add new generator: typescript-rxjs Jan 11, 2019
@wing328
Copy link
Member

wing328 commented Jan 11, 2019

cc @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @nicokoenig (2018/09) @topce (2018/10)

@macjohnny
Copy link
Member

see also #802 (comment)

@denyo
Copy link
Contributor Author

denyo commented Jan 14, 2019

@macjohnny thanks for the feedback and hints.
I applied the small changes. However I won't have the time to add tests or anything. So if this is required then I would need someone else to jump in and continue from here.

Copy link
Member

@macjohnny macjohnny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the interface RequestInit seems to be missing.

macjohnny and others added 8 commits January 15, 2019 10:38
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
…untime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
@denyo
Copy link
Contributor Author

denyo commented Jan 15, 2019

Thanks for the additions.
RequestInit is part of typescript itself.

…pis.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>
@macjohnny
Copy link
Member

RequestInit is part of typescript itself.

You are right, I missed that. So you can revert the change I suggested that adds the interface AjaxRequestParts

@denyo
Copy link
Contributor Author

denyo commented Jan 15, 2019

Will do. Also the one with return throwError(res) causes problems:

Type error: Type 'Observable<Observable<never> | T>' is not assignable to type 'Observable<T>'.
  Type 'Observable<never> | T' is not assignable to type 'T'.
    Type 'Observable<never>' is not assignable to type 'T'.  TS2322

    44 | 
    45 |     protected request<T>(context: RequestOpts): Observable<T> {
  > 46 |         return this.rxjsRequest(this.createRequestArgs(context)).pipe(
       |         ^
    47 |             map((res) => {
    48 |                 if (res.status >= 200 && res.status < 300) {
    49 |                     return res.response as T;

@macjohnny
Copy link
Member

Also the one with return throwError(res) causes problems:

you are right, it is inside a map operator, not switchMap. Sorry for that

@wing328 wing328 merged commit d33c4bb into OpenAPITools:master Jan 21, 2019
@wing328
Copy link
Member

wing328 commented Jan 21, 2019

@denyo thanks for the PR, which has been merged into master.

@macjohnny thanks for reviewing the change.

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* Merged in feature/rxjs (pull request #2)

Feature/rxjs

* feat: duplicate typescript-fetch, add docs

* duplicate fetch codegen to use for rxjs

* remove mapping helpers from modesl

* introduce rxjs, adjust apis

* make middlewares work

* fix namespace issue with babel

* fix enum generation

* fix formatting of enum

* remove other readme

* feat: duplicate typescript-fetch, add docs

* duplicate fetch codegen to use for rxjs

* remove mapping helpers from modesl

* introduce rxjs, adjust apis

* make middlewares work

* fix namespace issue with babel

* fix enum generation

* fix formatting of enum

* remove other readme

* add bash scripts to generate samples

* remove environment import

* add rxjs dependency to package.mustache

* add genereated samples

* add docs

* add windows scripts

* adjust license info

* update "ensure-up-to-date" by typescript-rxjs

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* Update modules/openapi-generator/src/main/resources/typescript-rxjs/apis.mustache

Co-Authored-By: denyo <hacker.bernd@gmail.com>

* fix missing return for Observable<void>

* use shorthand syntax

* improve linting

* improve linting

* revert previous changes

* Revert "Update modules/openapi-generator/src/main/resources/typescript-rxjs/runtime.mustache"

This reverts commit 26f65ca.

* recreate typescript-rxjs samples
@denyo denyo deleted the typescript-rxjs branch July 10, 2019 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants