Commit Graph

39 Commits

Author SHA1 Message Date
delenius
079addb6db More fine-grained fix
Instead of just ignoring default values in the generated
model constructors, we modify the generator code in Java.
The template checks for null before outputting a default value.
2016-02-18 11:12:01 -08:00
delenius
692c865c76 Handle empty response.body from superagent
Superagent does not always produce a `body`. See
http://visionmedia.github.io/superagent/ for details. When it
doesn't, we should deserialize the raw `response.text` rather
than returning `null`. Currently, the JS client always returns
`null` when the return type is String! This commit fixes
that.
2016-02-17 22:39:53 -08:00
xhh
bb70073ca3 JavaScript: fix call to buildCollectisnParam
Closes #2166
2016-02-18 10:31:21 +08:00
xhh
33d7d7b4b1 JavaScript: update Petstore sample and fix tests 2016-02-18 10:20:01 +08:00
xhh
7beb7373c2 Merge branch 'master' into javascript-auth
Conflicts:
	modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache
	modules/swagger-codegen/src/main/resources/Javascript/api.mustache
2016-02-16 17:08:58 +08:00
delenius
59931ef0f7 Correct exporting of enum classes
Fixes #2102.
2016-02-15 07:46:14 -08:00
wing328
a159998293 Merge pull request #2115 from delenius/enums
Use objects for enums, not constructor functions
2016-02-15 10:29:34 +08:00
delenius
fa2333717a Use static model factory methods
The `constructFromObject` factory methods should be class methods
(or "static" methods), not instance methods.

With this commit, ApiClient no longer calls the model constructors
directly. Instead, it calls the new static factory method to get the
new instance. If there is no data on the top level, null is returned.

It is still possible for users to call the model constructors
directly, of course.
2016-02-12 07:54:04 -08:00
delenius
86154f87c3 Use objects for enums, not constructor functions
Fixes #2101.
2016-02-12 07:53:51 -08:00
delenius
c7766457bd Don't set missing optional params in models
Fixes #2103.

In the constructFromObject methods, we were always setting all the
parameters, including optional ones that were missing in the `data`
object. Because of the `convertToType` calls, this had the effect
of producing the *strings* `"undefined"` or `"null"` as property
values on the constructed object! This obviously leads to difficult
bugs.

This commit makes sure that we first check that the data field
exists in the data object. Note that both `null` and `undefined`
values will be skipped.
2016-02-10 17:18:31 -08:00
delenius
aab96ec772 Remove unused callback param when using promises 2016-02-08 23:39:05 -08:00
delenius
153faebc6d Modify JS PetStore tests for prototypes change
This is just the result of running ./bin/javascript-petstore.sh
after the fix for #2044.
2016-02-08 12:39:30 -08:00
xhh
d52ebdf684 JavaScript client: Add authentications support
Closes #1952
2016-02-06 16:26:15 +08:00
xhh
47f25efb25 JavaScript client: support collectionFormat for parameters
Closes #1953
2016-02-04 16:30:41 +08:00
xhh
2eb125681e JavaScript client: handle response deserialization
to support array of models and Date property in model

Closes #1951
2016-02-04 12:36:44 +08:00
xhh
c7fa44cd0c Fix ApiClient.isFileParam in browserify runtime
Closes #2028
2016-02-04 08:43:13 +08:00
xhh
5463015725 JavaScript client: use brackets to access mobel properties
to support nonstandard characters in property names, e.g. "user-status".
2016-02-03 16:01:33 +08:00
xhh
29885ab2ae Lock version for superagent to 1.7.1
to avoid an unexpected behavior on request.header in 1.7.2:
Node version's request.header uses lower-case keys while browser
version's request.header keeps current case.

See also visionmedia/superagent#873
2016-01-27 12:06:22 +08:00
xhh
794589d6b8 JavaScript: add default headers and some tests 2016-01-22 18:46:29 +08:00
wing328
a550eec389 Merge pull request #1942 from xhh/javascript-fixes
[JavaScript] Fix initialization issues on array and nested model fields
2016-01-22 18:15:20 +08:00
GU Yu (Byron)
cad64724a5 Remove useless tests 2016-01-22 17:39:25 +08:00
xhh
16e367bdc8 JavaScript: fix constructFromObject for Array fields
Closes #1721
2016-01-22 11:23:45 +08:00
xhh
3b5462c1e9 Use String for "binary" as a workaronud 2016-01-20 10:34:36 +08:00
xhh
9c580a2447 Set accept header for JavaScript client 2016-01-20 10:29:09 +08:00
xhh
40d83e7f52 Some cleanup 2016-01-19 22:52:05 +08:00
xhh
14630c7632 Make JavaScript client work in both Node.js and browser
* Replace jQuery with SuperAgent which works in both Node.js and browser
* Use UMD pattern (returnExports.js) to make the module exporting compatible
  with all major systems: AMD, Node.js (CommonJS) and browser
* Implement support of header and form parameters. Closes #1736
* Move HTTP requesting code to `ApiClient` and allow customizing options
  in it, e.g. "basePath"
* Update unit tests accordingly and add some tests for `ApiClient`
2016-01-19 22:21:36 +08:00
xhh
1777124e62 Javascript: remove call to apiClietn.parameterToString 2015-12-17 21:37:04 +08:00
xhh
1b0294dac0 Javascript: fix the constructFromObject issue
Closes #1721
Also fixed indentations in models
2015-12-17 21:29:58 +08:00
xhh
a58f755a6a Escape path parameters with encodeURIComponent
and tweak the test command
2015-12-17 21:19:28 +08:00
xhh
f07b75f419 Include Javascript client into integration test
and return the promise-like result of $.ajax for API
2015-12-17 20:41:09 +08:00
xhh
794783a4bb Javascript: bug fixes, clean-ups, tests
- Fix the "apiClient.escapeString" issue
- Remove unused code in api.mustache
- Add test case for creating and getting Pet
2015-12-17 20:05:00 +08:00
xhh
dcfe40fc44 Configure Javascript tests to allow running in browser 2015-12-17 18:51:12 +08:00
xhh
146b4a4813 Use a more real jquery mocking in test 2015-12-17 18:00:09 +08:00
xhh
cc408a0dd7 Add unit tests to Javascript Petstore sample 2015-12-17 00:32:50 +08:00
xhh
2c1d8b19d2 Make Javascript client a Node.js (NPM) module 2015-12-16 23:51:48 +08:00
xhh
199c4f70ad Add some config options to Javascript client codegen 2015-12-16 19:57:44 +08:00
xhh
3f3e444ab1 Some clean-ups for the Javascript client codegen 2015-12-15 23:00:09 +08:00
thibaultclem
7c72552780 Update JS Client Petstore samples after fixing issue on the JS api.mustache 2015-12-09 16:32:18 +07:00
wing328
7aab20485a add bin and petstore samples for JS 2015-12-07 10:53:40 +08:00