-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[TS][Inverisify] Adding support for RxJS 6 #2793
Merged
wing328
merged 11 commits into
OpenAPITools:master
from
gualtierim:typescript-inverisify-rxjs6
May 27, 2019
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
66f93dd
Add support to http patch method
gualtierim ee663f3
Add support to rxjs6
gualtierim 7d3f2c6
Align sample
gualtierim d2062a4
Add sample for openapi3
gualtierim 50fddc7
Change usage of single quote to use only double ones
gualtierim 84a7f98
Fix wrong changes of typescript-angular package.json template
gualtierim 85d5101
Add `map` keyword inside reservedWords
gualtierim ed34de6
Add typescript-inversify inside README
gualtierim b992751
Merge branch 'master' into typescript-inverisify-rxjs6
wing328 fccd02c
fix merge issue, update petstore
wing328 2005c10
update doc
wing328 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
import IHttpClient from "./IHttpClient"; | ||
import { Observable } from "rxjs/Observable"; | ||
|
||
{{^useRxJS6}} | ||
import { Observable } from 'rxjs/Observable'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i suggest to use double quotes as in the rest of the code |
||
{{/useRxJS6}} | ||
{{#useRxJS6}} | ||
import { Observable, from } from 'rxjs'; | ||
{{/useRxJS6}} | ||
|
||
import "whatwg-fetch"; | ||
import HttpResponse from "./HttpResponse"; | ||
import {injectable} from "inversify"; | ||
import "rxjs/add/observable/fromPromise"; | ||
import { Headers } from "./Headers"; | ||
|
||
@injectable() | ||
class HttpClient implements IHttpClient { | ||
|
||
get(url:string, headers?: Headers):Observable<HttpResponse> { | ||
return this.performNetworkCall(url, "get", undefined, headers); | ||
return this.performNetworkCall(url, "GET", undefined, headers); | ||
} | ||
|
||
post(url: string, body: {}|FormData, headers?: Headers): Observable<HttpResponse> { | ||
return this.performNetworkCall(url, "post", this.getJsonBody(body), this.addJsonHeaders(headers)); | ||
return this.performNetworkCall(url, "POST", this.getJsonBody(body), this.addJsonHeaders(headers)); | ||
} | ||
|
||
put(url: string, body: {}, headers?: Headers): Observable<HttpResponse> { | ||
return this.performNetworkCall(url, "put", this.getJsonBody(body), this.addJsonHeaders(headers)); | ||
return this.performNetworkCall(url, "PUT", this.getJsonBody(body), this.addJsonHeaders(headers)); | ||
} | ||
|
||
patch(url: string, body: {}, headers?: Headers): Observable<HttpResponse> { | ||
return this.performNetworkCall(url, "PATCH", this.getJsonBody(body), this.addJsonHeaders(headers)); | ||
} | ||
|
||
|
||
delete(url: string, headers?: Headers): Observable<HttpResponse> { | ||
return this.performNetworkCall(url, "delete", undefined, headers); | ||
return this.performNetworkCall(url, "DELETE", undefined, headers); | ||
} | ||
|
||
private getJsonBody(body: {}|FormData) { | ||
|
@@ -56,7 +67,13 @@ class HttpClient implements IHttpClient { | |
return httpResponse; | ||
}); | ||
}); | ||
return Observable.fromPromise(promise); | ||
|
||
{{^useRxJS6}} | ||
return Observable.fromPromise(promise); | ||
{{/useRxJS6}} | ||
{{#useRxJS6}} | ||
return from(promise); | ||
{{/useRxJS6}} | ||
} | ||
} | ||
|
||
|
8 changes: 7 additions & 1 deletion
8
modules/openapi-generator/src/main/resources/typescript-inversify/IHttpClient.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
modules/openapi-generator/src/main/resources/typescript-inversify/apiInterface.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this changed? it is not related to typescript-inversify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a config's property
useRxJS6
to allow the user to decide the using of rxjs6 or rxjs5There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you are modifying the
typescript-angular
fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I did a big mistake