-
Notifications
You must be signed in to change notification settings - Fork 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
Add usePromise parameter to JS client #2072
Conversation
This is just the result of running ./bin/javascript-petstore.sh after the fix for swagger-api#2044.
Update parser, inline resolver
Modify JS PetStore tests for prototypes change
@delenius thanks for adding the support for Promises. Instead of modifying bin/javascript-petstore.sh, I would suggest adding If it's not too much work, I would suggest using CLI option (instead of |
@wing328, can you point me to how to add a CLI option instead of |
Tests added as discussed above, though some tests are not implemented:
|
would this help #1851 ? |
That looks like what I did, except that there is no |
Sorry I missed the lines about adding USE_PROMISES to CLIOption. |
Btw, I saw commits from others in the commit tabs. Is that due to |
Oh, yeah I was confused by that too. Yes, probably. I was trying to integrate the latest master branch into my feature branch... |
@@ -96,6 +82,8 @@ public JavascriptClientCodegen() { | |||
"version of the project (Default: using info.version or \"1.0.0\")")); | |||
cliOptions.add(new CliOption(PROJECT_LICENSE_NAME, | |||
"name of the license the project uses (Default: using info.license.name)")); | |||
cliOptions.add(new CliOption(USE_PROMISES, | |||
"use Promises as return values from the client API, instead of superagent callbacks (Default: false)")); |
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.
Instead of putting the default value in the description, you can use .defaultValue
instead. Here is an example:
Line 79 in ee8547f
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("SwaggerClient")); |
FYI. I usually rebase my branch (e.g. fix_something) as follows:
Assuming |
@wing328, yeah that's how I did my rebase too, except I think I did a git push (to I fixed the |
@delenius thanks for the update. We can clean those up later. I also left you a comment about wildcard import. |
I for sure did not change those imports (it's because other people's commits are listed with my PR for some reason). I agree on not using wildcards, and I typically use IDE auto-imports which does not generate wildcards. But I can try to fix them anyway. |
Yes, you're right. @fehguy did that. No worry then. I'll review your PR and approve shortly. |
No worries, I already fixed the imports. |
👍 |
@wing328, regarding the other people's commits showing up: Is it because I messed up my rebase somehow? Or does that always happen after a rebase? I'd like to not repeat the same mistake in the future. |
It never happens to me when I perform a rebase. I've seen others doing that due to a bad rebase. |
Add usePromise parameter to JS client
PR merged. Thanks again for the contribution 🍻 |
This adds a "usePromise" boolean parameter to the JS client generator (disabled by default).
Fixes #2014.
For some discussion on the benefits of using Promises, see http://bluebirdjs.com/docs/why-promises.html
Note: I have not added any unit tests for this feature, because it produces a different client API, so the existing PetStore tests will not work. I could add:
samples/client/javascript/test/api/PetApiPromiseTest.js
samples/client/javascript/test/api/ApiClientPromiseTest.js
and furthermore, modify bin/javascript-petstore.sh to produce a promise version of the test client.
Let me know if you want me to do that, or create tests in any other way.
In the meantime, consider this addition experimental. It does not impact existing functionality since it has to be explicitly enabled using
--additional-properties usePromises=true